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

    <resultMap type="com.ruoyi.interfaces.domain.PtServiceComment" id="ptServiceCommentResultMap">
        <result property="id" column="ID"/>
        <result property="score" column="SCORE"/>
        <result property="content" column="CONTENT"/>
        <result property="srvId" column="SRV_ID"/>
        <result property="userId" column="USER_ID"/>
        <result property="intm" column="INTM"/>
        <result property="reuserId" column="REUSER_ID"/>
        <result property="pid" column="PID"/>
    </resultMap>

    <sql id="table_columns">
        ID
        ,
            SCORE,
            CONTENT,
            SRV_ID,
            USER_ID,
            INTM,
            REUSER_ID,
            PID
    </sql>
    <sql id="entity_properties">
        #{id}
        ,
        #{score},
        #{content},
        #{srvId},
        #{userId},
        #{intm},
        #{reuserId},
        #{pid}
    </sql>

    <!-- 使用like用法：columnName like concat('%',#columnName#,'%') -->
    <sql id="page_where">
        <trim prefix="where" prefixOverrides="and | or ">
            <if test="score != null and score != ''">and SCORE = #{score}</if>
            <if test="content != null and content != ''">and CONTENT = #{content}</if>
            <if test="srvId != null and srvId != ''">and SRV_ID = #{srvId}</if>
            <if test="userId != null and userId != ''">and USER_ID = #{userId}</if>
            <if test="intm != null">and INTM = #{intm}</if>
            <if test="reuserId != null and reuserId != ''">and REUSER_ID = #{reuserId}</if>
            <if test="pid != null and pid != ''">and PID = #{pid}</if>
        </trim>
    </sql>


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

    <select id="findList" resultMap="ptServiceCommentResultMap">
        select
        <include refid="table_columns"/>
        from PT_SERVICE_COMMENT
        <include refid="page_where"/>
    </select>
    <insert id="insert" parameterType="com.ruoyi.interfaces.domain.PtServiceComment">
        insert into PT_SERVICE_COMMENT(
        <include refid="table_columns"/>
        )
        values (
        <include refid="entity_properties"/>
        )
    </insert>

    <delete id="delete" parameterType="java.lang.String">
        delete
        from PT_SERVICE_COMMENT
        where ID = #{id}
    </delete>

    <delete id="deleteBy" parameterType="com.ruoyi.interfaces.domain.PtServiceComment">
        delete from PT_SERVICE_COMMENT
        where
        <trim prefixOverrides="and | or ">
            <if test="srvId != null and srvId != ''">and SRV_ID = #{srvId}</if>
            <if test="userId != null and userId != ''">and USER_ID = #{userId}</if>
            <if test="reuserId != null and reuserId != ''">and REUSER_ID = #{reuserId}</if>
            <if test="pid != null and pid != ''">and PID = #{pid}</if>
        </trim>
    </delete>

    <update id="update" parameterType="com.ruoyi.interfaces.domain.PtServiceComment">
        update PT_SERVICE_COMMENT
        <trim prefix="set" suffixOverrides=",">
            <if test="score != null and score != ''">SCORE = #{score},</if>
            <if test="content != null and content != ''">CONTENT = #{content},</if>
            <if test="srvId != null and srvId != ''">SRV_ID = #{srvId},</if>
            <if test="userId != null and userId != ''">USER_ID = #{userId},</if>
            <if test="intm != null">INTM = #{intm},</if>
            <if test="reuserId != null and reuserId != ''">REUSER_ID = #{reuserId},</if>
            <if test="pid != null and pid != ''">PID = #{pid},</if>
        </trim>
        <where>ID = #{id}</where>
    </update>

    <select id="list" resultMap="ptServiceCommentResultMap">
        select
        <include refid="table_columns"/>
        from PT_SERVICE_COMMENT
        <include refid="page_where"/>
    </select>

    <select id="threeListByPid" resultMap="ptServiceCommentResultMap">
        SELECT * FROM (
        select
        <include refid="table_columns"/>
        from PT_SERVICE_COMMENT
        WHERE PID = #{pid}
        ORDER BY INTM
        ) A
        WHERE ROWNUM &lt;= 3
    </select>


</mapper>
