<?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.srs.stureg.mapper.SrsTaskListMapper">

    <resultMap type="SrsTaskList" id="SrsTaskListResult">
        <result property="id"    column="id"    />
        <result property="projectName"    column="project_name"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="status"    column="status"    />
        <result property="url"    column="url"    />
        <result property="rowRank"    column="row_rank"    />
        <result property="isMust"    column="is_must"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="taskCode"    column="task_code"    />
        <result property="isOpen"    column="is_open"    />
    </resultMap>

    <sql id="selectSrsTaskListVo">
        select id,is_open,task_code, project_name, start_time, end_time, status, url, row_rank, is_must, del_flag, create_by, create_time, update_by, update_time from srs_task_list
    </sql>

    <select id="selectSrsTaskListList" parameterType="SrsTaskList" resultMap="SrsTaskListResult">
        <include refid="selectSrsTaskListVo"/>
        <where>
            <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="rowRank != null "> and row_rank = #{rowRank}</if>
            <if test="isMust != null "> and is_must = #{isMust}</if>
            <if test="taskCode != null "> and task_code = #{taskCode}</if>
            <if test="isOpen != null "> and is_open = #{isOpen}</if>
            and del_flag = #{delFlag}
        </where>
        order by row_rank
    </select>

    <select id="selectSrsTaskListById" parameterType="Long" resultMap="SrsTaskListResult">
        <include refid="selectSrsTaskListVo"/>
        where id = #{id}
    </select>

    <insert id="insertSrsTaskList" parameterType="SrsTaskList" useGeneratedKeys="true" keyProperty="id">
        insert into srs_task_list
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectName != null">project_name,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="status != null">status,</if>
            <if test="url != null">url,</if>
            <if test="rowRank != null">row_rank,</if>
            <if test="isMust != null">is_must,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="taskCode != null">task_code,</if>
            <if test="isOpen != null">is_open,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectName != null">#{projectName},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="status != null">#{status},</if>
            <if test="url != null">#{url},</if>
            <if test="rowRank != null">#{rowRank},</if>
            <if test="isMust != null">#{isMust},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="taskCode != null">#{taskCode},</if>
            <if test="isOpen != null">#{isOpen},</if>
        </trim>
    </insert>

    <update id="updateSrsTaskList" parameterType="SrsTaskList">
        update srs_task_list
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectName != null">project_name = #{projectName},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="url != null">url = #{url},</if>
            <if test="rowRank != null">row_rank = #{rowRank},</if>
            <if test="isMust != null">is_must = #{isMust},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="taskCode != null">task_code = #{taskCode},</if>
            <if test="isOpen != null">is_open = #{isOpen},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSrsTaskListById" parameterType="Long">
        delete from srs_task_list where id = #{id}
    </delete>

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