<?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.zehong.system.mapper.TWorkTaskMemberMapper">
    
    <resultMap type="TWorkTaskMember" id="TWorkTaskMemberResult">
        <result property="id"    column="id"    />
        <result property="taskId"    column="task_id"    />
        <result property="memberId"    column="member_id"    />
        <result property="progress"    column="progress"    />
    </resultMap>

    <sql id="selectTWorkTaskMemberVo">
        select id, task_id, member_id,progress from t_work_task_member
    </sql>

    <select id="selectTWorkTaskMemberList" parameterType="TWorkTaskMember" resultMap="TWorkTaskMemberResult">
        <include refid="selectTWorkTaskMemberVo"/>
        <where>  
            <if test="taskId != null "> and task_id = #{taskId}</if>
            <if test="memberId != null "> and member_id = #{memberId}</if>
            <if test="progress != null "> and progress = #{progress}</if>
        </where>
    </select>
    
    <select id="selectTWorkTaskMemberById" parameterType="Long" resultMap="TWorkTaskMemberResult">
        <include refid="selectTWorkTaskMemberVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTWorkTaskMember" parameterType="TWorkTaskMember" useGeneratedKeys="true" keyProperty="id">
        insert into t_work_task_member
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskId != null">task_id,</if>
            <if test="memberId != null">member_id,</if>
            <if test="progress != null">progress,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskId != null">#{taskId},</if>
            <if test="memberId != null">#{memberId},</if>
            <if test="progress != null">#{progress},</if>
         </trim>
    </insert>

    <update id="updateTWorkTaskMember" parameterType="TWorkTaskMember">
        update t_work_task_member
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="memberId != null">member_id = #{memberId},</if>
            <if test="progress != null">progress = #{progress},</if>
        </trim>
        where id = #{id}
    </update>
    <update id="updateByMemberIdTaskId" parameterType="TWorkTaskMember">
        update t_work_task_member SET progress = #{progress}
        where  task_id =#{taskId} and member_id = #{memberId}
    </update>
    <delete id="deleteTWorkTaskMemberById" parameterType="Long">
        delete from t_work_task_member where id = #{id}
    </delete>

    <delete id="deleteTWorkTaskMemberByIds" parameterType="String">
        delete from t_work_task_member where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <delete id="deleteWorkTaskMemberByTaskId" parameterType="Long">
        delete from t_work_task_member where task_id = #{taskId}
    </delete>
</mapper>