|
@@ -89,36 +89,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
|
|
- select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
|
|
|
- u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader_id, d.director_id, d.type
|
|
|
- from
|
|
|
- sys_user u
|
|
|
- left join sys_dept d on u.dept_id = d.dept_id
|
|
|
- where u.del_flag = '0'
|
|
|
- <if test="userId != null and userId != 0">
|
|
|
- AND u.user_id = #{userId}
|
|
|
- </if>
|
|
|
- <if test="userName != null and userName != ''">
|
|
|
- AND u.user_name like concat('%', #{userName}, '%')
|
|
|
- </if>
|
|
|
- <if test="status != null and status != ''">
|
|
|
- AND u.status = #{status}
|
|
|
- </if>
|
|
|
- <if test="phonenumber != null and phonenumber != ''">
|
|
|
- AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
|
|
- </if>
|
|
|
- <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
|
|
- AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
|
|
- </if>
|
|
|
- <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
|
|
- AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
|
|
- </if>
|
|
|
- <if test="deptId != null and deptId != 0">
|
|
|
- AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
|
|
|
- </if>
|
|
|
- <!-- 数据范围过滤 -->
|
|
|
- ${params.dataScope}
|
|
|
- </select>
|
|
|
+ select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
|
|
|
+ u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader_id,
|
|
|
+ d.director_id, d.type
|
|
|
+ from
|
|
|
+ sys_user u
|
|
|
+ left join sys_dept d on u.dept_id = d.dept_id
|
|
|
+ where u.del_flag = '0'
|
|
|
+ <if test="userId != null and userId != 0">
|
|
|
+ AND u.user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="userName != null and userName != ''">
|
|
|
+ AND u.user_name like concat('%', #{userName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="status != null and status != ''">
|
|
|
+ AND u.status = #{status}
|
|
|
+ </if>
|
|
|
+ <if test="phonenumber != null and phonenumber != ''">
|
|
|
+ AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND u.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
|
|
+ AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+ <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
|
|
+ AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
|
|
+ </if>
|
|
|
+ <if test="deptId != null and deptId != 0">
|
|
|
+ AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
|
|
|
+ ancestors) ))
|
|
|
+ </if>
|
|
|
+ <!-- 数据范围过滤 -->
|
|
|
+ ${params.dataScope}
|
|
|
+ </select>
|
|
|
|
|
|
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
|
|
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
|
@@ -166,8 +171,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</select>
|
|
|
|
|
|
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
|
|
|
- select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
|
|
|
- </select>
|
|
|
+ select user_id, user_name
|
|
|
+ from sys_user
|
|
|
+ where user_name = #{userName}
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ and tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ and del_flag = '0'
|
|
|
+ limit 1
|
|
|
+ </select>
|
|
|
|
|
|
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
|
|
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
|
|
@@ -191,6 +203,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="status != null and status != ''">status,</if>
|
|
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
|
<if test="remark != null and remark != ''">remark,</if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">tenant_id,</if>
|
|
|
+ <if test="userType != null and userType != ''">user_type,</if>
|
|
|
create_time
|
|
|
)values(
|
|
|
<if test="userId != null and userId != ''">#{userId},</if>
|
|
@@ -205,30 +219,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="status != null and status != ''">#{status},</if>
|
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
|
<if test="remark != null and remark != ''">#{remark},</if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">#{tenantId},</if>
|
|
|
+ <if test="userType != null and userType != ''">#{userType},</if>
|
|
|
sysdate()
|
|
|
)
|
|
|
</insert>
|
|
|
|
|
|
<update id="updateUser" parameterType="SysUser">
|
|
|
- update sys_user
|
|
|
- <set>
|
|
|
- <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
|
|
- <if test="userName != null and userName != ''">user_name = #{userName},</if>
|
|
|
- <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
|
|
- <if test="email != null ">email = #{email},</if>
|
|
|
- <if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
|
|
- <if test="sex != null and sex != ''">sex = #{sex},</if>
|
|
|
- <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
|
|
- <if test="password != null and password != ''">password = #{password},</if>
|
|
|
- <if test="status != null and status != ''">status = #{status},</if>
|
|
|
- <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
|
|
- <if test="loginDate != null">login_date = #{loginDate},</if>
|
|
|
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
|
- <if test="remark != null">remark = #{remark},</if>
|
|
|
- update_time = sysdate()
|
|
|
- </set>
|
|
|
- where user_id = #{userId}
|
|
|
- </update>
|
|
|
+ update sys_user
|
|
|
+ <set>
|
|
|
+ <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
|
|
+ <if test="userName != null and userName != ''">user_name = #{userName},</if>
|
|
|
+ <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
|
|
+ <if test="email != null ">email = #{email},</if>
|
|
|
+ <if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
|
|
+ <if test="sex != null and sex != ''">sex = #{sex},</if>
|
|
|
+ <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
|
|
+ <if test="password != null and password != ''">password = #{password},</if>
|
|
|
+ <if test="status != null and status != ''">status = #{status},</if>
|
|
|
+ <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
|
|
+ <if test="loginDate != null">login_date = #{loginDate},</if>
|
|
|
+ <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
|
+ <if test="remark != null">remark = #{remark},</if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
|
|
|
+ <if test="userType != null and userType != ''">user_type = #{userType},</if>
|
|
|
+ update_time = sysdate()
|
|
|
+ </set>
|
|
|
+ where user_id = #{userId}
|
|
|
+ </update>
|
|
|
|
|
|
<update id="updateUserStatus" parameterType="SysUser">
|
|
|
update sys_user set status = #{status} where user_id = #{userId}
|