水利项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

368 lines
15 KiB

2 years ago
<?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.kms.system.mapper.SysUserMapper">
<resultMap type="com.shuili.common.core.domain.entity.SysUser" id="sysUserResult">
<id property="id" column="id" />
<result property="deptId" column="dept_id" />
<result property="isPcUser" column="is_pc_user" />
<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="createUid" column="create_uid" />
<result property="createTime" column="create_time" />
<result property="updateUid" column="update_uid" />
<result property="updateTime" column="update_time" />
<result property="note" column="note" />
2 years ago
<result property="realName" column="real_name" />
<result property="cardNo" column="card_no" />
<result property="department" column="department" />
<result property="post" column="post" />
<result property="isFirst" column="is_first" />
<result property="invitee" column="invitee" />
<result property="professional" column="professional" />
<association property="dept" column="dept_id" javaType="com.shuili.common.core.domain.entity.SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap>
<resultMap id="deptResult" type="com.shuili.common.core.domain.entity.SysDept">
<id property="id" column="did" />
<result property="parentId" column="dparent_id" />
<result property="deptName" column="ddept_name" />
<result property="orderNum" column="dorder_num" />
<result property="leader" column="dleader" />
<result property="status" column="ddept_status" />
<result property="tag" column="dtag" />
<result property="isDownload" column="is_download" />
<result property="isComment" column="is_comment" />
<result property="ipStart" column="ip_start" />
<result property="ipEnd" column="ip_end" />
<result property="pcLogo" column="pc_logo" />
<result property="pcBackground" column="pc_background" />
<result property="adminLogo" column="admin_logo" />
1 month ago
<result property="xzqhId" column="xzqh_id"/>
2 years ago
</resultMap>
<resultMap id="RoleResult" type="com.shuili.common.core.domain.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>
<sql id="selectUserVo">
select u.is_pc_user,u.invitee,u.is_first,u.id,u.password, 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_uid, u.create_time, u.note,
2 years ago
u.real_name,u.card_no,u.department,u.post,u.professional,
1 month ago
d.id,d.xzqh_id,d.parent_id,d.tag as dtag, d.dept_name as ddept_name, d.order_num as dorder_num, d.leader as dleader, d.status as dept_status, d.pc_logo, d.pc_background, d.admin_logo,
2 years ago
r.id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
from sys_user u
left join sys_dept d on u.dept_id = d.id
left join sys_user_role ur on u.id = ur.user_id
left join sys_role r on r.id = ur.role_id
</sql>
<select id="selectUserList" parameterType="com.shuili.common.core.domain.entity.SysUser" resultMap="sysUserResult">
select u.id,u.is_pc_user,u.invitee,u.is_first, 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_uid, u.create_time, u.note,
2 years ago
d.dept_name as ddept_name,d.tag as dtag, d.id as did,d.parent_id as dparent_id,
u.real_name,u.card_no,u.department,u.post,u.professional,d.leader,d.is_download,d.is_comment,
d.ip_start,d.ip_end, d.pc_logo, d.pc_background, d.admin_logo
from sys_user u
left join sys_dept d on u.dept_id = d.id
where u.del_flag = '0'
<if test="userName != null and userName != ''">
AND u.user_name = #{userName}
</if>
<if test="nickName != null and nickName != ''">
AND u.nick_name like concat('%', #{nickName}, '%')
</if>
<if test="isPcUser != null and isPcUser != ''">
AND u.is_pc_user = #{isPcUser}
</if>
<!-- <if test="deptStatus != null and deptStatus != ''">
AND u.dept_status = #{deptStatus}
</if> -->
<if test="status != null and status != ''">
AND u.status = #{status}
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber= #{phonenumber}
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
<if test="deptId != null and deptId != ''">
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.id FROM sys_dept t WHERE FIND_IN_SET (#{deptId},ancestors) ))
</if>
<if test="ids != null and ids.size>0 ">
AND u.id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectUserByUserName" parameterType="String" resultMap="sysUserResult">
<include refid="selectUserVo"/>
where (u.user_name = #{userName} OR u.phonenumber = #{userName})
</select>
<select id="loginUser" parameterType="com.shuili.common.core.domain.model.LoginBody" resultMap="sysUserResult">
<include refid="selectUserVo"/>
where
(u.user_name = #{username} OR u.phonenumber = #{username} OR u.email = #{username})
AND u.is_pc_user = #{isPcLogin}
</select>
<select id="checkUser" parameterType="com.shuili.common.core.domain.model.LoginBody" resultMap="sysUserResult">
SELECT
u.*
FROM
sys_user u
WHERE
u.is_pc_user = #{isPcUser}
<if test="userName != null or email != null or phonenumber !=null or cardNo!=null ">
AND
<trim prefixOverrides="OR" prefix = "(" suffix=")">
<if test="userName != null and userName != ''" >
OR u.user_name = #{userName}
</if>
<if test="email != null and email != ''">
OR u.email = #{email}
</if>
<if test="phonenumber != null and phonenumber != ''">
OR u.phonenumber = #{phonenumber}
</if>
<if test="cardNo != null and cardNo != ''">
OR u.card_no = #{cardNo}
</if>
</trim>
</if>
<if test="id != null and id != '' ">
AND id !=#{id}
</if>
</select>
<select id="selectUserById" parameterType="String" resultMap="sysUserResult">
<include refid="selectUserVo"/>
where u.id = #{id}
</select>
<select id="checkUserNameUnique" parameterType="com.shuili.common.core.domain.entity.SysUser" resultType="int">
select count(1) from sys_user
where user_name = #{userName}
AND is_pc_user = #{isPcUser} limit 1
</select>
<select id="checkPhoneUnique" parameterType="com.shuili.common.core.domain.entity.SysUser" resultMap="sysUserResult">
select id, phonenumber from sys_user
where phonenumber = #{phonenumber}
AND is_pc_user = #{isPcUser} limit 1
</select>
<select id="checkEmailUnique" parameterType="com.shuili.common.core.domain.entity.SysUser" resultMap="sysUserResult">
select id, email from sys_user
where email = #{email}
AND is_pc_user = #{isPcUser}
limit 1
</select>
<insert id="insertUser" parameterType="com.shuili.common.core.domain.entity.SysUser" useGeneratedKeys="true" keyProperty="id">
insert into sys_user(
<if test="id != null and id != ''">id,</if>
<if test="isPcUser != null and isPcUser != ''">is_pc_user,</if>
<if test="invitee != null and invitee != ''">invitee,</if>
<if test="deptId != null and deptId != ''">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="loginIp != null and loginIp != ''">login_ip,</if>
<if test="loginDate != null">login_date,</if>
<if test="createUid != null and createUid != ''">create_uid,</if>
<if test="updateUid != null and updateUid != ''">update_uid,</if>
<if test="note != null and note != ''">note,</if>
2 years ago
<if test="realName != null">real_name,</if>
<if test="cardNo != null">card_no,</if>
<if test="department != null">department,</if>
<if test="post != null">post,</if>
<if test="professional != null">professional,</if>
<if test="isFirst != null">is_first,</if>
create_time
)values(
<if test="id != null and id != ''">#{id},</if>
<if test="isPcUser != null and isPcUser != ''">#{isPcUser},</if>
<if test="invitee != null and invitee != ''">#{invitee},</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="createUid != null and createUid != ''">#{createUid},</if>
<if test="loginIp != null and loginIp != ''">#{loginIp},</if>
<if test="loginDate != null">#{loginDate},</if>
<if test="updateUid != null and updateUid != ''">#{updateUid},</if>
<if test="note != null and note != ''">#{note},</if>
2 years ago
<if test="realName != null">
#{realName},
</if>
<if test="cardNo != null">
#{cardNo},
</if>
<if test="department != null">
#{department},
</if>
<if test="post != null">
#{post},
</if>
<if test="professional != null">
#{professional},
</if>
<if test="isFirst != null"> #{isFirst}, </if>
sysdate()
)
</insert>
<update id="updateUser" parameterType="com.shuili.common.core.domain.entity.SysUser">
update sys_user
<set>
<if test="deptId != null and deptId != ''">dept_id = #{deptId},</if>
<if test="invitee != null and invitee != ''">invitee = #{invitee},</if>
<if test="isPcUser != null and isPcUser != ''">is_pc_user = #{isPcUser},</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 and email != ''">email = #{email},</if>
<if test="phonenumber != null and phonenumber != ''">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="updateUid != null and updateUid != ''">update_uid = #{updateUid},</if>
<if test="note != null">note = #{note},</if>
2 years ago
<if test="isFirst != null">is_first = #{isFirst},</if>
<if test="realName != null">
real_name = #{realName},</if>
<if test="cardNo != null">
card_no =#{cardNo},
</if>
<if test="department != null">
department =#{department},
</if>
<if test="post != null">
post =#{post},
</if>
<if test="professional != null">
professional =#{professional},
</if>
update_time = sysdate()
</set>
where id = #{id}
</update>
<update id="updateUserStatus" parameterType="com.shuili.common.core.domain.entity.SysUser">
update sys_user set status = #{status} where id = #{id}
</update>
<update id="updateUserAvatar" parameterType="com.shuili.common.core.domain.entity.SysUser">
update sys_user set avatar = #{avatar} where user_name = #{userName}
</update>
<update id="resetUserPwd" parameterType="com.shuili.common.core.domain.entity.SysUser">
update sys_user set password = #{password}
<where>
<if test="userName != null">
AND user_name = #{userName},
</if>
<if test="phonenumber != null">
AND phonenumber= #{phonenumber},
</if>
<if test="userName != null">
AND email= #{email},
</if>
</where>
</update>
<update id="resetPwd" parameterType="com.shuili.common.core.domain.entity.SysUser">
update sys_user set password = #{password}
<where>
<if test="userName != null">
AND user_name = #{userName}
</if>
<if test="phonenumber != null">
AND phonenumber= #{phonenumber}
</if>
<if test="userName != null">
AND email= #{email}
</if>
<if test="id != null">
AND id= #{id}
</if>
</where>
</update>
<delete id="deleteUserById" parameterType="String">
delete from sys_user where id = #{id}
</delete>
<delete id="deleteUserByIds" parameterType="String">
delete from sys_user where id in
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 导入时候专用,勿修改 -->
<select id="findList" parameterType="com.shuili.common.core.domain.entity.SysUser" resultMap="sysUserResult">
select u.*
from sys_user u
<where>
<if test="userName != null and userName != ''">
AND u.user_name = #{userName}
</if>
<if test="isPcUser != null and isPcUser != ''">
AND u.is_pc_user = #{isPcUser}
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber= #{phonenumber}
</if>
<if test="email != null and email != ''">
AND u.email= #{email}
</if>
<if test="cardNo != null and cardNo != ''">
AND u.card_no= #{cardNo}
</if>
</where>
</select>
<!-- 查询笔记协作者 -->
<select id="getCooperationList" resultType="java.lang.String">
SELECT u.user_name AS `userName` FROM sys_user u LEFT JOIN cms_note_book_cooperation c ON u.id = c.user_id
WHERE c.note_book_id = #{noteBookId}
</select>
</mapper>