<?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.ruoyi.interfaces.mapper.PtApprovalDao">
    <resultMap type="com.ruoyi.interfaces.domain.PtApproval" id="ptApprovalResultMap">
        <result property="id" column="ID" jdbcType="VARCHAR"/>
        <result property="applyUnit" column="APPLY_UNIT" jdbcType="VARCHAR"/>
        <result property="srvName" column="SRV_NAME" jdbcType="VARCHAR"/>
        <result property="srvId" column="SRV_ID" jdbcType="VARCHAR"/>
        <result property="status" column="STATUS" jdbcType="VARCHAR"/>
        <result property="opinion" column="OPINION" jdbcType="VARCHAR"/>
        <result property="approvalerId" column="APPROVALER_ID" jdbcType="VARCHAR"/>
        <result property="approvalerName" column="APPROVALER_NAME" jdbcType="VARCHAR"/>
        <result property="tm" column="TM" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="table_columns">
        ID
        ,
		APPLY_UNIT,
		SRV_NAME,
		SRV_ID,
		STATUS,
		OPINION,
		APPROVALER_ID,
		APPROVALER_NAME,
		TM
    </sql>
    <sql id="entity_properties">
        #{id,jdbcType=VARCHAR}
        ,
        #{applyUnit,jdbcType=VARCHAR},
        #{srvName,jdbcType=VARCHAR},
        #{srvId,jdbcType=VARCHAR},
        #{status,jdbcType=VARCHAR},
        #{opinion,jdbcType=VARCHAR},
        #{approvalerId,jdbcType=VARCHAR},
        #{approvalerName,jdbcType=VARCHAR},
        #{tm,jdbcType=VARCHAR}
    </sql>


    <insert id="insert" parameterType="com.ruoyi.interfaces.domain.PtApproval">
        insert into PT_APPROVAL(
        <include refid="table_columns"/>
        )
        values (
        <include refid="entity_properties"/>
        )
    </insert>

    <select id="selectByPrimaryKey" resultMap="ptApprovalResultMap" parameterType="java.lang.String">
        select
        <include refid="table_columns"/>
        from PT_APPROVAL
        where 1=1
        <if test="_parameter != null and _parameter !=''">
            and ID = #{_parameter,jdbcType=VARCHAR}
        </if>
    </select>

    <select id="selectBySrvId" resultMap="ptApprovalResultMap" parameterType="java.lang.String">
        select
        <include refid="table_columns"/>
        from PT_APPROVAL
        where SRV_ID = #{srvId,jdbcType=VARCHAR}
    </select>

    <update id="updateByPrimaryKey" parameterType="com.ruoyi.interfaces.domain.PtApproval">
        update PT_APPROVAL
        <set>
            <if test="applyUnit != null and applyUnit !=''">
                APPLY_UNIT = #{applyUnit,jdbcType=VARCHAR},
            </if>
            <if test="srvName != null and srvName !=''">
                SRV_NAME = #{srvName,jdbcType=VARCHAR},
            </if>
            <if test="srvId != null and srvId !=''">
                SRV_ID = #{srvId,jdbcType=VARCHAR},
            </if>
            <if test="status != null and status !=''">
                STATUS = #{status,jdbcType=VARCHAR},
            </if>
            <if test="opinion != null and opinion !=''">
                OPINION = #{opinion,jdbcType=VARCHAR},
            </if>
            <if test="approvalerId != null and approvalerId !=''">
                APPROVALER_ID = #{approvalerId,jdbcType=VARCHAR},
            </if>
            <if test="approvalerName != null and approvalerName !=''">
                APPROVALER_NAME = #{approvalerName,jdbcType=VARCHAR},
            </if>
            <if test="tm != null and tm !=''">
                TM = #{tm,jdbcType=VARCHAR},
            </if>
        </set>
        where ID = #{id,jdbcType=VARCHAR}
    </update>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        delete
        from PT_APPROVAL
        where ID = #{id,jdbcType=VARCHAR}
    </delete>

</mapper>
