<?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.project.mapper.TrsPersonResultMapper">

    <resultMap type="TrsPersonResult" id="TrsPersonResultResult">
        <result property="id"    column="id"    />
        <result property="sitename"    column="sitename"    />
        <result property="sitetag"    column="sitetag"    />
        <result property="title"    column="title"    />
        <result property="page"    column="page"    />
        <result property="wrongWord"    column="wrong_word"    />
        <result property="wrongType"    column="wrong_type"    />
        <result property="errorType"    column="error_type"    />
        <result property="context"    column="context"    />
        <result property="time"    column="time"    />
        <result property="status"    column="status"    />
        <result property="version"    column="version"    />
        <result property="datakey"    column="datakey"    />
        <result property="allcontext"    column="allcontext"    />
        <result property="tenantId"    column="tenant_id"    />
    </resultMap>

    <sql id="selectTrsPersonResultVo">
        select id, sitename, sitetag, title, page, wrong_word, wrong_type, error_type, context, time, status, version, datakey, tenant_id
        from trs_person_result
    </sql>

    <sql id="selectTrsPersonResultVo2">
        select id, sitename, sitetag, title, page, wrong_word, wrong_type, error_type, context, time, status, version, datakey, allcontext, tenant_id
        from trs_person_result
    </sql>

    <select id="selectId" parameterType="String" resultType="Long">
        select id from trs_person_result where datakey = #{datakey}
    </select>

    <select id="selectTrsPersonResultList" parameterType="TrsPersonResult" resultMap="TrsPersonResultResult">
        <include refid="selectTrsPersonResultVo"/>
        <where>
            <!-- 修改这里：将所有 concat 改为 || 操作符 -->
            <if test="sitename != null  and sitename != ''"> and sitename like '%' || #{sitename} || '%'</if>
            <if test="sitetag != null  and sitetag != ''"> and sitetag like '%' || #{sitetag} || '%'</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="page != null  and page != ''"> and page like '%' || #{page} || '%'</if>
            <if test="wrongWord != null  and wrongWord != ''"> and wrong_word like '%' || #{wrongWord} || '%'</if>
            <if test="wrongType != null  and wrongType != ''"> and wrong_type = #{wrongType}</if>
            <if test="errorType != null  and errorType != ''"> and error_type = #{errorType}</if>
            <if test="context != null  and context != ''"> and context like '%' || #{context} || '%'</if>
            <if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and time between #{params.beginTime} and #{params.endTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="version != null  and version != ''"> and version = #{version}</if>
            <if test="datakey != null  and datakey != ''"> and datakey = #{datakey}</if>
            <if test="allcontext != null  and allcontext != ''"> and allcontext = #{allcontext}</if>
            <if test="tenantId != null  and tenantId != ''"> and tenant_id = #{tenantId}</if>
        </where>
        order by time desc
    </select>

    <select id="selectTrsPersonResultList2" parameterType="TrsPersonResult" resultMap="TrsPersonResultResult">
        <include refid="selectTrsPersonResultVo"/>
        <where>
            <!-- 修改这里：将所有 concat 改为 || 操作符 -->
            <if test="sitename != null  and sitename != ''"> and sitename like '%' || #{sitename} || '%'</if>
            <if test="sitetag != null  and sitetag != ''"> and sitetag like '%' || #{sitetag} || '%'</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="page != null  and page != ''"> and page like '%' || #{page} || '%'</if>
            <if test="wrongWord != null  and wrongWord != ''"> and wrong_word like '%' || #{wrongWord} || '%'</if>
            <if test="wrongType != null  and wrongType != ''"> and wrong_type = #{wrongType}</if>
            <if test="errorType != null  and errorType != ''"> and error_type = #{errorType}</if>
            <if test="context != null  and context != ''"> and context like '%' || #{context} || '%'</if>
            <if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and time between #{params.beginTime} and #{params.endTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="version != null  and version != ''"> and version = #{version}</if>
            <if test="datakey != null  and datakey != ''"> and datakey = #{datakey}</if>
            <if test="allcontext != null  and allcontext != ''"> and allcontext = #{allcontext}</if>
            <if test="tenantId != null  and tenantId != ''"> and tenant_id = #{tenantId}</if>
        </where>
        order by time desc
    </select>

    <select id="selectTrsPersonResultById" parameterType="Long" resultMap="TrsPersonResultResult">
        <include refid="selectTrsPersonResultVo2"/>
        where id = #{id}
    </select>

    <!-- 以下 insert/update/delete 方法保持不变 -->
    <insert id="insertTrsPersonResult" parameterType="TrsPersonResult">
        insert into trs_person_result
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="sitename != null">sitename,</if>
            <if test="sitetag != null">sitetag,</if>
            <if test="title != null">title,</if>
            <if test="page != null">page,</if>
            <if test="wrongWord != null">wrong_word,</if>
            <if test="wrongType != null">wrong_type,</if>
            <if test="errorType != null">error_type,</if>
            <if test="context != null">context,</if>
            <if test="time != null">time,</if>
            <if test="status != null">status,</if>
            <if test="version != null">version,</if>
            <if test="datakey != null">datakey,</if>
            <if test="allcontext != null">allcontext,</if>
            <if test="tenantId != null">tenant_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="sitename != null">#{sitename},</if>
            <if test="sitetag != null">#{sitetag},</if>
            <if test="title != null">#{title},</if>
            <if test="page != null">#{page},</if>
            <if test="wrongWord != null">#{wrongWord},</if>
            <if test="wrongType != null">#{wrongType},</if>
            <if test="errorType != null">#{errorType},</if>
            <if test="context != null">#{context},</if>
            <if test="time != null">#{time},</if>
            <if test="status != null">#{status},</if>
            <if test="version != null">#{version},</if>
            <if test="datakey != null">#{datakey},</if>
            <if test="allcontext != null">#{allcontext},</if>
            <if test="tenantId != null">#{tenantId},</if>
        </trim>
    </insert>

    <update id="updateTrsPersonResult" parameterType="TrsPersonResult">
        update trs_person_result
        <trim prefix="SET" suffixOverrides=",">
            <if test="sitename != null">sitename = #{sitename},</if>
            <if test="sitetag != null">sitetag = #{sitetag},</if>
            <if test="title != null">title = #{title},</if>
            <if test="page != null">page = #{page},</if>
            <if test="wrongWord != null">wrong_word = #{wrongWord},</if>
            <if test="wrongType != null">wrong_type = #{wrongType},</if>
            <if test="errorType != null">error_type = #{errorType},</if>
            <if test="context != null">context = #{context},</if>
            <if test="time != null">time = #{time},</if>
            <if test="status != null">status = #{status},</if>
            <if test="version != null">version = #{version},</if>
            <if test="datakey != null">datakey = #{datakey},</if>
            <if test="allcontext != null">allcontext = #{allcontext},</if>
            <if test="tenantId != null  and tenantId != ''">  tenant_id = #{tenantId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTrsPersonResultById" parameterType="Long">
        delete from trs_person_result where id = #{id}
    </delete>

    <delete id="deleteTrsPersonResultByIds" parameterType="String">
        delete from trs_person_result where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>