120 lines
4.0 KiB
XML
120 lines
4.0 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="com.ruoyi.group.mapper.CustGroupMapper">
|
|
|
|
<sql id="custGroupVisibleBaseCondition">
|
|
AND (
|
|
cg.user_name = #{userName}
|
|
OR (
|
|
cg.share_enabled = 1
|
|
AND cg.group_status = '0'
|
|
AND cg.share_dept_ids IS NOT NULL
|
|
AND cg.share_dept_ids != ''
|
|
AND find_in_set(#{deptId}, cg.share_dept_ids)
|
|
)
|
|
)
|
|
</sql>
|
|
|
|
<sql id="custGroupVisibleCondition">
|
|
<choose>
|
|
<when test="dto != null and dto.viewType == 'mine'">
|
|
AND cg.user_name = #{userName}
|
|
</when>
|
|
<when test="dto != null and dto.viewType == 'sharedToMe'">
|
|
AND cg.share_enabled = 1
|
|
AND cg.group_status = '0'
|
|
AND cg.share_dept_ids IS NOT NULL
|
|
AND cg.share_dept_ids != ''
|
|
AND find_in_set(#{deptId}, cg.share_dept_ids)
|
|
</when>
|
|
<otherwise>
|
|
<include refid="custGroupVisibleBaseCondition"/>
|
|
</otherwise>
|
|
</choose>
|
|
</sql>
|
|
|
|
<select id="selectCustGroupList" resultType="CustGroupVO">
|
|
SELECT
|
|
cg.id,
|
|
cg.group_name,
|
|
cg.group_mode,
|
|
cg.create_mode,
|
|
cg.user_name,
|
|
cg.nick_name,
|
|
cg.dept_id,
|
|
cg.share_enabled,
|
|
cg.share_dept_ids,
|
|
cg.group_status,
|
|
cg.create_by,
|
|
cg.create_time,
|
|
cg.update_by,
|
|
cg.update_time,
|
|
cg.remark,
|
|
cg.del_flag,
|
|
(SELECT COUNT(*) FROM ibs_cust_group_member cgm WHERE cgm.group_id = cg.id AND cgm.del_flag = '0') AS cust_count
|
|
FROM ibs_cust_group cg
|
|
<where>
|
|
cg.del_flag = '0'
|
|
AND cg.create_status = '1'
|
|
<include refid="custGroupVisibleCondition"/>
|
|
<if test="dto.groupName != null and dto.groupName != ''">
|
|
AND cg.group_name LIKE CONCAT('%', #{dto.groupName}, '%')
|
|
</if>
|
|
<if test="dto.groupMode != null and dto.groupMode != ''">
|
|
AND cg.group_mode = #{dto.groupMode}
|
|
</if>
|
|
<if test="dto.createMode != null and dto.createMode != ''">
|
|
AND cg.create_mode = #{dto.createMode}
|
|
</if>
|
|
<if test="dto.groupStatus != null and dto.groupStatus != ''">
|
|
AND cg.group_status = #{dto.groupStatus}
|
|
</if>
|
|
</where>
|
|
ORDER BY cg.create_time DESC
|
|
</select>
|
|
|
|
<select id="selectCustGroupById" resultType="CustGroupVO">
|
|
SELECT
|
|
cg.id,
|
|
cg.group_name,
|
|
cg.group_mode,
|
|
cg.create_mode,
|
|
cg.user_name,
|
|
cg.nick_name,
|
|
cg.dept_id,
|
|
cg.share_enabled,
|
|
cg.share_dept_ids,
|
|
cg.group_status,
|
|
cg.valid_time,
|
|
cg.create_by,
|
|
cg.create_time,
|
|
cg.update_by,
|
|
cg.update_time,
|
|
cg.remark,
|
|
cg.create_status,
|
|
cg.grid_type,
|
|
cg.cmpm_biz_type,
|
|
cg.grid_user_names,
|
|
cg.region_grid_ids,
|
|
cg.draw_grid_ids,
|
|
(SELECT COUNT(*) FROM ibs_cust_group_member cgm WHERE cgm.group_id = cg.id AND cgm.del_flag = '0') AS cust_count
|
|
FROM ibs_cust_group cg
|
|
WHERE cg.id = #{id}
|
|
AND cg.del_flag = '0'
|
|
AND cg.create_status = '1'
|
|
<include refid="custGroupVisibleBaseCondition"/>
|
|
</select>
|
|
|
|
<select id="countVisibleCustGroup" resultType="java.lang.Long">
|
|
SELECT COUNT(1)
|
|
FROM ibs_cust_group cg
|
|
WHERE cg.id = #{id}
|
|
AND cg.del_flag = '0'
|
|
AND cg.create_status = '1'
|
|
<include refid="custGroupVisibleBaseCondition"/>
|
|
</select>
|
|
|
|
</mapper>
|