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)
)
)
AND cg.user_name = #{userName}
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)
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
cg.del_flag = '0'
AND cg.create_status = '1'
AND cg.group_name LIKE CONCAT('%', #{dto.groupName}, '%')
AND cg.group_mode = #{dto.groupMode}
AND cg.create_mode = #{dto.createMode}
AND cg.group_status = #{dto.groupStatus}
ORDER BY cg.create_time DESC
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'
SELECT COUNT(1)
FROM ibs_cust_group cg
WHERE cg.id = #{id}
AND cg.del_flag = '0'
AND cg.create_status = '1'