<?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.test.test.mapper.UiHighSettingMapper">

    <resultMap type="UiHighSetting" id="UiHighSettingResult">
        <result property="id"    column="id"    />
        <result property="sceneStepsId"    column="scene_steps_id"    />
        <result property="settingType"    column="setting_type"    />
        <result property="name"    column="name"    />
        <result property="operateType"    column="operate_type"    />
        <result property="awateTime"    column="awate_time"    />
        <result property="assertionJson"    column="assertion_json"    />
        <result property="extractionDataJson"    column="extraction_data_json"    />
        <result property="errorHandling"    column="error_handling"    />
        <result property="otherSetting"    column="other_setting"    />
        <result property="orderNumber"    column="order_number"    />
        <result property="isDisabled"    column="is_disabled"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectUiHighSettingVo">
        select id, scene_steps_id, setting_type, name, operate_type, awate_time, assertion_json, extraction_data_json, error_handling, other_setting, order_number, is_disabled, del_flag from ui_high_setting
    </sql>

    <select id="selectUiHighSettingList" parameterType="UiHighSetting" resultMap="UiHighSettingResult">
        <include refid="selectUiHighSettingVo"/>
        <where>
            <if test="sceneStepsId != null "> and scene_steps_id = #{sceneStepsId}</if>
            <if test="settingType != null  and settingType != ''"> and setting_type = #{settingType}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="operateType != null  and operateType != ''"> and operate_type = #{operateType}</if>
            <if test="awateTime != null  and awateTime != ''"> and awate_time = #{awateTime}</if>
            <if test="assertionJson != null  and assertionJson != ''"> and assertion_json = #{assertionJson}</if>
            <if test="extractionDataJson != null  and extractionDataJson != ''"> and extraction_data_json = #{extractionDataJson}</if>
            <if test="errorHandling != null  and errorHandling != ''"> and error_handling = #{errorHandling}</if>
            <if test="otherSetting != null  and otherSetting != ''"> and other_setting = #{otherSetting}</if>
            <if test="orderNumber != null "> and order_number = #{orderNumber}</if>
            <if test="isDisabled != null "> and is_disabled = #{isDisabled}</if>
        </where>
    </select>

    <select id="selectUiHighSettingById" parameterType="Long" resultMap="UiHighSettingResult">
        <include refid="selectUiHighSettingVo"/>
        where scene_steps_id = #{sceneStepsId} and del_flag = 0 order by operate_type asc
    </select>

    <insert id="insertUiHighSetting" parameterType="UiHighSetting" useGeneratedKeys="true" keyProperty="id">
        insert into ui_high_setting
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sceneStepsId != null">scene_steps_id,</if>
            <if test="settingType != null">setting_type,</if>
            <if test="name != null">name,</if>
            <if test="operateType != null">operate_type,</if>
            <if test="awateTime != null">awate_time,</if>
            <if test="assertionJson != null">assertion_json,</if>
            <if test="extractionDataJson != null">extraction_data_json,</if>
            <if test="errorHandling != null">error_handling,</if>
            <if test="otherSetting != null">other_setting,</if>
            <if test="orderNumber != null">order_number,</if>
            <if test="isDisabled != null">is_disabled,</if>
            <if test="delFlag != null">del_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sceneStepsId != null">#{sceneStepsId},</if>
            <if test="settingType != null">#{settingType},</if>
            <if test="name != null">#{name},</if>
            <if test="operateType != null">#{operateType},</if>
            <if test="awateTime != null">#{awateTime},</if>
            <if test="assertionJson != null">#{assertionJson},</if>
            <if test="extractionDataJson != null">#{extractionDataJson},</if>
            <if test="errorHandling != null">#{errorHandling},</if>
            <if test="otherSetting != null">#{otherSetting},</if>
            <if test="orderNumber != null">#{orderNumber},</if>
            <if test="isDisabled != null">#{isDisabled},</if>
            <if test="delFlag != null">#{delFlag},</if>
        </trim>
    </insert>

    <update id="updateUiHighSetting" parameterType="UiHighSetting">
        update ui_high_setting
        <trim prefix="SET" suffixOverrides=",">
            <if test="sceneStepsId != null">scene_steps_id = #{sceneStepsId},</if>
            <if test="settingType != null">setting_type = #{settingType},</if>
            <if test="name != null">name = #{name},</if>
            <if test="operateType != null">operate_type = #{operateType},</if>
            <if test="awateTime != null">awate_time = #{awateTime},</if>
            <if test="assertionJson != null">assertion_json = #{assertionJson},</if>
            <if test="extractionDataJson != null">extraction_data_json = #{extractionDataJson},</if>
            <if test="errorHandling != null">error_handling = #{errorHandling},</if>
            <if test="otherSetting != null">other_setting = #{otherSetting},</if>
            <if test="orderNumber != null">order_number = #{orderNumber},</if>
            <if test="isDisabled != null">is_disabled = #{isDisabled},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUiHighSettingById" parameterType="Long">
        delete from ui_high_setting where scene_steps_id = #{sceneStepsId}
    </delete>

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