GroupMemberMappingMapper.xml 1.3 KB
<?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.subsidy.mapper.GroupMemberMappingMapper">

    <select id="parentCnt" parameterType="long" resultType="com.subsidy.vo.labor.AllGroupsVO">
        SELECT
            t.id,
            t.group_name,
            count( t2.id ) cnt
        FROM
            labor_group_dict t
            LEFT JOIN group_member_mapping t2 ON t.id = t2.group_id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.parent_id IS NULL
            AND t.labor_id = #{laborId}
        GROUP BY
            t.id,
            t.group_name
    </select>

    <select id="childCnt" parameterType="long" resultType="com.subsidy.vo.labor.AllGroupsVO">
        SELECT
            t.id,
            t.group_name,
            count( t2.member_id ) cnt
        FROM
            labor_group_dict t
            LEFT JOIN group_member_mapping t2 ON t.id = t2.group_id AND t2.delete_date IS NULL
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.parent_id IS NOT NULL
            AND t.labor_id = #{laborId}
        GROUP BY
            t.id,
            t.group_name
    </select>

</mapper>