yangys
2024-04-18 b3cbbc1b1bf540359ac22f8733f6c322d845b38f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?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.qianwen.smartman.modules.cps.mapper.OrganizationMapper">
 
    <select id="selectOrganizationList" resultType="com.qianwen.smartman.modules.cps.dto.OrganizationDTO">
        SELECT a.id,a.code,a.name,a.parent_id,
        count(d.id) peopleNum,b.name parentName,a.status status
        FROM blade_common_group a
        LEFT JOIN blade_common_group b on b.id = a.parent_id and b.is_deleted = 0
        AND a.group_type =b.group_type and a.group_category =b.group_category
        LEFT JOIN blade_common_group_of_item c on c.group_id = a.id
        LEFT JOIN blade_employee d on d.id = c.item_id and d.is_deleted = 0
        <where>
            a.is_deleted = 0
            <if test="query.name != null and query.name != ''">
                and a.name LIKE concat(#{query.name},'%')
            </if>
            <if test="query.status != null">
                and a.status = #{query.status}
            </if>
            and a.group_type = #{query.groupType}
            and a.group_category = #{query.groupCategory}
        </where>
        group by a.id,a.code,a.name,a.parent_id,b.name,a.sort,a.status
        order by a.id desc
    </select>
 
    <select id="getOneEmployeeByOrganizationIdList" resultType="com.qianwen.smartman.modules.cps.entity.Employee">
        select b.id
        from blade_common_group_of_item a
        join blade_employee b on b.id = a.item_id and b.is_deleted=0
        <where>
            <if test="organizationIdList != null and organizationIdList.size() > 0">
                AND a.group_id IN
                <foreach collection="organizationIdList" item="organizationId" open="(" separator="," close=")">
                    #{organizationId}
                </foreach>
            </if>
        </where>
        LIMIT 1
    </select>
</mapper>