<sql>
LEFT JOIN sys_office c ON c.id = a.company_id
LEFT JOIN sys_area ca ON ca.id = c.area_id
LEFT JOIN sys_office o ON o.id = a.office_id
LEFT JOIN sys_area oa ON oa.id = o.area_id
LEFT JOIN sys_user cu ON cu.id = c.primary_person
LEFT JOIN sys_user cu2 ON cu2.id = c.deputy_person
LEFT JOIN sys_user ou ON ou.id = o.primary_person
LEFT JOIN sys_user ou2 ON ou2.id = o.deputy_person
LEFT JOIN xj_school sc ON sc.id = a.school
</sql>
<!-- 查询语句,根据Id查询结果,返回类型可以直接写User,而不同配置resultMap省略编写xml的时间 -->
<select resultType="User">
SELECT
<include refid="userColumns"/>
FROM sys_user a
<include refid="userJoins"/>
WHERE a.id = #{id}
</select>
<!-- 查询语句,根据User对象来查询,这里的参数即为User变量 -->
<select resultType="User" parameterType="User">
SELECT
<include refid="userColumns"/>
FROM sys_user a
<include refid="userJoins"/>
WHERE
a.login_name = #{loginName}
AND a.del_flag = #{DEL_FLAG_NORMAL}
</select>
<!-- 插入语句,参数肯定是User对象 -->
<insert>
INSERT INTO sys_user(
id,
company_id,
office_id,
login_name,
password,
no,
name,
email,
phone,
mobile,
user_type,
create_by,
create_date,
update_by,
update_date,
remarks,
login_flag,
photo,
qrcode,
del_flag,
dept_id,
staff_id,
school
) VALUES (
#{id},
#{company.id},
#{office.id},
#{loginName},
#{password},
#{no},
#{name},
#{email},
#{phone},
#{mobile},
#{userType},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{loginFlag},
#{photo},
#{qrCode},
#{delFlag},
#{dept.id},
#{staff.id},
#{school.id}
)
</insert>