<?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.TrsWordResultsMapper">
    
    <resultMap type="TrsWordResults" id="TrsWordResultsResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="content"    column="content"    />
        <result property="status"    column="status"    />
        <result property="wrongWord"    column="wrong_word"    />
        <result property="errorType"    column="error_type"    />
        <result property="errorGrade"    column="error_grade"    />
        <result property="correctWord"    column="correct_word"    />
        <result property="source"    column="source"    />
        <result property="url"    column="url"    />
        <result property="time"    column="time"    />
        <result property="operuser"    column="operuser"    />
        <result property="ip"    column="ip"    />
        <result property="res"    column="res"    />
        <result property="logId"    column="log_id"    />
        <result property="sitename"    column="sitename"    />
        <result property="startpos"    column="startpos"    />
        <result property="endpos"    column="endpos"    />
    </resultMap>

    <sql id="selectTrsWordResultsVo">
        select id, title, content, status, wrong_word, error_type, error_grade, correct_word, source, url, time, operuser, ip, res, log_id, sitename, startpos, endpos from trs_word_results
    </sql>

    <select id="selectTrsWordResultsList" parameterType="TrsWordResults" resultMap="TrsWordResultsResult">
        <include refid="selectTrsWordResultsVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="wrongWord != null  and wrongWord != ''"> and wrong_word = #{wrongWord}</if>
            <if test="errorType != null  and errorType != ''"> and error_type = #{errorType}</if>
            <if test="errorGrade != null  and errorGrade != ''"> and error_grade = #{errorGrade}</if>
            <if test="correctWord != null  and correctWord != ''"> and correct_word = #{correctWord}</if>
            <if test="source != null  and source != ''"> and source = #{source}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="time != null "> and time = #{time}</if>
            <if test="operuser != null  and operuser != ''"> and operuser = #{operuser}</if>
            <if test="ip != null  and ip != ''"> and ip = #{ip}</if>
            <if test="res != null "> and res = #{res}</if>
            <if test="logId != null "> and log_id = #{logId}</if>
            <if test="sitename != null  and sitename != ''"> and sitename like concat('%', #{sitename}, '%')</if>
        </where>
    </select>

    <select id="selectTrsWordResultsAdminList" parameterType="TrsWordResults" resultMap="TrsWordResultsResult">
        select id, title, status, wrong_word, error_type, error_grade, correct_word, source, url, time, operuser, ip, res, log_id, sitename, startpos, endpos from trs_word_results
        <where>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="wrongWord != null  and wrongWord != ''"> and wrong_word = #{wrongWord}</if>
            <if test="errorType != null  and errorType != ''"> and error_type = #{errorType}</if>
            <if test="errorGrade != null  and errorGrade != ''"> and error_grade = #{errorGrade}</if>
            <if test="correctWord != null  and correctWord != ''"> and correct_word = #{correctWord}</if>
            <if test="source != null  and source != ''"> and source = #{source}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="time != null "> and time = #{time}</if>
            <if test="operuser != null  and operuser != ''"> and operuser = #{operuser}</if>
            <if test="ip != null  and ip != ''"> and ip = #{ip}</if>
            <if test="res != null "> and res = #{res}</if>
            <if test="logId != null "> and log_id = #{logId}</if>
            <if test="sitename != null  and sitename != ''"> and sitename like concat('%', #{sitename}, '%')</if>
        </where>
    </select>
    
    <select id="selectTrsWordResultsById" parameterType="Long" resultMap="TrsWordResultsResult">
        <include refid="selectTrsWordResultsVo"/>
        where id = #{id}
    </select>

    <insert id="insertTrsWordResults" parameterType="TrsWordResults" useGeneratedKeys="true" keyProperty="id">
        insert into trs_word_results
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="content != null">content,</if>
            <if test="status != null">status,</if>
            <if test="wrongWord != null">wrong_word,</if>
            <if test="errorType != null">error_type,</if>
            <if test="errorGrade != null">error_grade,</if>
            <if test="correctWord != null">correct_word,</if>
            <if test="source != null">source,</if>
            <if test="url != null">url,</if>
            <if test="time != null">time,</if>
            <if test="operuser != null">operuser,</if>
            <if test="ip != null">ip,</if>
            <if test="res != null">res,</if>
            <if test="logId != null">log_id,</if>
            <if test="sitename != null">sitename,</if>
            <if test="startpos != null">startpos,</if>
            <if test="endpos != null">endpos,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="content != null">#{content},</if>
            <if test="status != null">#{status},</if>
            <if test="wrongWord != null">#{wrongWord},</if>
            <if test="errorType != null">#{errorType},</if>
            <if test="errorGrade != null">#{errorGrade},</if>
            <if test="correctWord != null">#{correctWord},</if>
            <if test="source != null">#{source},</if>
            <if test="url != null">#{url},</if>
            <if test="time != null">#{time},</if>
            <if test="operuser != null">#{operuser},</if>
            <if test="ip != null">#{ip},</if>
            <if test="res != null">#{res},</if>
            <if test="logId != null">#{logId},</if>
            <if test="sitename != null">#{sitename},</if>
            <if test="startpos != null">#{startpos},</if>
            <if test="endpos != null">#{endpos},</if>
         </trim>
    </insert>

    <update id="updateTrsWordResults" parameterType="TrsWordResults">
        update trs_word_results
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="content != null">content = #{content},</if>
            <if test="status != null">status = #{status},</if>
            <if test="wrongWord != null">wrong_word = #{wrongWord},</if>
            <if test="errorType != null">error_type = #{errorType},</if>
            <if test="errorGrade != null">error_grade = #{errorGrade},</if>
            <if test="correctWord != null">correct_word = #{correctWord},</if>
            <if test="source != null">source = #{source},</if>
            <if test="url != null">url = #{url},</if>
            <if test="time != null">time = #{time},</if>
            <if test="operuser != null">operuser = #{operuser},</if>
            <if test="ip != null">ip = #{ip},</if>
            <if test="res != null">res = #{res},</if>
            <if test="logId != null">log_id = #{logId},</if>
            <if test="sitename != null">sitename = #{sitename},</if>
            <if test="startpos != null">startpos = #{startpos},</if>
            <if test="endpos != null">endpos = #{endpos},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTrsWordResultsById" parameterType="Long">
        delete from trs_word_results where id = #{id}
    </delete>

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

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

</mapper>