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

    <resultMap type="com.ruoyi.interfaces.domain.PtServiceAuth" id="ptServiceAuthResultMap">
        <result property="id" column="ID"/>
        <result property="deadline" column="DEADLINE"/>
        <result property="appId" column="APP_ID"/>
        <result property="srvId" column="SRV_ID"/>
        <result property="userId" column="USER_ID"/>
    </resultMap>

    <sql id="table_columns">
        ID
        ,
            DEADLINE,
            APP_ID,
            SRV_ID,
            USER_ID
    </sql>
    <sql id="entity_properties">
        #{id,jdbcType=VARCHAR}
        ,
        #{deadline},
        #{appId,jdbcType=VARCHAR},
        #{srvId,jdbcType=VARCHAR},
        #{userId,jdbcType=VARCHAR}
    </sql>

    <!-- 使用like用法：columnName like concat('%',#columnName#,'%') -->
    <sql id="page_where">
        <trim prefix="where" prefixOverrides="and | or ">
            <if test="deadline != null">and DEADLINE = #{deadline}</if>
            <if test="appId != null and appId != ''">and APP_ID = #{appId}</if>
            <if test="srvId != null and srvId != ''">and SRV_ID = #{srvId}</if>
            <if test="userId != null and userId != ''">and USER_ID = #{userId}</if>
        </trim>
    </sql>


    <select id="get" resultMap="ptServiceAuthResultMap" parameterType="String">
        select
        <include refid="table_columns"/>
        from PT_SERVICE_AUTH where ID = #{id}
    </select>

    <select id="getBy" resultMap="ptServiceAuthResultMap">
        select
        <include refid="table_columns"/>
        from PT_SERVICE_AUTH
        <include refid="page_where"/>
    </select>

    <select id="findList" resultMap="ptServiceAuthResultMap">
        select
        <include refid="table_columns"/>
        from PT_SERVICE_AUTH
        <include refid="page_where"/>
    </select>

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

    <delete id="delete" parameterType="java.lang.String">
        update PT_SERVICE_AUTH
        set DATA_STAT='9'
        where ID = #{id}
    </delete>

    <delete id="deleteBy" parameterType="com.ruoyi.interfaces.domain.PtServiceAuth">
        update PT_SERVICE_AUTH set DATA_STAT='9'
        <include refid="page_where"/>
    </delete>

    <update id="update" parameterType="com.ruoyi.interfaces.domain.PtServiceAuth">
        update PT_SERVICE_AUTH
        <trim prefix="set" suffixOverrides=",">
            <if test="deadline != null">DEADLINE = #{deadline},</if>
            <if test="appId != null and appId != ''">APP_ID = #{appId},</if>
            <if test="srvId != null and srvId != ''">SRV_ID = #{srvId},</if>
            <if test="userId != null and userId != ''">USER_ID = #{userId},</if>
        </trim>
        <where>ID = #{id}</where>
    </update>

    <select id="listOfMap" resultType="java.util.Map">
        select *
        from PT_SERVICE_AUTH
    </select>
</mapper>
