<?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.yanzhu.jh.project.mapper.SurProjectStandardMapper">

    <resultMap type="SurProjectStandard" id="SurProjectStandardResult">
        <result property="id"    column="id"    />
        <result property="projectId"    column="project_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="imageFile"    column="image_file"    />
        <result property="standardDesc"    column="standard_desc"    />
        <result property="ord"    column="ord"    />
        <result property="standardType"    column="standard_type"    />
        <result property="isDel"    column="is_del"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectSurProjectStandardVo">
        select id, project_id, dept_id, image_file, standard_desc, ord, standard_type, is_del, create_by, create_time, update_by, update_time from sur_project_standard
    </sql>

    <select id="selectSurProjectStandardList" parameterType="SurProjectStandard" resultMap="SurProjectStandardResult">
        <include refid="selectSurProjectStandardVo"/>
        <where>
            <if test="projectId != null "> and project_id = #{projectId}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="imageFile != null  and imageFile != ''"> and image_file = #{imageFile}</if>
            <if test="standardDesc != null  and standardDesc != ''"> and standard_desc = #{standardDesc}</if>
            <if test="ord != null "> and ord = #{ord}</if>
            <if test="standardType != null  and standardType != ''"> and standard_type = #{standardType}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
        order by standard_type,ord
    </select>

    <select id="selectSurProjectStandardById" parameterType="Long" resultMap="SurProjectStandardResult">
        <include refid="selectSurProjectStandardVo"/>
        where id = #{id}
    </select>

    <insert id="insertSurProjectStandard" parameterType="SurProjectStandard" useGeneratedKeys="true" keyProperty="id">
        insert into sur_project_standard
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectId != null">project_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="imageFile != null">image_file,</if>
            <if test="standardDesc != null">standard_desc,</if>
            <if test="ord != null">ord,</if>
            <if test="standardType != null">standard_type,</if>
            <if test="isDel != null">is_del,</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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectId != null">#{projectId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="imageFile != null">#{imageFile},</if>
            <if test="standardDesc != null">#{standardDesc},</if>
            <if test="ord != null">#{ord},</if>
            <if test="standardType != null">#{standardType},</if>
            <if test="isDel != null">#{isDel},</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>
        </trim>
    </insert>

    <update id="updateSurProjectStandard" parameterType="SurProjectStandard">
        update sur_project_standard
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="imageFile != null">image_file = #{imageFile},</if>
            <if test="standardDesc != null">standard_desc = #{standardDesc},</if>
            <if test="ord != null">ord = #{ord},</if>
            <if test="standardType != null">standard_type = #{standardType},</if>
            <if test="isDel != null">is_del = #{isDel},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSurProjectStandardById" parameterType="Long">
        delete from sur_project_standard where id = #{id}
    </delete>

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