<?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.zcloud.domain.persistence.mapper.ProjectTaskGroupUserMapper">
    <select id="getListByUserIdList" resultType="com.zcloud.domain.persistence.dataobject.ProjectTaskGroupUserDO">
        select ptg.*
        from project_task_group_user ptg
        left join project_task pt on ptg.project_task_id = pt.project_task_id
        left join user u on ptg.user_id = u.id
        where pt.delete_enum = 'false'
        and ptg.delete_enum = 'false'
        and pt.execute_status != 4
        and ptg.user_id in
        <foreach collection="userIdList" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        group by pt.id
    </select>
    <select id="getListByTaskId" resultType="com.zcloud.domain.persistence.dataobject.ProjectTaskGroupUserDO">
        select ptgu.*, d.name as departmentName, u.name as userName, c.corp_name as executeCorpinfoName
        from project_task_group_user ptgu
                 left join department d on ptgu.department_id = d.id
                 left join user u on ptgu.user_id = u.id
                 left join corp_info c on ptgu.execute_corpinfo_id = c.id
        where ptgu.delete_enum = 'false'
          and ptgu.project_task_id =#{projectTaskId}
        group by ptgu.id
        order by ptgu.create_time desc
    </select>
</mapper>

