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

    <resultMap type="TrsUrlResult" id="TrsUrlResultResult">
        <result property="id"    column="id"    />
        <result property="record"    column="record"    />
        <result property="sitename"    column="sitename"    />
        <result property="sitetag"    column="sitetag"    />
        <result property="url"    column="url"    />
        <result property="linkurl"    column="linkurl"    />
        <result property="type"    column="type"    />
        <result property="msg"    column="msg"    />
        <result property="time"    column="time"    />
        <result property="title"    column="title"    />
        <result property="tenantId"    column="tenant_id"    />
    </resultMap>

    <sql id="selectTrsUrlResultVo">
        select id, record, sitename, url, linkurl, type, msg, time, title, tenant_id  from trs_url_result
    </sql>

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

    <select id="selectTrsUrlResultList" parameterType="TrsUrlResult" resultMap="TrsUrlResultResult">
        <include refid="selectTrsUrlResultVo"/>
        <where>
            <if test="record != null "> and record = #{record}</if>
            <!-- 修改这里：将 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="url != null  and url != ''"> and url = #{url}</if>
            <if test="linkurl != null  and linkurl != ''"> and linkurl = #{linkurl}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="msg != null  and msg != ''"> and msg = #{msg}</if>
            <if test="title != null  and title != ''"> and title = #{title}</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="tenantId != null  and tenantId != ''"> and tenant_id = #{tenantId}</if>
        </where>
    </select>

    <select id="selectTrsUrlResultList2" parameterType="TrsUrlResult" resultMap="TrsUrlResultResult">
        <include refid="selectTrsUrlResultVo"/>
        <where>
            <if test="record != null "> and record = #{record}</if>
            <!-- 修改这里：将 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="url != null  and url != ''"> and url = #{url}</if>
            <if test="linkurl != null  and linkurl != ''"> and linkurl = #{linkurl}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="msg != null  and msg != ''"> and msg = #{msg}</if>
            <if test="title != null  and title != ''"> and title = #{title}</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="tenantId != null  and tenantId != ''"> and tenant_id = #{tenantId}</if>
        </where>
    </select>

    <select id="selectTrsUrlResultById" parameterType="Long" resultMap="TrsUrlResultResult">
        <include refid="selectTrsUrlResultVo"/>
        where id = #{id}
    </select>

    <insert id="insertTrsUrlResult" parameterType="TrsUrlResult" useGeneratedKeys="true" keyProperty="id">
        insert into trs_url_result
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="record != null">record,</if>
            <if test="sitename != null">sitename,</if>
            <if test="sitetag != null">sitetag,</if>
            <if test="url != null">url,</if>
            <if test="linkurl != null">linkurl,</if>
            <if test="type != null">type,</if>
            <if test="msg != null">msg,</if>
            <if test="time != null">time,</if>
            <if test="title != null">title,</if>
            <if test="tenantId != null">tenant_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="record != null">#{record},</if>
            <if test="sitename != null">#{sitename},</if>
            <if test="sitetag != null">#{sitetag},</if>
            <if test="url != null">#{url},</if>
            <if test="linkurl != null">#{linkurl},</if>
            <if test="type != null">#{type},</if>
            <if test="msg != null">#{msg},</if>
            <if test="time != null">#{time},</if>
            <if test="title != null">#{title},</if>
            <if test="tenantId != null">#{tenantId},</if>
        </trim>
    </insert>

    <update id="updateTrsUrlResult" parameterType="TrsUrlResult">
        update trs_url_result
        <trim prefix="SET" suffixOverrides=",">
            <if test="record != null">record = #{record},</if>
            <if test="sitename != null">sitename = #{sitename},</if>
            <if test="sitetag != null">sitetag = #{sitetag},</if>
            <if test="url != null">url = #{url},</if>
            <if test="linkurl != null">linkurl = #{linkurl},</if>
            <if test="type != null">type = #{type},</if>
            <if test="msg != null">msg = #{msg},</if>
            <if test="time != null">time = #{time},</if>
            <if test="title != null">title = #{title},</if>
            <if test="tenantId != null  and tenantId != ''">  tenant_id = #{tenantId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTrsUrlResultById" parameterType="Long">
        delete from trs_url_result where id = #{id}
    </delete>

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

</mapper>