136 lines
6.2 KiB
XML
136 lines
6.2 KiB
XML
<?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="org.dromara.cw.mapper.CwProjectAuditorMapper">
|
|
|
|
<resultMap type="org.dromara.cw.domain.vo.CwProjectAuditorVo" id="CwProjectAuditorResult">
|
|
<result property="id" column="id" />
|
|
<result property="userId" column="user_id" />
|
|
<result property="userName" column="user_name" />
|
|
<result property="nickName" column="nick_name" />
|
|
<result property="deptId" column="dept_id" />
|
|
<result property="deptName" column="dept_name" />
|
|
<result property="phoneNumber" column="phone_number" />
|
|
<result property="email" column="email" />
|
|
<result property="status" column="status" />
|
|
<result property="remark" column="remark" />
|
|
<result property="configBy" column="config_by" />
|
|
<result property="configByName" column="config_by_name" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
</resultMap>
|
|
|
|
<sql id="selectCwProjectAuditorVo">
|
|
select
|
|
a.id, a.user_id, a.user_name, a.nick_name, a.dept_id, a.dept_name,
|
|
a.phone_number, a.email, a.status, a.remark, a.config_by, a.config_by_name,
|
|
a.create_by, a.create_time, a.update_by, a.update_time,
|
|
u.user_name as sys_user_name,
|
|
d.dept_name as sys_dept_name
|
|
from cw_project_auditor a
|
|
left join sys_user u on a.user_id = u.user_id
|
|
left join sys_dept d on a.dept_id = d.dept_id
|
|
</sql>
|
|
|
|
<select id="selectAuditorList" parameterType="org.dromara.cw.domain.CwProjectAuditor" resultMap="CwProjectAuditorResult">
|
|
<include refid="selectCwProjectAuditorVo"/>
|
|
<where>
|
|
a.deleted = 0
|
|
<if test="userId != null"> and a.user_id = #{userId}</if>
|
|
<if test="userName != null and userName != ''"> and a.user_name like concat('%', #{userName}, '%')</if>
|
|
<if test="nickName != null and nickName != ''"> and a.nick_name like concat('%', #{nickName}, '%')</if>
|
|
<if test="deptId != null"> and a.dept_id = #{deptId}</if>
|
|
<if test="deptName != null and deptName != ''"> and a.dept_name like concat('%', #{deptName}, '%')</if>
|
|
<if test="status != null and status != ''"> and a.status = #{status}</if>
|
|
<if test="configBy != null"> and a.config_by = #{configBy}</if>
|
|
<if test="configByName != null and configByName != ''"> and a.config_by_name like concat('%', #{configByName}, '%')</if>
|
|
<if test="params.beginCreateTime != null and params.beginCreateTime != ''"> and a.create_time >= #{params.beginCreateTime}</if>
|
|
<if test="params.endCreateTime != null and params.endCreateTime != ''"> and a.create_time <= #{params.endCreateTime}</if>
|
|
</where>
|
|
order by a.create_time desc
|
|
</select>
|
|
|
|
<select id="selectAuditorsByDeptId" resultMap="CwProjectAuditorResult">
|
|
<include refid="selectCwProjectAuditorVo"/>
|
|
where a.dept_id = #{deptId} and a.status = '1' and a.deleted = 0
|
|
order by a.create_time desc
|
|
</select>
|
|
|
|
<select id="selectAvailableAuditors" resultMap="CwProjectAuditorResult">
|
|
<include refid="selectCwProjectAuditorVo"/>
|
|
where a.status = '1' and a.deleted = 0
|
|
order by a.dept_id, a.create_time desc
|
|
</select>
|
|
|
|
<select id="selectMyConfigAuditors" resultMap="CwProjectAuditorResult">
|
|
<include refid="selectCwProjectAuditorVo"/>
|
|
where a.config_by = #{configBy} and a.deleted = 0
|
|
order by a.create_time desc
|
|
</select>
|
|
|
|
<select id="selectAuditorsByUserIds" resultMap="CwProjectAuditorResult">
|
|
<include refid="selectCwProjectAuditorVo"/>
|
|
where a.user_id in
|
|
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
|
|
#{userId}
|
|
</foreach>
|
|
and a.status = '1' and a.deleted = 0
|
|
order by a.create_time desc
|
|
</select>
|
|
|
|
<select id="selectAuditorStatistics" resultType="map">
|
|
select
|
|
d.dept_name,
|
|
count(*) as total_count,
|
|
count(case when a.status = '1' then 1 end) as active_count,
|
|
count(case when a.status = '0' then 1 end) as inactive_count
|
|
from cw_project_auditor a
|
|
left join sys_dept d on a.dept_id = d.dept_id
|
|
where a.deleted = 0
|
|
<if test="deptId != null"> and a.dept_id = #{deptId}</if>
|
|
<if test="status != null and status != ''"> and a.status = #{status}</if>
|
|
group by a.dept_id, d.dept_name
|
|
order by total_count desc
|
|
</select>
|
|
|
|
<select id="selectByUserId" resultMap="CwProjectAuditorResult">
|
|
<include refid="selectCwProjectAuditorVo"/>
|
|
where a.user_id = #{userId} and a.deleted = 0
|
|
</select>
|
|
|
|
<update id="batchUpdateStatus">
|
|
update cw_project_auditor
|
|
set status = #{status}, update_by = #{updateBy}, update_time = now()
|
|
where id in
|
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
and deleted = 0
|
|
</update>
|
|
|
|
<!-- 查询完整的用户信息(包含部门信息)用于批量添加 -->
|
|
<select id="selectUsersWithDeptInfo" resultType="org.dromara.cw.domain.UserWithDeptInfo">
|
|
select
|
|
u.user_id as userId,
|
|
u.user_name as userName,
|
|
u.nick_name as nickName,
|
|
u.dept_id as deptId,
|
|
d.dept_name as deptName,
|
|
u.phonenumber as phonenumber,
|
|
u.email as email,
|
|
u.status as status
|
|
from sys_user u
|
|
left join sys_dept d on u.dept_id = d.dept_id
|
|
where u.status = '0'
|
|
and u.user_id in
|
|
<foreach item="userId" collection="userIds" open="(" separator="," close=")">
|
|
#{userId}
|
|
</foreach>
|
|
order by u.dept_id, u.user_name
|
|
</select>
|
|
|
|
</mapper>
|