| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803 |
- <?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.zd.system.mapper.SysUserMapper">
- <resultMap type="com.zd.model.entity.SysUser" id="SysUserResult">
- <id property="userId" column="user_id"/>
- <result property="deptId" column="dept_id"/>
- <result property="userName" column="user_name"/>
- <result property="nickName" column="nick_name"/>
- <result property="email" column="email"/>
- <result property="phonenumber" column="phonenumber"/>
- <result property="sex" column="sex"/>
- <result property="avatar" column="avatar"/>
- <result property="password" column="password"/>
- <result property="status" column="status"/>
- <result property="delFlag" column="del_flag"/>
- <result property="loginIp" column="login_ip"/>
- <result property="loginDate" column="login_date"/>
- <result property="createBy" column="create_by"/>
- <result property="createTime" column="create_time"/>
- <result property="updateBy" column="update_by"/>
- <result property="updateTime" column="update_time"/>
- <result property="remark" column="remark"/>
- <result property="userType" column="user_type"/>
- <result property="major" column="major"/>
- <result property="grade" column="grade"/>
- <result property="gradeName" column="gradeName"/>
- <result property="category" column="category"/>
- <result property="tutorUserId" column="tutor_user_id"/>
- <result property="position" column="position"/>
- <result property="positionName" column="positionName"/>
- <result property="nature" column="nature"/>
- <result property="deptName" column="dept_name"/>
- <result property="tutorUserName" column="tutorUserName"/>
- <result property="cardNum" column="card_num"/>
- <result property="wechatId" column="wechat_id"/>
- <result property="education" column="education"/>
- <result property="nationality" column="nationality"/>
- <result property="addr" column="addr"/>
- <result property="workStatus" column="work_status"/>
- <result property="dateBirth" column="date_birth"/>
- <result property="department" column="department"/>
- <result property="majorId" column="major_id"/>
- <result property="isCheck" column="is_check"/>
- <result property="signature" column="signature"/>
- <result property="faceImg" column="face_img"/>
- <result property="className" column="class_name"/>
- <result property="createTimeStr" column="createTimeStr"/>
- <association property="dept" column="dept_id" javaType="com.zd.model.entity.SysDept"
- resultMap="deptResult"/>
- <!--<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>-->
- </resultMap>
- <resultMap id="deptResult" type="com.zd.model.entity.SysDept">
- <id property="deptId" column="dept_id"/>
- <result property="parentId" column="parent_id"/>
- <result property="deptName" column="dept_name"/>
- <result property="orderNum" column="order_num"/>
- <result property="leader" column="leader"/>
- <result property="status" column="dept_status"/>
- </resultMap>
- <resultMap id="RoleResult" type="com.zd.model.entity.SysRole">
- <id property="roleId" column="role_id"/>
- <result property="roleName" column="role_name"/>
- <result property="roleKey" column="role_key"/>
- <result property="roleSort" column="role_sort"/>
- <result property="dataScope" column="data_scope"/>
- <result property="status" column="role_status"/>
- </resultMap>
- <!--2.6弃用-->
- <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,u.user_type,
- d.dept_id, d.parent_id, 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,
- u.major,u.major_id, u.grade, u.category, u.tutor_user_id, u.position, u.nature, u.signature,
- u.card_num,u.wechat_id,u.education,u.nationality,u.addr,u.work_status,u.date_birth,
- ut.nick_name tutorUserName,u.is_check
- from sys_user u
- left join sys_dept d on u.dept_id = d.dept_id
- 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
- left join sys_user ut on ut.user_id = u.tutor_user_id
- </sql>
- <sql id="selectUserNewVo">
- 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,u.user_type,
- d.dept_id, d.parent_id, d.dept_name, d.order_num, d.leader, d.status as dept_status,
- sm.`major_name` major, u.grade, u.category, u.tutor_user_id, u.position, u.nature, u.signature,
- u.card_num,u.wechat_id,u.education,u.nationality,u.addr,u.work_status,u.date_birth,
- ut.nick_name tutorUserName,u.is_check,
- uf.face_img,sc.class_name,u.major_id,u.signature,pt.`post_name` positionName
- from sys_user u
- left join sys_dept d on u.dept_id = d.dept_id
- left join sys_user ut on ut.user_id = u.tutor_user_id
- left join lab_students_info uf on u.user_id = uf.join_students_id
- LEFT JOIN sys_class sc ON sc.id = u.grade
- LEFT JOIN sys_major sm ON sm.id = u.major_id
- left join sys_post pt on pt.`post_id` = u.`position`
- </sql>
- <select id="selectUserList" parameterType="com.zd.model.entity.SysUser" resultMap="SysUserResult">
- select u.user_id, u.dept_id, u.nick_name, u.user_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,
- u.major_id, u.grade, u.tutor_user_id, u.position, p.post_name as positionName,
- u.nature,(select sc.class_name from sys_class sc where sc.id = u.grade) gradeName,
- u.card_num,u.wechat_id,u.nationality,u.addr,u.work_status,
- u.date_birth,d.dept_name, d.leader,u.department,
- u.education, u.user_type,sm.`major_name` major,
- ut.nick_name tutorUserName,u.is_check,date_format(u.create_time, '%Y-%m-%d') createTimeStr
- from
- sys_user u
- left join sys_dept d on u.dept_id = d.dept_id
- left join sys_user ut on ut.user_id = u.tutor_user_id
- left join sys_post p on u.position = p.post_id
- LEFT JOIN sys_major sm ON sm.id = u.major_id
- where u.del_flag = '0'
- <if test="userId != null ">
- AND u.user_id = #{userId}
- </if>
- <if test="paramIds != null and paramIds != ''">
- AND find_in_set(u.user_id, #{paramIds})
- </if>
- <if test="userName != null and userName != ''">
- AND u.user_name like concat('%', #{userName}, '%')
- </if>
- <if test="nickName != null and nickName != ''">
- AND u.nick_name like concat('%', #{nickName}, '%')
- </if>
- <if test="cardNum != null and cardNum != ''">
- AND u.card_num = #{cardNum}
- </if>
- <if test="userType != null and userType != ''">
- AND u.user_type = #{userType}
- </if>
- <if test="userType == null or userType == ''">
- AND u.user_type != '00' AND u.user_type != '33'
- </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>
- <if test="ids!=null and ids.size > 0">
- <choose>
- <when test="include">
- AND u.user_id not IN
- </when>
- <otherwise>
- AND u.user_id IN
- </otherwise>
- </choose>
- <foreach item="item" collection="ids" separator="," open="(" close=")" index="">'${item}'</foreach>
- </if>
- <if test="major != null and major != ''">
- AND u.major like concat('%', #{major}, '%')
- </if>
- <if test="majorId != null and majorId != ''">
- AND u.major_id = #{majorId}
- </if>
- <if test="searchValue != null and searchValue != ''">
- AND
- (
- u.nick_name like concat('%', #{searchValue}, '%')
- or
- u.user_name like concat('%', #{searchValue}, '%')
- or
- u.phonenumber like concat('%', #{searchValue}, '%')
- or
- ut.nick_name like concat('%', #{searchValue}, '%')
- or
- p.post_name like concat('%', #{searchValue}, '%')
- )
- </if>
- <if test="grade != null and grade != ''">
- AND u.grade like concat('%', #{grade}, '%')
- </if>
- <if test="category != null and category != ''">
- AND u.category like concat('%', #{category}, '%')
- </if>
- <if test="tutorUserId != null">
- AND u.tutor_user_id = #{tutorUserId}
- </if>
- <if test="nature != null and nature != ''">
- AND u.nature = #{nature}
- </if>
- <if test="position != null and position != ''">
- AND u.position = #{position}
- </if>
- <if test="isCheck != null">
- AND u.is_check = #{isCheck}
- </if>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- order by
- <if test="userType == '11'">
- u.nature ASC,
- </if>
- u.create_time DESC
- </select>
- <select id="selectUserListByDeptIds" resultMap="SysUserResult">
- select u.user_id, u.dept_id, u.nick_name, u.user_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,
- u.card_num,u.wechat_id,u.education,u.nationality,u.addr,u.work_status,u.date_birth
- from
- sys_user u
- where u.del_flag = '0'
- and u.status = '0'
- and u.dept_id in
- <foreach collection="array" item="deptId" open="(" separator="," close=")">
- #{deptId}
- </foreach>
- </select>
- <select id="selectAllocatedList" parameterType="com.zd.model.entity.SysUser" resultMap="SysUserResult">
- select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.user_type, u.email, u.phonenumber, u.status, u.create_time, d.`dept_name`,
- u.card_num,u.wechat_id,u.education,u.nationality,u.addr,u.work_status,u.date_birth
- from sys_user u
- left join sys_dept d on u.dept_id = d.dept_id
- 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
- where u.del_flag = '0' and r.role_id = #{roleId}
- <if test="userName != null and userName != ''">
- AND u.user_name like concat('%', #{userName}, '%')
- </if>
- <if test="nickName != null and nickName != ''">
- AND u.nick_name like concat('%', #{nickName}, '%')
- </if>
- <if test="userType != null and userType != ''">
- AND u.user_type = #{userType}
- </if>
- <if test="phonenumber != null and phonenumber != ''">
- AND u.phonenumber like concat('%', #{phonenumber}, '%')
- </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="selectUnallocatedList" parameterType="com.zd.model.entity.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,
- u.card_num,u.wechat_id,u.education,u.nationality,u.addr,u.work_status
- from sys_user u
- left join sys_dept d on u.dept_id = d.dept_id
- 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
- where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
- and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and
- ur.role_id = #{roleId})
- <if test="userName != null and userName != ''">
- AND u.user_name like concat('%', #{userName}, '%')
- </if>
- <if test="nickName != null and nickName != ''">
- AND u.nick_name like concat('%', #{nickName}, '%')
- </if>
- <if test="userType != null and userType != ''">
- AND u.user_type = #{userType}
- </if>
- <if test="phonenumber != null and phonenumber != ''">
- AND u.phonenumber like concat('%', #{phonenumber}, '%')
- </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="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
- <include refid="selectUserNewVo"/>
- where (u.user_name = #{userName} or u.phonenumber=#{userName}) and u.del_flag = 0
- </select>
- <select id="selectUserCenterByUserName" parameterType="String" resultMap="SysUserResult">
- 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,u.user_type,
- d.dept_id, d.parent_id,
- CASE WHEN u.user_type='22' THEN d.dept_name ELSE concat(if((SELECT dt.dept_name FROM sys_dept dt WHERE dt.dept_id = d.parent_id) is null ,'',
- (SELECT concat(dt.dept_name,'-') FROM sys_dept dt WHERE dt.dept_id = d.parent_id)),d.dept_name) end dept_name,
- d.order_num, d.leader, d.status AS dept_status,
- CASE WHEN u.user_type='22' THEN sm.`major_name` else pt.`post_name` end major,
- u.grade,dd.`dict_label` category, u.tutor_user_id, u.position, u.nature, u.signature,
- u.card_num,u.wechat_id,
- case when u.user_type='22' then ed.`dict_label` else dd.`dict_label` end education,
- u.nationality,u.addr,u.work_status,u.date_birth,
- ut.nick_name tutorUserName,u.is_check,
- uf.face_img,sc.class_name,u.major_id,u.signature,pt.`post_name` positionName
- FROM sys_user u
- LEFT JOIN sys_dept d ON u.dept_id = d.dept_id
- LEFT JOIN sys_user ut ON ut.user_id = u.tutor_user_id
- LEFT JOIN lab_students_info uf ON u.user_id = uf.join_students_id
- LEFT JOIN sys_class sc ON sc.id = u.grade
- LEFT JOIN sys_major sm ON sm.id = u.major_id
- LEFT JOIN sys_post pt ON pt.`post_id` = u.`position`
- LEFT JOIN sys_dict_data dd ON dd.`dict_value` = u.category AND dd.`dict_type`='professional'
- LEFT JOIN sys_dict_data ed ON ed.`dict_value` = u.education AND ed.`dict_type`='education'
- where u.user_name = #{userName} and u.del_flag = 0
- </select>
- <select id="selectUserByNickName" parameterType="String" resultMap="SysUserResult">
- <include refid="selectUserNewVo"/>
- where u.nick_name = #{nickName}
- </select>
- <select id="selectUserByCardNum" parameterType="String" resultMap="SysUserResult">
- <include refid="selectUserNewVo"/>
- where u.card_num = #{cardNum} and u.del_flag = 0
- </select>
- <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
- <include refid="selectUserNewVo"/>
- where u.user_id = #{userId}
- </select>
- <select id="checkUserNameUnique" parameterType="String" resultType="int">
- select count(1) 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} limit 1
- </select>
- <select id="checkPhoneUniqueNotOwn" parameterType="com.zd.model.entity.SysUser" resultMap="SysUserResult">
- select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and user_name != #{userName} limit 1
- </select>
- <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
- select user_id, email from sys_user where email = #{email} limit 1
- </select>
- <select id="selectOption" resultType="java.util.Map">
- select user_id userId, nick_name nickName,user_name userName from sys_user
- <where>
- <if test="userType != null and userType != ''">
- AND user_type = #{userType}
- </if>
- <if test="nickName != null and nickName != ''">
- AND nick_name like concat('%', #{nickName}, '%')
- </if>
- </where>
- </select>
- <select id="noJoinPositionByList" parameterType="com.zd.model.entity.SysUser" resultMap="SysUserResult">
- select u.user_id, u.dept_id, u.nick_name, u.user_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,
- u.major, u.grade, u.category, u.tutor_user_id, u.position, u.nature,
- u.card_num,u.wechat_id,u.education,u.nationality,u.addr,u.work_status,u.date_birth,
- d.dept_name, d.leader,u.department,
- ut.nick_name tutorUserName,u.is_check
- from
- sys_user u
- left join sys_dept d on u.dept_id = d.dept_id
- left join sys_user ut on ut.user_id = u.tutor_user_id
- where u.del_flag = '0' AND (u.position = '未定' or u.position is null)
- <if test="userId != null ">
- AND u.user_id = #{userId}
- </if>
- <if test="userName != null and userName != ''">
- AND u.user_name like concat('%', #{userName}, '%')
- </if>
- <if test="nickName != null and nickName != ''">
- AND u.nick_name like concat('%', #{nickName}, '%')
- </if>
- <if test="cardNum != null and cardNum != ''">
- AND u.card_num = #{cardNum}
- </if>
- <if test="userType != null and userType != ''">
- AND u.user_type = #{userType}
- </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>
- <if test="ids!=null and ids.size > 0">
- AND u.user_id IN
- <foreach item="item" collection="ids" separator="," open="(" close=")" index="">'${item}'</foreach>
- </if>
- <if test="major != null and major != ''">
- AND u.major like concat('%', #{major}, '%')
- </if>
- <if test="grade != null and grade != ''">
- AND u.grade like concat('%', #{grade}, '%')
- </if>
- <if test="category != null and category != ''">
- AND u.category like concat('%', #{category}, '%')
- </if>
- <if test="tutorUserId != null">
- AND u.tutor_user_id = #{tutorUserId}
- </if>
- <if test="nature != null and nature != ''">
- AND u.nature = #{nature}
- </if>
- <if test="isCheck != null">
- AND u.is_check = #{isCheck}
- </if>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- </select>
- <insert id="insertUser" parameterType="com.zd.model.entity.SysUser" useGeneratedKeys="true"
- keyProperty="userId">
- insert into sys_user(
- <if test="userId != null and userId != 0">user_id,</if>
- <if test="deptId != null and deptId != 0">dept_id,</if>
- <if test="userName != null and userName != ''">user_name,</if>
- <if test="nickName != null and nickName != ''">nick_name,</if>
- <if test="email != null and email != ''">email,</if>
- <if test="avatar != null and avatar != ''">avatar,</if>
- <if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
- <if test="sex != null and sex != ''">sex,</if>
- <if test="password != null and password != ''">password,</if>
- <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="userType != null and userType != ''">user_type,</if>
- <if test="major != null and major != ''">major,</if>
- <if test="grade != null and grade != ''">grade,</if>
- <if test="category != null and category != ''">category,</if>
- <if test="tutorUserId != null and tutorUserId != '' ">tutor_user_id,</if>
- <if test="majorId != null and majorId != ''">major_id,</if>
- <if test="position != null and position != ''">position,</if>
- <if test="department != null and department != ''">department,</if>
- <if test="nature != null and nature != ''">nature,</if>
- <if test="cardNum != null and cardNum != ''">card_num,</if>
- <if test="education != null and education != ''">education,</if>
- <if test="nationality != null and nationality != ''">nationality,</if>
- <if test="addr != null and addr != ''">addr,</if>
- <if test="workStatus != null and workStatus != ''">work_status,</if>
- <if test="dateBirth != null">date_birth,</if>
- <if test="isCheck != null and isCheck != ''">is_check,</if>
- create_time
- )values(
- <if test="userId != null and userId != ''">#{userId},</if>
- <if test="deptId != null and deptId != ''">#{deptId},</if>
- <if test="userName != null and userName != ''">#{userName},</if>
- <if test="nickName != null and nickName != ''">#{nickName},</if>
- <if test="email != null and email != ''">#{email},</if>
- <if test="avatar != null and avatar != ''">#{avatar},</if>
- <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
- <if test="sex != null and sex != ''">#{sex},</if>
- <if test="password != null and password != ''">#{password},</if>
- <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="userType != null and userType != ''">#{userType},</if>
- <if test="major != null and major != ''">#{major},</if>
- <if test="grade != null and grade != ''">#{grade},</if>
- <if test="category != null and category != ''">#{category},</if>
- <if test="tutorUserId != null and tutorUserId != ''">#{tutorUserId},</if>
- <if test="majorId != null and majorId != ''">#{majorId},</if>
- <if test="position != null and position != '' ">#{position},</if>
- <if test="department != null and department != ''">#{department},</if>
- <if test="nature != null and nature != ''">#{nature},</if>
- <if test="cardNum != null and cardNum != ''">#{cardNum},</if>
- <if test="education != null and education != ''">#{education},</if>
- <if test="nationality != null and nationality != ''">#{nationality},</if>
- <if test="addr != null and addr != ''">#{addr},</if>
- <if test="workStatus != null and workStatus != ''">#{workStatus},</if>
- <if test="dateBirth != null">#{dateBirth},</if>
- <if test="isCheck != null and isCheck != ''">#{isCheck},</if>
- sysdate()
- )
- </insert>
- <update id="updateUser" parameterType="com.zd.model.entity.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 and remark != ''">remark = #{remark},</if>
- <if test="userType != null ">user_type = #{userType},</if>
- <if test="major != null and major != ''">major = #{major},</if>
- <if test="majorId != null">major_id = #{majorId},</if>
- <if test="grade != null and grade!=''">grade = #{grade},</if>
- <if test="category != null and category !=''">category = #{category},</if>
- <if test="tutorUserId != null ">tutor_user_id = #{tutorUserId},</if>
- <if test="position != null ">position = #{position},</if>
- <if test="department != null ">department = #{department},</if>
- <if test="nature != null and nature!=''">nature = #{nature},</if>
- <if test="cardNum != null ">card_num = #{cardNum},</if>
- <if test="education != null and education!=''">education = #{education},</if>
- <if test="nationality != null and nationality!=''">nationality = #{nationality},</if>
- <if test="addr != null and addr != ''">addr = #{addr},</if>
- <if test="workStatus != null and workStatus != ''">work_status = #{workStatus},</if>
- <if test="dateBirth != null">date_birth = #{dateBirth},</if>
- <if test="isCheck != null ">is_check = #{isCheck},</if>
- <if test="signature != null and signature != ''">signature = #{signature},</if>
- update_time = sysdate()
- </set>
- where user_id = #{userId}
- </update>
- <update id="updateTeacherUser" parameterType="com.zd.model.entity.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 and remark != ''">remark = #{remark},</if>
- <if test="userType != null ">user_type = #{userType},</if>
- <if test="major != null and major != ''">major = #{major},</if>
- <if test="majorId != null">major_id = #{majorId},</if>
- <if test="grade != null and grade!=''">grade = #{grade},</if>
- <if test="category != null and category !=''">category = #{category},</if>
- <if test="tutorUserId != null ">tutor_user_id = #{tutorUserId},</if>
- <if test="position != null ">position = #{position},</if>
- <if test="department != null ">department = #{department},</if>
- <if test="nature != null and nature!=''">nature = #{nature},</if>
- card_num = #{cardNum},
- <if test="education != null and education!=''">education = #{education},</if>
- <if test="nationality != null and nationality!=''">nationality = #{nationality},</if>
- <if test="addr != null and addr != ''">addr = #{addr},</if>
- <if test="workStatus != null and workStatus != ''">work_status = #{workStatus},</if>
- <if test="dateBirth != null">date_birth = #{dateBirth},</if>
- <if test="isCheck != null ">is_check = #{isCheck},</if>
- <if test="signature != null and signature != ''">signature = #{signature},</if>
- update_time = sysdate()
- </set>
- where user_id = #{userId}
- </update>
- <update id="updateStudentUser" parameterType="com.zd.model.entity.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 and remark != ''">remark = #{remark},</if>
- <if test="userType != null ">user_type = #{userType},</if>
- <if test="major != null and major != ''">major = #{major},</if>
- <if test="majorId != null">major_id = #{majorId},</if>
- <if test="grade != null and grade!=''">grade = #{grade},</if>
- <if test="category != null and category !=''">category = #{category},</if>
- <if test="tutorUserId != null ">tutor_user_id = #{tutorUserId},</if>
- <if test="position != null ">position = #{position},</if>
- <if test="department != null ">department = #{department},</if>
- <if test="nature != null and nature!=''">nature = #{nature},</if>
- card_num = #{cardNum},
- <if test="education != null and education!=''">education = #{education},</if>
- <if test="nationality != null and nationality!=''">nationality = #{nationality},</if>
- <if test="addr != null and addr != ''">addr = #{addr},</if>
- <if test="workStatus != null and workStatus != ''">work_status = #{workStatus},</if>
- <if test="dateBirth != null">date_birth = #{dateBirth},</if>
- <if test="isCheck != null ">is_check = #{isCheck},</if>
- <if test="signature != null and signature != ''">signature = #{signature},</if>
- update_time = sysdate()
- </set>
- where user_id = #{userId}
- </update>
- <update id="relieveUserByPosition" parameterType="com.zd.model.entity.SysUser">
- update sys_user
- set position = '未定'
- where user_id = #{userId}
- </update>
- <update id="updateUserAvatar" parameterType="com.zd.model.entity.SysUser">
- update sys_user set avatar = #{avatar} where user_name = #{userName}
- </update>
- <update id="resetUserPwd" parameterType="com.zd.model.entity.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>
- </delete>
- <select id="queryPhoneByIds" resultType="string">
- select phonenumber from sys_user
- where user_id in
- <foreach collection="array" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- and length(phonenumber)=11
- </select>
- <select id="queryCountByDeptIds" resultType="com.zd.model.entity.TotalByID">
- select dept_id as id, count(dept_id ) as total from sys_user
- where dept_id in
- <foreach collection="array" item="deptId" open="(" separator="," close=")">
- #{deptId}
- </foreach>
- group by dept_id
- </select>
- <select id="selectUserListByName" parameterType="com.zd.model.entity.SysUser" resultMap="SysUserResult">
- select u.user_id, u.dept_id, u.nick_name, u.user_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,
- u.major, u.grade, u.category, u.tutor_user_id, u.position, u.nature,
- u.card_num,u.wechat_id,u.education,u.nationality,u.addr,u.work_status,u.date_birth,
- d.dept_name, d.leader,u.department,u.is_check
- 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 u.user_id = #{userId}
- </if>
- <if test="userName != null and userName != ''">
- AND u.user_name like concat('%', #{userName}, '%')
- </if>
- <if test="nickName != null and nickName != ''">
- AND u.nick_name like concat('%', #{nickName}, '%')
- </if>
- <if test="userType != null and userType != ''">
- AND u.user_type = #{userType}
- </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="ids!=null and ids.size > 0">
- AND u.user_id IN
- <foreach item="item" collection="ids" separator="," open="(" close=")" index="">'${item}'</foreach>
- </if>
- <if test="major != null and major != ''">
- AND u.major like concat('%', #{major}, '%')
- </if>
- <if test="grade != null and grade != ''">
- AND u.grade like concat('%', #{grade}, '%')
- </if>
- <if test="category != null and category != ''">
- AND u.category like concat('%', #{category}, '%')
- </if>
- <if test="tutorUserId != null">
- AND u.tutor_user_id = #{tutorUserId}
- </if>
- <if test="nature != null and nature != ''">
- AND u.nature = #{nature}
- </if>
- <if test="position != null and position != ''">
- AND u.position = #{position}
- </if>
- <if test="isCheck != null">
- AND u.is_check = #{isCheck}
- </if>
- </select>
- <select id="selectUserListByNotWhite" parameterType="com.zd.model.entity.SysUser" resultMap="SysUserResult">
- select u.user_id, u.dept_id, u.nick_name, u.user_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,
- u.major, u.grade, u.category, u.tutor_user_id, u.position, u.nature,
- u.card_num,u.wechat_id,u.education,u.nationality,u.addr,u.work_status,u.date_birth,
- d.dept_name, d.leader,u.department,u.is_check
- from
- sys_user u
- left join sys_dept d on u.dept_id = d.dept_id
- where u.del_flag = '0'
- and u.`user_id` not in (select w.`user_id` from lab_whitelist w)
- <if test="userId != null ">
- AND u.user_id = #{userId}
- </if>
- <if test="userName != null and userName != ''">
- AND u.user_name like concat('%', #{userName}, '%')
- </if>
- <if test="nickName != null and nickName != ''">
- AND u.nick_name like concat('%', #{nickName}, '%')
- </if>
- <if test="userType != null and userType != ''">
- AND u.user_type = #{userType}
- </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="ids!=null and ids.size > 0">
- AND u.user_id IN
- <foreach item="item" collection="ids" separator="," open="(" close=")" index="">'${item}'</foreach>
- </if>
- <if test="deptIds !=null and deptIds.size >0" >
- AND u.dept_id IN
- <foreach item="item" collection="deptIds" separator="," open="(" close=")" index="">'${item}'</foreach>
- </if>
- <if test="major != null and major != ''">
- AND u.major like concat('%', #{major}, '%')
- </if>
- <if test="grade != null and grade != ''">
- AND u.grade like concat('%', #{grade}, '%')
- </if>
- <if test="category != null and category != ''">
- AND u.category like concat('%', #{category}, '%')
- </if>
- <if test="tutorUserId != null">
- AND u.tutor_user_id = #{tutorUserId}
- </if>
- <if test="nature != null and nature != ''">
- AND u.nature = #{nature}
- </if>
- <if test="position != null and position != ''">
- AND u.position = #{position}
- </if>
- <if test="isCheck != null">
- AND u.is_check = #{isCheck}
- </if>
- </select>
- <select id="selectUserInfoByCardNum" resultType="com.zd.model.entity.SysUser">
- SELECT user_id,nick_name,card_num FROM sys_user u WHERE u.card_num = #{cardNum}
- </select>
- <select id="getSafeUserList" parameterType="com.zd.model.entity.SysUser" resultMap="SysUserResult">
- select u.user_id, u.nick_name
- from
- sys_user u
- where u.del_flag = '0'
- <if test="safeUserId != null">
- AND FIND_IN_SET(u.user_id, #{safeUserId})
- </if>
- </select>
- </mapper>
|