<?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="io.renren.modules.sys.dao.algs.ApprovalMapper">
    <resultMap id="BaseResultMap" type="io.renren.modules.sys.entity.algs.Approval">
        <id column="approval_id" jdbcType="BIGINT" property="approvalId" />
        <result column="algorithm_training_id" jdbcType="BIGINT" property="algorithmTrainingId" />
        <result column="model_id" jdbcType="BIGINT" property="modelId" />
        <result column="category_id" jdbcType="BIGINT" property="categoryId" />
        <result column="uid" jdbcType="BIGINT" property="uid" />
        <result column="apply_time" jdbcType="TIMESTAMP" property="applyTime" />
        <result column="approval_status" jdbcType="TINYINT" property="approvalStatus" />
    </resultMap>
    <sql id="Base_Column_List">
        approval_id, algorithm_training_id, model_id, category_id, uid, apply_time, approval_status
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from approval
        where approval_id = #{approvalId,jdbcType=BIGINT}
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from approval
        where approval_id = #{approvalId,jdbcType=BIGINT}
     </delete>
    <insert id="insert" parameterType="io.renren.modules.sys.entity.algs.Approval">
        insert into  approval(approval_id, algorithm_training_id, model_id, category_id, uid,
         apply_time, approval_status)
        values (#{approvalId,jdbcType=BIGINT}, #{algorithmTrainingId,jdbcType=BIGINT}, #{modelId,jdbcType=BIGINT},
          #{categoryId,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{applyTime,jdbcType=TIMESTAMP},
          #{approvalStatus,jdbcType=TINYINT})
    </insert>
    <insert id="insertSelective" parameterType="io.renren.modules.sys.entity.algs.Approval">
        insert into approval
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="approvalId!=null">
                approval_id,
            </if>
            <if test="algorithmTrainingId!=null">
                algorithm_training_id,
            </if>
            <if test="modelId!=null">
                model_id,
            </if>
            <if test="categoryId!=null">
                category_id,
            </if>
            <if test="uid!=null">
                uid,
            </if>
            <if test="applyTime!=null">
                apply_time,
            </if>
            <if test="approvalStatus!=null">
                approval_status,
            </if>
        </trim>
        <trim prefix="values(" suffix=")" suffixOverrides=",">
            <if test="approvalId!=null">
                #{approvalId,jdbcType=BIGINT},
            </if>
            <if test="algorithmTrainingId!=null">
                #{algorithmTrainingId,jdbcType=BIGINT},
            </if>
            <if test="modelId!=null">
                #{modelId,jdbcType=BIGINT},
            </if>
            <if test="categoryId!=null">
                #{categoryId,jdbcType=BIGINT},
            </if>
            <if test="uid!=null">
                #{uid,jdbcType=BIGINT},
            </if>
            <if test="applyTime!=null">
                #{applyTime,jdbcType=TIMESTAMP},
            </if>
            <if test="approvalStatus!=null">
                #{approvalStatus,jdbcType=TINYINT},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="io.renren.modules.sys.entity.algs.Approval">
        update approval
        <set>
            <if test="approvalId!=null">
                approval_id=#{approvalId,jdbcType=BIGINT},
            </if>
            <if test="algorithmTrainingId!=null">
                algorithm_training_id=#{algorithmTrainingId,jdbcType=BIGINT},
            </if>
            <if test="modelId!=null">
                model_id=#{modelId,jdbcType=BIGINT},
            </if>
            <if test="categoryId!=null">
                category_id=#{categoryId,jdbcType=BIGINT},
            </if>
            <if test="uid!=null">
                uid=#{uid,jdbcType=BIGINT},
            </if>
            <if test="applyTime!=null">
                apply_time=#{applyTime,jdbcType=TIMESTAMP},
            </if>
            <if test="approvalStatus!=null">
                approval_status=#{approvalStatus,jdbcType=TINYINT},
            </if>
        </set>
        where approval_id=#{approvalId,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="io.renren.modules.sys.entity.algs.Approval">
        update approval
        set approval_id=#{approvalId,jdbcType=BIGINT},
          algorithm_training_id=#{algorithmTrainingId,jdbcType=BIGINT},
          model_id=#{modelId,jdbcType=BIGINT},
          category_id=#{categoryId,jdbcType=BIGINT},
          uid=#{uid,jdbcType=BIGINT},
          apply_time=#{applyTime,jdbcType=TIMESTAMP},
          approval_status=#{approvalStatus,jdbcType=TINYINT},
        where approval_id=#{approvalId,jdbcType=BIGINT}
    </update>


</mapper>