<?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="cn.stylefeng.roses.kernel.system.modular.user.mapper.SysUserMapper">
|
|
<!--用户列表sql-->
|
<sql id="user_list_mysql">
|
select
|
suser.user_id as userId,
|
suser.account as account,
|
suser.nick_name as nickName,
|
suser.real_name as realName,
|
suser.avatar as avatar,
|
suser.birthday as birthday,
|
suser.sex as sex,
|
suser.email as email,
|
suser.phone as phone,
|
suser.tel as tel,
|
suser.status_flag as statusFlag,
|
suorg.org_id as orgId,
|
suorg.position_id as positionId,
|
hpos.position_name as positionName,
|
hrorg.org_name as orgName,
|
suser.customer_ids as customerIds,
|
suser.ware_house_ids AS wareHouseIds,
|
suser.remark AS remark,
|
suser.wx_open_id AS wxOpenId
|
from sys_user suser
|
left join sys_user_org suorg on suser.user_id = suorg.user_id
|
left join hr_position hpos on suorg.position_id = hpos.position_id
|
left join hr_organization hrorg on suorg.org_id = hrorg.org_id
|
<where>
|
<if test="sysUserRequest.nickName != null and sysUserRequest.nickName != ''">
|
and suser.nick_name like concat('%',#{sysUserRequest.nickName},'%')
|
</if>
|
<if test="sysUserRequest.realName != null and sysUserRequest.realName != ''">
|
and suser.real_name like concat('%',#{sysUserRequest.realName},'%')
|
</if>
|
<if test="sysUserRequest.account != null and sysUserRequest.account != ''">
|
and suser.account like concat('%',#{sysUserRequest.account},'%')
|
</if>
|
<if test="sysUserRequest.statusFlag != null and sysUserRequest.statusFlag != ''">
|
and suser.status_flag like concat('%',#{sysUserRequest.statusFlag},'%')
|
</if>
|
<if test="sysUserRequest.orgId != null and sysUserRequest.orgId != ''">
|
and suorg.org_id in (select org_id from hr_organization where org_pids like CONCAT('%$[',#{sysUserRequest.orgId},'$]%') escape '$' or org_id=#{sysUserRequest.orgId} )
|
</if>
|
<if test="sysUserRequest.scopeOrgIds != null and sysUserRequest.scopeOrgIds.size() > 0">
|
and suorg.org_id in
|
<foreach item="item" collection="sysUserRequest.scopeOrgIds" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="sysUserRequest.userScopeIds != null and sysUserRequest.userScopeIds.size() > 0">
|
and suser.user_id in
|
<foreach item="item" collection="sysUserRequest.userScopeIds" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="sysUserRequest.customerList != null and sysUserRequest.customerList.size() > 0">
|
and
|
<foreach item="item" collection="sysUserRequest.customerList" index="index" open="(" separator="or" close=")">
|
FIND_IN_SET(#{item},suser.customer_ids)
|
</foreach>
|
</if>
|
<if test="sysUserRequest.wareHouseList != null and sysUserRequest.wareHouseList.size() > 0">
|
and
|
<foreach item="item" collection="sysUserRequest.wareHouseList" index="index" open="(" separator="or" close=")">
|
FIND_IN_SET( #{item},suser.ware_house_ids)
|
</foreach>
|
</if>
|
and suser.del_flag = 'N'
|
order by suser.create_time desc
|
</where>
|
</sql>
|
|
<!--用户列表 oracle版本-->
|
<sql id="user_list_oracle">
|
select
|
suser.user_id as userId,
|
suser.account as account,
|
suser.nick_name as nickName,
|
suser.real_name as realName,
|
suser.avatar as avatar,
|
suser.birthday as birthday,
|
suser.sex as sex,
|
suser.email as email,
|
suser.phone as phone,
|
suser.tel as tel,
|
suser.status_flag as statusFlag,
|
suorg.org_id as orgId,
|
suorg.position_id as positionId,
|
hpos.position_name as positionName,
|
hrorg.org_name as orgName,
|
suser.customer_ids as customerIds,
|
suser.ware_house_ids AS wareHouseIds
|
from sys_user suser
|
left join sys_user_org suorg on suser.user_id = suorg.user_id
|
left join hr_position hpos on suorg.position_id = hpos.position_id
|
left join hr_organization hrorg on suorg.org_id = hrorg.org_id
|
<where>
|
<if test="sysUserRequest.nickName != null and sysUserRequest.nickName != ''">
|
and suser.nick_name like '%' || #{sysUserRequest.nickName} || '%'
|
</if>
|
<if test="sysUserRequest.realName != null and sysUserRequest.realName != ''">
|
and suser.real_name like '%' || #{sysUserRequest.realName} || '%'
|
</if>
|
<if test="sysUserRequest.account != null and sysUserRequest.account != ''">
|
and suser.account like '%' || #{sysUserRequest.account} || '%'
|
</if>
|
<if test="sysUserRequest.statusFlag != null and sysUserRequest.statusFlag != ''">
|
and suser.status_flag like '%' || #{sysUserRequest.statusFlag} || '%'
|
</if>
|
<if test="sysUserRequest.orgId != null and sysUserRequest.orgId != ''">
|
and suorg.org_id in(select org_id from hr_organization where org_pids like '%' || #{sysUserRequest.orgId} || '%' or org_id = #{sysUserRequest.orgId})
|
</if>
|
and suser.del_flag = 'N'
|
order by suser.create_time desc
|
</where>
|
</sql>
|
|
|
<!--获取用户分页列表-->
|
<select id="findUserPage" resultType="cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO">
|
<include refid="user_list_mysql"></include>
|
</select>
|
|
<sql id="select_user_org_customer">
|
SELECT
|
suser.user_id AS userId,
|
suser.account AS account,
|
suser.nick_name AS nickName,
|
suser.real_name AS realName,
|
suser.avatar AS avatar,
|
suser.birthday AS birthday,
|
suser.sex AS sex,
|
suser.email AS email,
|
suser.phone AS phone,
|
suser.tel AS tel,
|
suser.status_flag AS statusFlag,
|
suorg.org_id AS orgId,
|
hrorg.org_name AS orgName,
|
cu.worker_no,
|
cu.work_status,
|
cu.post_types,
|
cu.post_ids
|
FROM
|
sys_user suser
|
LEFT JOIN sys_user_org suorg ON suser.user_id = suorg.user_id
|
LEFT JOIN hr_organization hrorg ON suorg.org_id = hrorg.org_id
|
LEFT JOIN toc_customer cu ON cu.sys_user_id = suser.user_id
|
</sql>
|
<select id="getWorkerPage" resultType="cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO">
|
<include refid="select_user_org_customer" />
|
<where>
|
cu.user_type = 1 AND suser.del_flag = 'N'
|
<if test="req.nickName != null and req.nickName != ''">
|
and suser.nick_name LIKE CONCAT('%', #{req.nickName}, '%')
|
</if>
|
<if test="req.realName != null and req.realName != ''">
|
and suser.real_name LIKE CONCAT('%', #{req.realName}, '%')
|
</if>
|
<if test="req.phone != null and req.phone != ''">
|
and suser.phone LIKE CONCAT('%', #{req.phone}, '%')
|
</if>
|
<if test="req.statusFlag != null and req.statusFlag != ''">
|
and suser.status_flag = #{req.statusFlag}
|
</if>
|
<if test="req.orgId != null and req.orgId != ''">
|
and suorg.org_id in(select org_id from hr_organization where org_pids LIKE CONCAT('%', #{req.orgId}, '%') or org_id = #{req.orgId})
|
</if>
|
<if test="req.postType != null and req.postType != -1">
|
AND FIND_IN_SET ( #{req.postType}, cu.post_types )
|
</if>
|
<if test="req.postId != null and req.postId != -1">
|
AND FIND_IN_SET ( #{req.postId}, cu.post_ids )
|
</if>
|
ORDER BY suser.create_time DESC
|
</where>
|
</select>
|
<select id="getWorkerDetail" resultType="cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO">
|
<include refid="select_user_org_customer" />
|
<where>
|
<if test="userId != null">
|
AND suser.user_id = #{userId}
|
</if>
|
</where>
|
</select>
|
|
<!--获取用户列表-->
|
<select id="findUserList" resultType="cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO">
|
<include refid="user_list_mysql"></include>
|
</select>
|
|
</mapper>
|