<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.stylefeng.guns.modular.system.dao.UserMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.User">
|
<id column="id" property="id" />
|
<result column="avatar" property="avatar" />
|
<result column="account" property="account" />
|
<result column="password" property="password" />
|
<result column="salt" property="salt" />
|
<result column="name" property="name" />
|
<result column="birthday" property="birthday" />
|
<result column="sex" property="sex" />
|
<result column="email" property="email" />
|
<result column="phone" property="phone" />
|
<result column="roleid" property="roleid" />
|
<result column="deptid" property="deptid" />
|
<result column="status" property="status" />
|
<result column="createtime" property="createtime" />
|
<result column="commission" property="commission" />
|
<result column="isMain" property="isMain" />
|
<result column="lastId" property="lastId" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<select id="getList" resultType="com.stylefeng.guns.modular.system.model.UserVo">
|
select t1.*,t2.name roleName,t3.fullname as departmentName from sys_user t1
|
left JOIN sys_role t2 on t1.roleid = t2.id
|
LEFT JOIN sys_dept t3 on t1.deptid = t3.id where t1.`status` != 3
|
<if test="account != null and account !=''">
|
and t1.account like concat("%",#{account},"%")
|
</if>
|
<if test="name != null and name !=''">
|
and t1.name like concat("%",#{name},"%")
|
</if>
|
<if test="roleName != null and roleName !=''">
|
and t2.name like concat("%",#{roleName},"%")
|
</if>
|
<if test="departmentName != null and departmentName !=''">
|
and t3.name like concat("%",#{departmentName},"%")
|
</if>
|
|
</select>
|
|
<sql id="Base_Column_List">
|
id, account, name, birthday, sex, email, avatar,
|
phone, roleid,
|
deptid, status,
|
createtime, commission
|
</sql>
|
|
<sql id="Base_Column_List_With_Pwd">
|
id, account, name, birthday,password, sex, email, avatar,
|
phone, roleid,salt,
|
deptid, status,
|
createtime, commission
|
</sql>
|
|
<select id="selectUsers" resultType="map">
|
select
|
<include refid="Base_Column_List" />
|
from sys_user
|
where status != 3
|
<if test="name != null and name != ''">
|
and (phone like CONCAT('%',#{name},'%')
|
or account like CONCAT('%',#{name},'%')
|
or name like CONCAT('%',#{name},'%'))
|
</if>
|
<if test="deptid != null and deptid != 0">
|
and (deptid = #{deptid} or deptid in ( select id from sys_dept where pids like CONCAT('%[', #{deptid}, ']%') ))
|
</if>
|
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
|
and (createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
|
</if>
|
</select>
|
|
<update id="setStatus">
|
update sys_user set status = #{status} where id =
|
#{userId}
|
</update>
|
|
<update id="changePwd">
|
update sys_user set password = #{pwd} where id =
|
#{userId}
|
</update>
|
|
<update id="setRoles">
|
update sys_user set roleid = #{roleIds} where id =
|
#{userId}
|
</update>
|
|
<select id="getByAccount" resultType="user">
|
select
|
<include refid="Base_Column_List_With_Pwd" />
|
from sys_user where account = #{account} and status != 3
|
</select>
|
|
</mapper>
|