<?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.WorkOrderSubMapper">



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

    <select id="selectByPrimaryKey" resultType="com.ho.flow.entity.WorkOrderSub">
        select
        <include refid="Base_Column_List" />
        from work_order_sub
        where  id = #{id,jdbcType=INTEGER}
    </select>
    <select id="selectByPid" resultType="com.ho.flow.entity.WorkOrderSub">
        select
        <include refid="Base_Column_List" />
        from work_order_sub
        where  pid = #{pId,jdbcType=INTEGER}
    </select>

    <delete id="deleteByPrimaryKey">
        delete from work_order_sub
        where  id = #{id,jdbcType=INTEGER}
    </delete>

    <delete id="deleteByPid">
        delete from work_order_sub
        where pid = #{pid}
    </delete>

    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.flow.entity.WorkOrderSub" useGeneratedKeys="true">
        insert into work_order_sub
        ( id,pid,type
        ,src_id)
        values (#{id,jdbcType=INTEGER},#{pid,jdbcType=BIGINT},#{type,jdbcType=INTEGER}
               ,#{srcId,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.flow.entity.WorkOrderSub" useGeneratedKeys="true">
        insert into work_order_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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=INTEGER},</if>
            <if test="pid != null">#{pid,jdbcType=BIGINT},</if>
            <if test="type != null">#{type,jdbcType=INTEGER},</if>
            <if test="srcId != null">#{srcId,jdbcType=INTEGER},</if>
        </trim>
    </insert>

    <insert id="insertBatch">
        insert into work_order_sub
        ( pid,`type`
        ,src_id)
        values
        <foreach item="item" collection="list" index="index" separator=",">
            (#{item.pid},#{item.type},#{item.srcId})
        </foreach>
    </insert>

    <update id="updateByPrimaryKeySelective" parameterType="com.ho.flow.entity.WorkOrderSub">
        update work_order_sub
        <set>
            <if test="pid != null">
                pid = #{pid,jdbcType=BIGINT},
            </if>
            <if test="type != null">
                type = #{type,jdbcType=INTEGER},
            </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.WorkOrderSub">
        update work_order_sub
        set
            pid =  #{pid,jdbcType=BIGINT},
            type =  #{type,jdbcType=INTEGER},
            src_id =  #{srcId,jdbcType=INTEGER}
        where   id = #{id,jdbcType=INTEGER}
    </update>
</mapper>
