<!-- 根据账号来获取用户信息 -->
<select id="findByLogin" parameterType="java.lang.String" resultMap="UserLoginMap">
select u.*,ur.id as user_role_id,ur.name,ur.role_name from user u inner join user_associate_role uar on u.id = uar.user_id inner join user_role ur on uar.role_id = ur.id where u.login = #{login}
</select>
<!--根据主键获取对象-->
<select id="get" parameterType="com.csdn.demo.sys.entity.User" resultMap="UserMap">
select u.* from user u
WHERE id=#{id}
</select>
<!--修改-->
<update id="update" parameterType="com.csdn.demo.sys.entity.User">
UPDATE user SET user_name=#{userName},address=#{address},job=#{job},group_id=#{orgGroup.groupId},birth_date=#{birthDate},city=#{city},district=#{district},province=#{province},street_address=#{streetAddress}
WHERE id=#{id}
</update>
<!--删除-->
<delete id="delete" parameterType="com.csdn.demo.sys.entity.User">
DELETE FROM user WHERE id=#{id}
</delete>
<!--分页查询组织架构底下的用户-->
<select id="findGroupUserByPage" parameterType="com.csdn.demo.sys.entity.QueryUser" resultMap="UserMap">
select u.* from user u
WHERE 1=1
<if test="userName!=null and userName!='' ">
AND u.user_name like concat(#{userName},'%')
</if>
<if test="sort!= null and sort!='' ">
order by ${sort} ${order}
</if>
limit #{offset},#{limit}
</select>
<!--统计组织架构底下的用户-->
<select id="countGroupUser" parameterType="com.csdn.demo.sys.entity.QueryUser" resultType="int">
select count(1) from user u
WHERE 1=1
<if test="userName!=null and userName!='' ">
AND u.user_name like concat(#{userName},'%')
</if>
</select>
<!--分页查询-->
<select id="findByPage" parameterType="com.csdn.demo.sys.entity.QueryUser" resultMap="UserMap">
select u.* from user u
WHERE 1=1
<if test="login!=null and login!='' ">
AND u.login=#{login}
</if>
<if test="password!=null and password!='' ">
AND u.password=#{password}
</if>
<if test="userName!=null and userName!='' ">
AND u.user_name=#{userName}
</if>
<if test="address!=null and address!='' ">
AND u.address=#{address}
</if>
<if test="job!=null and job!='' ">
AND u.job=#{job}
</if>
<if test="groupId!=null and groupId!='' ">
AND u.group_id=#{groupId}
</if>
<if test="birthDate!=null and birthDate!='' ">
AND u.birth_date=#{birthDate}
</if>
<if test="city!=null and city!='' ">
AND u.city=#{city}
</if>
<if test="district!=null and district!='' ">
AND u.district=#{district}
</if>
<if test="province!=null and province!='' ">
AND u.province=#{province}
</if>
<if test="streetAddress!=null and streetAddress!='' ">
AND u.street_address=#{streetAddress}
</if>
<if test="state!=null and state!='' ">
AND u.state=#{state}
</if>
<if test="type!=null and type!='' ">
AND u.type=#{type}
</if>
<if test="lastLoginDate!=null and lastLoginDate!='' ">
AND u.last_login_date=#{lastLoginDate}
</if>
<if test="sort!= null and sort!='' ">
order by ${sort} ${order}
</if>
limit #{offset},#{limit}
</select>
<!--统计-->
<select id="count" parameterType="com.csdn.demo.sys.entity.QueryUser" resultType="int">
SELECT count(*) FROM user
WHERE 1=1
<if test="login!=null and login!='' ">
AND login=#{login}
</if>
<if test="password!=null and password!='' ">
AND password=#{password}
</if>
<if test="userName!=null and userName!='' ">
AND user_name=#{userName}
</if>
<if test="address!=null and address!='' ">
AND address=#{address}
</if>
<if test="job!=null and job!='' ">
AND job=#{job}
</if>
<if test="groupId!=null and groupId!='' ">
AND group_id=#{groupId}
</if>
<if test="birthDate!=null and birthDate!='' ">
AND birth_date=#{birthDate}
</if>
<if test="city!=null and city!='' ">
AND city=#{city}
</if>
<if test="district!=null and district!='' ">
AND district=#{district}
</if>
<if test="province!=null and province!='' ">
AND province=#{province}
</if>
<if test="streetAddress!=null and streetAddress!='' ">
AND street_address=#{streetAddress}
</if>
<if test="state!=null and state!='' ">
AND state=#{state}
</if>
<if test="type!=null and type!='' ">
AND type=#{type}
</if>
<if test="lastLoginDate!=null and lastLoginDate!='' ">
AND last_login_date=#{lastLoginDate}
</if>
<if test="sort!= null and sort!='' ">
order by ${sort} ${order}
</if>
</select>
<!--查询-->
<select id="query" parameterType="com.csdn.demo.sys.entity.QueryUser" resultMap="UserMap">
SELECT id,login,password,user_name,address,job,group_id,birth_date,city,district,province,street_address,state,type,last_login_date FROM user
WHERE 1=1
<if test="login!=null and login!='' ">
AND login=#{login}
</if>
<if test="password!=null and password!='' ">
AND password=#{password}
</if>
<if test="userName!=null and userName!='' ">
AND user_name=#{userName}
</if>
<if test="address!=null and address!='' ">
AND address=#{address}
</if>
<if test="job!=null and job!='' ">
AND job=#{job}
</if>
<if test="groupId!=null and groupId!='' ">
AND group_id=#{groupId}
</if>
<if test="birthDate!=null and birthDate!='' ">
AND birth_date=#{birthDate}
</if>
<if test="city!=null and city!='' ">
AND city=#{city}
</if>
<if test="district!=null and district!='' ">
AND district=#{district}
</if>
<if test="province!=null and province!='' ">
AND province=#{province}
</if>
<if test="streetAddress!=null and streetAddress!='' ">
AND street_address=#{streetAddress}
</if>
<if test="state!=null and state!='' ">
AND state=#{state}
</if>
<if test="type!=null and type!='' ">
AND type=#{type}
</if>
<if test="lastLoginDate!=null and lastLoginDate!='' ">
AND last_login_date=#{lastLoginDate}
</if>
<if test="sort!= null and sort!='' ">
order by ${sort} ${order}
</if>
</select>