<?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.ho.flow.mapper.WorkOrderPlanSubMapper">

    <resultMap id="BaseResultMap" type="com.ho.flow.entity.WorkOrderPlanSub">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="pid" column="pid" jdbcType="INTEGER"/>
            <result property="type" column="type" jdbcType="VARCHAR"/>
            <result property="srcId" column="src_id" jdbcType="INTEGER"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,pid,type,
        src_id,user_id
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from work_order_plan_sub
        where  id = #{id,jdbcType=INTEGER} 
    </select>

    <select id="selectByPid" resultType="com.ho.flow.entity.WorkOrderPlanSub">
        select
        <include refid="Base_Column_List" />
        from work_order_plan_sub
        where  pid = #{pid}
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from work_order_plan_sub
        where  id = #{id,jdbcType=INTEGER} 
    </delete>
    <delete id="deleteByPid">
        delete from work_order_plan_sub
        where pid = #{pid}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.flow.entity.WorkOrderPlanSub" useGeneratedKeys="true">
        insert into work_order_plan_sub
        ( id,pid,type
        ,src_id)
        values (#{id,jdbcType=INTEGER},#{pid,jdbcType=INTEGER},#{type,jdbcType=VARCHAR}
        ,#{srcId,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.flow.entity.WorkOrderPlanSub" useGeneratedKeys="true">
        insert into work_order_plan_sub
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="pid != null">pid,</if>
                <if test="type != null">type,</if>
                <if test="srcId != null">src_id,</if>
                <if test="userId != null">user_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=INTEGER},</if>
                <if test="pid != null">#{pid,jdbcType=INTEGER},</if>
                <if test="type != null">#{type,jdbcType=VARCHAR},</if>
                <if test="srcId != null">#{srcId,jdbcType=INTEGER},</if>
                <if test="userId != null">#{userId,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <insert id="insertBatch">
        insert into work_order_plan_sub
        ( pid,type
        ,src_id)
        values
        <foreach item="item" collection="list" index="index" separator=",">
         (#{item.pid},#{item.type},#{item.srcId})
        </foreach>
    </insert>
    <insert id="insertUserBatch">
        insert into work_order_plan_sub
        ( pid,type
        ,user_id)
        values
        <foreach item="item" collection="list" index="index" separator=",">
            (#{item.pid},#{item.type},#{item.userId})
        </foreach>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.ho.flow.entity.WorkOrderPlanSub">
        update work_order_plan_sub
        <set>
                <if test="pid != null">
                    pid = #{pid,jdbcType=INTEGER},
                </if>
                <if test="type != null">
                    type = #{type,jdbcType=VARCHAR},
                </if>
                <if test="srcId != null">
                    src_id = #{srcId,jdbcType=INTEGER},
                </if>
        </set>
        where   id = #{id,jdbcType=INTEGER} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ho.flow.entity.WorkOrderPlanSub">
        update work_order_plan_sub
        set 
            pid =  #{pid,jdbcType=INTEGER},
            type =  #{type,jdbcType=VARCHAR},
            src_id =  #{srcId,jdbcType=INTEGER}
        where   id = #{id,jdbcType=INTEGER} 
    </update>
</mapper>
