<?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.dcs.hnyz.mapper.DcsGroupTaskMapper">

    <resultMap type="DcsGroupTask" id="DcsGroupTaskResult">
        <result property="groupId"    column="group_id"    />
        <result property="groupName"    column="group_name"    />
        <result property="groupCode"    column="group_code"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectDcsGroupTaskVo">
        select group_id, group_name, group_code, status, del_flag, create_by, update_by, create_time, update_time, remark from dcs_group_task
    </sql>

    <select id="selectDcsGroupTaskList" parameterType="DcsGroupTask" resultMap="DcsGroupTaskResult">
        <include refid="selectDcsGroupTaskVo"/>
        <where>
            <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
            <if test="groupCode != null  and groupCode != ''"> and group_code = #{groupCode}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>

    <select id="selectDcsGroupTaskByGroupId" parameterType="Long" resultMap="DcsGroupTaskResult">
        <include refid="selectDcsGroupTaskVo"/>
        where group_id = #{groupId}
    </select>

    <select id="selectDcsGroupTaskByGroupCode" parameterType="string" resultMap="DcsGroupTaskResult">
        <include refid="selectDcsGroupTaskVo"/>
        where group_code = #{groupCode}
    </select>

    <insert id="insertDcsGroupTask" parameterType="DcsGroupTask" useGeneratedKeys="true" keyProperty="groupId">
        insert into dcs_group_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="groupName != null">group_name,</if>
            <if test="groupCode != null">group_code,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="groupName != null">#{groupName},</if>
            <if test="groupCode != null">#{groupCode},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateDcsGroupTask" parameterType="DcsGroupTask">
        update dcs_group_task
        <trim prefix="SET" suffixOverrides=",">
            <if test="groupName != null">group_name = #{groupName},</if>
            <if test="groupCode != null">group_code = #{groupCode},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where group_id = #{groupId}
    </update>

    <delete id="deleteDcsGroupTaskByGroupId" parameterType="Long">
        delete from dcs_group_task where group_id = #{groupId}
    </delete>

    <delete id="deleteDcsGroupTaskByGroupIds" parameterType="String">
        delete from dcs_group_task where group_id in
        <foreach item="groupId" collection="array" open="(" separator="," close=")">
            #{groupId}
        </foreach>
    </delete>
</mapper>
