<?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.ktg.iscs.mapper.IsSopPointsMapper">

    <resultMap type="IsSopPoints" id="IsSopPointsResult">
        <result property="recordId"    column="record_id"    />
        <result property="sopId"    column="sop_id"    />
        <result property="workshopId"    column="workshop_id"    />
        <result property="workareaId"    column="workarea_id"    />
        <result property="pointId"    column="point_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="prePointId"    column="pre_point_id"    />
    </resultMap>

    <sql id="selectIsSopPointsVo">
        select * from is_sop_points
    </sql>

    <select id="selectIsSopPointsList" parameterType="IsSopPoints" resultMap="IsSopPointsResult">
        <include refid="selectIsSopPointsVo"/>
        <where>
            <if test="sopId != null "> and sop_id = #{sopId}</if>
            <if test="workshopId != null "> and workshop_id = #{workshopId}</if>
            <if test="workareaId != null "> and workarea_id = #{workareaId}</if>
            <if test="pointId != null "> and point_id = #{pointId}</if>
        </where>
    </select>

    <select id="selectIsSopPointsByRecordId" parameterType="Long" resultMap="IsSopPointsResult">
        <include refid="selectIsSopPointsVo"/>
        where record_id = #{recordId}
    </select>

    <insert id="insertIsSopPoints" parameterType="IsSopPoints" useGeneratedKeys="true" keyProperty="recordId">
        insert into is_sop_points
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sopId != null">sop_id,</if>
            <if test="workshopId != null">workshop_id,</if>
            <if test="workareaId != null">workarea_id,</if>
            <if test="pointId != null">point_id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="prePointId != null">pre_point_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sopId != null">#{sopId},</if>
            <if test="workshopId != null">#{workshopId},</if>
            <if test="workareaId != null">#{workareaId},</if>
            <if test="pointId != null">#{pointId},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="prePointId != null">#{prePointId},</if>
         </trim>
    </insert>

    <update id="updateIsSopPoints" parameterType="IsSopPoints">
        update is_sop_points
        <trim prefix="SET" suffixOverrides=",">
            <if test="sopId != null">sop_id = #{sopId},</if>
            <if test="workshopId != null">workshop_id = #{workshopId},</if>
            <if test="workareaId != null">workarea_id = #{workareaId},</if>
            <if test="pointId != null">point_id = #{pointId},</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="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="prePointId != null">pre_point_id = #{prePointId},</if>
        </trim>
        where record_id = #{recordId}
    </update>

    <delete id="deleteIsSopPointsByRecordId" parameterType="Long">
        delete from is_sop_points where record_id = #{recordId}
    </delete>

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