|
|
|
@ -23,10 +23,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
|
<result property="updateBy" column="update_by" /> |
|
|
|
|
<result property="updateTime" column="update_time" /> |
|
|
|
|
<result property="remark" column="remark" /> |
|
|
|
|
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" /> |
|
|
|
|
<result property="wechatNickName" column="wechat_nick_name" /> |
|
|
|
|
<result property="balance" column="balance" /> |
|
|
|
|
<result property="referrerId" column="referrer_id" /> |
|
|
|
|
<association property="referrerSysUser" javaType="SysUser"> |
|
|
|
|
<result property="phonenumber" column="referrer_phonenumber"/> |
|
|
|
|
</association> |
|
|
|
|
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" /> |
|
|
|
|
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" /> |
|
|
|
|
</resultMap> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<resultMap id="deptResult" type="SysDept"> |
|
|
|
|
<id property="deptId" column="dept_id" /> |
|
|
|
|
<result property="parentId" column="parent_id" /> |
|
|
|
@ -36,7 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
|
<result property="leader" column="leader" /> |
|
|
|
|
<result property="status" column="dept_status" /> |
|
|
|
|
</resultMap> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<resultMap id="RoleResult" type="SysRole"> |
|
|
|
|
<id property="roleId" column="role_id" /> |
|
|
|
|
<result property="roleName" column="role_name" /> |
|
|
|
@ -45,9 +51,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
|
<result property="dataScope" column="data_scope" /> |
|
|
|
|
<result property="status" column="role_status" /> |
|
|
|
|
</resultMap> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<sql id="selectUserVo"> |
|
|
|
|
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, |
|
|
|
|
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, |
|
|
|
|
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, |
|
|
|
|
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status |
|
|
|
|
from sys_user u |
|
|
|
@ -55,10 +61,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
|
left join sys_user_role ur on u.user_id = ur.user_id |
|
|
|
|
left join sys_role r on r.role_id = ur.role_id |
|
|
|
|
</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 from sys_user u |
|
|
|
|
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,u.wechat_nick_name,u.balance, d.dept_name, d.leader,referrer.phonenumber as referrer_phonenumber from sys_user u |
|
|
|
|
left join sys_dept d on u.dept_id = d.dept_id |
|
|
|
|
left join sys_user referrer on u.referrer_id = referrer.user_id |
|
|
|
|
where u.del_flag = '0' |
|
|
|
|
<if test="userId != null and userId != 0"> |
|
|
|
|
AND u.user_id = #{userId} |
|
|
|
@ -84,7 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
|
<!-- 数据范围过滤 --> |
|
|
|
|
${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 |
|
|
|
|
from sys_user u |
|
|
|
@ -101,7 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
|
<!-- 数据范围过滤 --> |
|
|
|
|
${params.dataScope} |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectUnallocatedList" 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 |
|
|
|
|
from sys_user u |
|
|
|
@ -119,29 +126,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
|
<!-- 数据范围过滤 --> |
|
|
|
|
${params.dataScope} |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult"> |
|
|
|
|
<include refid="selectUserVo"/> |
|
|
|
|
where u.user_name = #{userName} and u.del_flag = '0' |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult"> |
|
|
|
|
<include refid="selectUserVo"/> |
|
|
|
|
where u.user_id = #{userId} |
|
|
|
|
</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 id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult"> |
|
|
|
|
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1 |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult"> |
|
|
|
|
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1 |
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> |
|
|
|
|
insert into sys_user( |
|
|
|
|
<if test="userId != null and userId != 0">user_id,</if> |
|
|
|
@ -173,7 +180,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
|
sysdate() |
|
|
|
|
) |
|
|
|
|
</insert> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<update id="updateUser" parameterType="SysUser"> |
|
|
|
|
update sys_user |
|
|
|
|
<set> |
|
|
|
@ -194,28 +201,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|
|
|
|
</set> |
|
|
|
|
where user_id = #{userId} |
|
|
|
|
</update> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<update id="updateUserStatus" parameterType="SysUser"> |
|
|
|
|
update sys_user set status = #{status} where user_id = #{userId} |
|
|
|
|
</update> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<update id="updateUserAvatar" parameterType="SysUser"> |
|
|
|
|
update sys_user set avatar = #{avatar} where user_name = #{userName} |
|
|
|
|
</update> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<update id="resetUserPwd" parameterType="SysUser"> |
|
|
|
|
update sys_user set password = #{password} where user_name = #{userName} |
|
|
|
|
</update> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<delete id="deleteUserById" parameterType="Long"> |
|
|
|
|
update sys_user set del_flag = '2' where user_id = #{userId} |
|
|
|
|
</delete> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<delete id="deleteUserByIds" parameterType="Long"> |
|
|
|
|
update sys_user set del_flag = '2' where user_id in |
|
|
|
|
<foreach collection="array" item="userId" open="(" separator="," close=")"> |
|
|
|
|
#{userId} |
|
|
|
|
</foreach> |
|
|
|
|
</foreach> |
|
|
|
|
</delete> |
|
|
|
|
|
|
|
|
|
</mapper> |
|
|
|
|
|
|
|
|
|
</mapper> |
|
|
|
|