<?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.sundot.airport.item.mapper.FailedMatchItemMapper">

    <resultMap type="FailedMatchItem" id="FailedMatchItemResult">
        <result property="id" column="id"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="revision" column="revision"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="name" column="name"/>
        <result property="code" column="code"/>
        <result property="categoryCode" column="category_code"/>
        <result property="categoryName" column="category_name"/>
        <result property="dangerLevel" column="danger_level"/>
        <result property="dangerLevelDesc" column="danger_level_desc"/>
        <result property="userId" column="user_id"/>
        <result property="userName" column="user_name"/>
        <result property="positionId" column="position_id"/>
        <result property="positionName" column="position_name"/>
        <result property="fullPositionPath" column="full_position_path"/>
        <result property="teamId" column="team_id"/>
        <result property="teamName" column="team_name"/>
        <result property="postDictCode" column="post_dict_code"/>
        <result property="postLabel" column="post_label"/>
        <result property="terminalId" column="terminal_id"/>
        <result property="terminalName" column="terminal_name"/>
        <result property="regionalId" column="regional_id"/>
        <result property="regionalName" column="regional_name"/>
        <result property="channelId" column="channel_id"/>
        <result property="channelName" column="channel_name"/>
        <result property="audioFilePath" column="audio_file_path"/>
        <result property="audioFileSize" column="audio_file_size"/>
        <result property="audioFormat" column="audio_format"/>
        <result property="isMatched" column="is_matched"/>
        <result property="matchedText" column="matched_text"/>
        <result property="originalText" column="original_text"/>
        <result property="correctedText" column="corrected_text"/>
        <result property="correctedSaved" column="corrected_saved"/>
        <result property="correctedRecordId" column="corrected_record_id"/>
        <result property="correctedSaveTime" column="corrected_save_time"/>
        <result property="extractedLocation" column="extracted_location"/>
        <result property="extractedQuantity" column="extracted_quantity"/>
        <result property="processingTimeMs" column="processing_time_ms"/>
        <result property="similarityScore" column="similarity_score"/>
        <result property="sourceType" column="source_type"/>
        <result property="locationKeywordId" column="location_keyword_id"/>
        <result property="prohibitedItemKeywordId" column="prohibited_item_keyword_id"/>
        <result property="prohibitedItemCategoryId" column="prohibited_item_category_id"/>
        <result property="checkPointId" column="check_point_id"/>
        <result property="checkPointName" column="check_point_name"/>
        <result property="appEdited" column="app_edited"/>
        <result property="isActiveConcealment" column="is_active_concealment"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectFailedMatchItemVo">
        select id,
               tenant_id,
               revision,
               create_by,
               create_time,
               update_by,
               update_time,
               name,
               code,
               category_code,
               category_name,
               danger_level,
               danger_level_desc,
               user_id,
               user_name,
               position_id,
               position_name,
               full_position_path,
               team_id,
               team_name,
               post_dict_code,
               post_label,
               terminal_id,
               terminal_name,
               regional_id,
               regional_name,
               channel_id,
               channel_name,
               audio_file_path,
               audio_file_size,
               audio_format,
               is_matched,
               matched_text,
               original_text,
               corrected_text,
               corrected_saved,
               corrected_record_id,
               corrected_save_time,
               extracted_location,
               extracted_quantity,
               processing_time_ms,
               similarity_score,
               source_type,
               location_keyword_id,
               prohibited_item_keyword_id,
               prohibited_item_category_id,
               check_point_id,
               check_point_name,
               app_edited,
               is_active_concealment,
               remark
        from failed_match_item
    </sql>

    <select id="selectFailedMatchItemList" parameterType="FailedMatchItem" resultMap="FailedMatchItemResult">
        <include refid="selectFailedMatchItemVo"/>
        <where>
            <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
            <if test="code != null and code != ''">and code = #{code}</if>
            <if test="categoryCode != null and categoryCode != ''">and category_code = #{categoryCode}</if>
            <if test="dangerLevel != null and dangerLevel != ''">and danger_level = #{dangerLevel}</if>
            <if test="userId != null">and user_id = #{userId}</if>
            <if test="userName != null and userName != ''">and user_name like concat('%', #{userName}, '%')</if>
            <if test="positionId != null">and position_id = #{positionId}</if>
            <if test="teamId != null">and team_id = #{teamId}</if>
            <if test="terminalId != null">and terminal_id = #{terminalId}</if>
            <if test="regionalId != null">and regional_id = #{regionalId}</if>
            <if test="channelId != null">and channel_id = #{channelId}</if>
            <if test="sourceType != null and sourceType != ''">and source_type = #{sourceType}</if>
            <if test="appEdited != null">and app_edited = #{appEdited}</if>
        </where>
        order by update_time desc
    </select>

    <select id="selectFailedMatchItemListByUserId" parameterType="Long" resultMap="FailedMatchItemResult">
        <include refid="selectFailedMatchItemVo"/>
        where user_id = #{userId}
        order by update_time desc
    </select>

    <select id="selectFailedMatchItemById" parameterType="Integer" resultMap="FailedMatchItemResult">
        <include refid="selectFailedMatchItemVo"/>
        where id = #{id}
    </select>

    <insert id="insertFailedMatchItem" parameterType="FailedMatchItem" useGeneratedKeys="true" keyProperty="id">
        insert into failed_match_item
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tenantId != null">tenant_id,</if>
            <if test="revision != null">revision,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="code != null and code != ''">code,</if>
            <if test="categoryCode != null and categoryCode != ''">category_code,</if>
            <if test="categoryName != null and categoryName != ''">category_name,</if>
            <if test="dangerLevel != null and dangerLevel != ''">danger_level,</if>
            <if test="dangerLevelDesc != null and dangerLevelDesc != ''">danger_level_desc,</if>
            <if test="userId != null">user_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="positionId != null">position_id,</if>
            <if test="positionName != null">position_name,</if>
            <if test="fullPositionPath != null">full_position_path,</if>
            <if test="teamId != null">team_id,</if>
            <if test="teamName != null">team_name,</if>
            <if test="postDictCode != null">post_dict_code,</if>
            <if test="postLabel != null">post_label,</if>
            <if test="terminalId != null">terminal_id,</if>
            <if test="terminalName != null">terminal_name,</if>
            <if test="regionalId != null">regional_id,</if>
            <if test="regionalName != null">regional_name,</if>
            <if test="channelId != null">channel_id,</if>
            <if test="channelName != null">channel_name,</if>
            <if test="audioFilePath != null">audio_file_path,</if>
            <if test="audioFileSize != null">audio_file_size,</if>
            <if test="audioFormat != null">audio_format,</if>
            <if test="isMatched != null">is_matched,</if>
            <if test="matchedText != null">matched_text,</if>
            <if test="originalText != null">original_text,</if>
            <if test="correctedText != null">corrected_text,</if>
            <if test="correctedSaved != null">corrected_saved,</if>
            <if test="correctedRecordId != null">corrected_record_id,</if>
            <if test="correctedSaveTime != null">corrected_save_time,</if>
            <if test="extractedLocation != null">extracted_location,</if>
            <if test="extractedQuantity != null">extracted_quantity,</if>
            <if test="processingTimeMs != null">processing_time_ms,</if>
            <if test="similarityScore != null">similarity_score,</if>
            <if test="sourceType != null">source_type,</if>
            <if test="locationKeywordId != null">location_keyword_id,</if>
            <if test="prohibitedItemKeywordId != null">prohibited_item_keyword_id,</if>
            <if test="prohibitedItemCategoryId != null">prohibited_item_category_id,</if>
            <if test="checkPointId != null">check_point_id,</if>
            <if test="checkPointName != null">check_point_name,</if>
            <if test="appEdited != null">app_edited,</if>
            <if test="isActiveConcealment != null">is_active_concealment,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tenantId != null">#{tenantId},</if>
            <if test="revision != null">#{revision},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="code != null and code != ''">#{code},</if>
            <if test="categoryCode != null and categoryCode != ''">#{categoryCode},</if>
            <if test="categoryName != null and categoryName != ''">#{categoryName},</if>
            <if test="dangerLevel != null and dangerLevel != ''">#{dangerLevel},</if>
            <if test="dangerLevelDesc != null and dangerLevelDesc != ''">#{dangerLevelDesc},</if>
            <if test="userId != null">#{userId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="positionId != null">#{positionId},</if>
            <if test="positionName != null">#{positionName},</if>
            <if test="fullPositionPath != null">#{fullPositionPath},</if>
            <if test="teamId != null">#{teamId},</if>
            <if test="teamName != null">#{teamName},</if>
            <if test="postDictCode != null">#{postDictCode},</if>
            <if test="postLabel != null">#{postLabel},</if>
            <if test="terminalId != null">#{terminalId},</if>
            <if test="terminalName != null">#{terminalName},</if>
            <if test="regionalId != null">#{regionalId},</if>
            <if test="regionalName != null">#{regionalName},</if>
            <if test="channelId != null">#{channelId},</if>
            <if test="channelName != null">#{channelName},</if>
            <if test="audioFilePath != null">#{audioFilePath},</if>
            <if test="audioFileSize != null">#{audioFileSize},</if>
            <if test="audioFormat != null">#{audioFormat},</if>
            <if test="isMatched != null">#{isMatched},</if>
            <if test="matchedText != null">#{matchedText},</if>
            <if test="originalText != null">#{originalText},</if>
            <if test="correctedText != null">#{correctedText},</if>
            <if test="correctedSaved != null">#{correctedSaved},</if>
            <if test="correctedRecordId != null">#{correctedRecordId},</if>
            <if test="correctedSaveTime != null">#{correctedSaveTime},</if>
            <if test="extractedLocation != null">#{extractedLocation},</if>
            <if test="extractedQuantity != null">#{extractedQuantity},</if>
            <if test="processingTimeMs != null">#{processingTimeMs},</if>
            <if test="similarityScore != null">#{similarityScore},</if>
            <if test="sourceType != null">#{sourceType},</if>
            <if test="locationKeywordId != null">#{locationKeywordId},</if>
            <if test="prohibitedItemKeywordId != null">#{prohibitedItemKeywordId},</if>
            <if test="prohibitedItemCategoryId != null">#{prohibitedItemCategoryId},</if>
            <if test="checkPointId != null">#{checkPointId},</if>
            <if test="checkPointName != null">#{checkPointName},</if>
            <if test="appEdited != null">#{appEdited},</if>
            <if test="isActiveConcealment != null">#{isActiveConcealment},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateFailedMatchItem" parameterType="FailedMatchItem">
        update failed_match_item
        <trim prefix="SET" suffixOverrides=",">
            <if test="tenantId != null">tenant_id = #{tenantId},</if>
            <if test="revision != null">revision = #{revision},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="code != null and code != ''">code = #{code},</if>
            <if test="categoryCode != null and categoryCode != ''">category_code = #{categoryCode},</if>
            <if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
            <if test="dangerLevel != null and dangerLevel != ''">danger_level = #{dangerLevel},</if>
            <if test="dangerLevelDesc != null and dangerLevelDesc != ''">danger_level_desc = #{dangerLevelDesc},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="userName != null">user_name = #{userName},</if>
            <if test="positionId != null">position_id = #{positionId},</if>
            <if test="positionName != null">position_name = #{positionName},</if>
            <if test="fullPositionPath != null">full_position_path = #{fullPositionPath},</if>
            <if test="teamId != null">team_id = #{teamId},</if>
            <if test="teamName != null">team_name = #{teamName},</if>
            <if test="postDictCode != null">post_dict_code = #{postDictCode},</if>
            <if test="postLabel != null">post_label = #{postLabel},</if>
            <if test="terminalId != null">terminal_id = #{terminalId},</if>
            <if test="terminalName != null">terminal_name = #{terminalName},</if>
            <if test="regionalId != null">regional_id = #{regionalId},</if>
            <if test="regionalName != null">regional_name = #{regionalName},</if>
            <if test="channelId != null">channel_id = #{channelId},</if>
            <if test="channelName != null">channel_name = #{channelName},</if>
            <if test="audioFilePath != null">audio_file_path = #{audioFilePath},</if>
            <if test="audioFileSize != null">audio_file_size = #{audioFileSize},</if>
            <if test="audioFormat != null">audio_format = #{audioFormat},</if>
            <if test="isMatched != null">is_matched = #{isMatched},</if>
            <if test="matchedText != null">matched_text = #{matchedText},</if>
            <if test="originalText != null">original_text = #{originalText},</if>
            <if test="correctedText != null">corrected_text = #{correctedText},</if>
            <if test="correctedSaved != null">corrected_saved = #{correctedSaved},</if>
            <if test="correctedRecordId != null">corrected_record_id = #{correctedRecordId},</if>
            <if test="correctedSaveTime != null">corrected_save_time = #{correctedSaveTime},</if>
            <if test="extractedLocation != null">extracted_location = #{extractedLocation},</if>
            <if test="extractedQuantity != null">extracted_quantity = #{extractedQuantity},</if>
            <if test="processingTimeMs != null">processing_time_ms = #{processingTimeMs},</if>
            <if test="similarityScore != null">similarity_score = #{similarityScore},</if>
            <if test="sourceType != null">source_type = #{sourceType},</if>
            <if test="locationKeywordId != null">location_keyword_id = #{locationKeywordId},</if>
            <if test="prohibitedItemKeywordId != null">prohibited_item_keyword_id = #{prohibitedItemKeywordId},</if>
            <if test="prohibitedItemCategoryId != null">prohibited_item_category_id = #{prohibitedItemCategoryId},</if>
            <if test="checkPointId != null">check_point_id = #{checkPointId},</if>
            <if test="checkPointName != null">check_point_name = #{checkPointName},</if>
            <if test="appEdited != null">app_edited = #{appEdited},</if>
            <if test="isActiveConcealment != null">is_active_concealment = #{isActiveConcealment},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFailedMatchItemById" parameterType="Integer">
        delete
        from failed_match_item
        where id = #{id}
    </delete>

    <delete id="deleteFailedMatchItemByIds" parameterType="Integer">
        delete from failed_match_item where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
