<?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.agri.system.mapper.SysRequireListMapper">
    
    <resultMap type="SysRequireList" id="SysRequireListResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="detail"    column="detail"    />
        <result property="priority"    column="priority"    />
        <result property="progress"    column="progress"    />
        <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="reqType"    column="req_type"    />
        <result property="assigneeId"    column="assignee_id"    />
        <result property="assigneeName"    column="assignee_name"    />
        <result property="version"    column="version"    />
    </resultMap>

    <sql id="selectSysRequireListVo">
        select id, title, detail, priority, progress, create_by, create_time, update_by, update_time, req_type, assignee_id, assignee_name, version from sys_require_list
    </sql>

    <select id="selectSysRequireListList" parameterType="SysRequireList" resultMap="SysRequireListResult">
        <include refid="selectSysRequireListVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="detail != null  and detail != ''"> and detail = #{detail}</if>
            <if test="priority != null "> and priority = #{priority}</if>
            <if test="progress != null "> and progress = #{progress}</if>
            <if test="reqType != null "> and req_type = #{reqType}</if>
            <if test="assigneeId != null "> and assignee_id = #{assigneeId}</if>
            <if test="assigneeName != null  and assigneeName != ''"> and assignee_name like concat('%', #{assigneeName}, '%')</if>
        </where>
    </select>
    
    <select id="selectSysRequireListById" parameterType="Long" resultMap="SysRequireListResult">
        <include refid="selectSysRequireListVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysRequireList" parameterType="SysRequireList" useGeneratedKeys="true" keyProperty="id">
        insert into sys_require_list
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null and title != ''">title,</if>
            <if test="detail != null and detail != ''">detail,</if>
            <if test="priority != null">priority,</if>
            <if test="progress != null">progress,</if>
    create_by,
    create_time,
    update_by,
    update_time,
            <if test="reqType != null">req_type,</if>
            <if test="assigneeId != null">assignee_id,</if>
            <if test="assigneeName != null">assignee_name,</if>
            <if test="version != null">version,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null and title != ''">#{title},</if>
            <if test="detail != null and detail != ''">#{detail},</if>
            <if test="priority != null">#{priority},</if>
            <if test="progress != null">#{progress},</if>
        #{createBy},
        #{createTime},
        #{updateBy},
        #{updateTime},
            <if test="reqType != null">#{reqType},</if>
            <if test="assigneeId != null">#{assigneeId},</if>
            <if test="assigneeName != null">#{assigneeName},</if>
            <if test="version != null">#{version},</if>
         </trim>
    </insert>

    <update id="updateSysRequireList" parameterType="SysRequireList">
        update sys_require_list
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="detail != null and detail != ''">detail = #{detail},</if>
            <if test="priority != null">priority = #{priority},</if>
            <if test="progress != null">progress = #{progress},</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="reqType != null">req_type = #{reqType},</if>
            <if test="assigneeId != null">assignee_id = #{assigneeId},</if>
            <if test="assigneeName != null">assignee_name = #{assigneeName},</if>
            <if test="version != null">version = #{version},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysRequireListById" parameterType="Long">
        delete from sys_require_list where id = #{id}
    </delete>

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