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

    <resultMap type="UiSceneSteps" id="UiSceneStepsResult">
        <result property="id" column="id"/>
        <result property="automationId" column="automation_id"/>
        <result property="operateType" column="operate_type"/>
        <result property="name" column="name"/>
        <result property="stepType" column="step_type"/>
        <result property="url" column="url"/>
        <result property="isAppendPage" column="is_append_page"/>
        <result property="operate" column="operate"/>
        <result property="operateObject" column="operate_object"/>
        <result property="operateGroupId" column="operate_group_id"/>
        <result property="operateElementId" column="operate_element_id"/>
        <result property="operateLocType" column="operate_loc_type"/>
        <result property="operateLocValue" column="operate_loc_value"/>
        <result property="clickMethod" column="click_method"/>
        <result property="inputValue" column="Input_value"/>
        <result property="windowSize" column="window_size"/>
        <result property="subOptions" column="sub_options"/>
        <result property="subOptionsValue" column="sub_options_value"/>
        <result property="awaitValue" column="await_value"/>
        <result property="isDisabled" column="is_disabled"/>
        <result property="delFlag" column="del_flag"/>
        <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="orderNumber" column="order_number"/>
        <result property="handleId" column="handle_id"/>
        <result property="pageIndex" column="page_index"/>
        <result property="frameIndex" column="frame_index"/>
        <result property="isEnter" column="is_enter"/>
        <result property="operateWay" column="operate_way"/>
    </resultMap>

    <sql id="selectUiSceneStepsVo">
        select id,
               automation_id,
               operate_type,
               name,
               step_type,
               url,
               is_append_page,
               operate,
               operate_object,
               operate_group_id,
               operate_element_id,
               operate_loc_type,
               operate_loc_value,
               click_method,
               Input_value,
               window_size,
               sub_options,
               sub_options_value,
               await_value,
               is_disabled,
               del_flag,
               create_by,
               create_time,
               update_by,
               update_time,
               order_number,
               handle_id,
               page_index,
               frame_index,
               is_enter,
               operate_way
        from ui_scene_steps
    </sql>

    <select id="selectUiSceneStepsList" parameterType="UiSceneSteps" resultMap="UiSceneStepsResult">
        <include refid="selectUiSceneStepsVo"/>
        <where>
            <if test="automationId != null ">and automation_id = #{automationId}</if>
            <if test="operateType != null  and operateType != ''">and operate_type = #{operateType}</if>
            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
            <if test="stepType != null  and stepType != ''">and step_type = #{stepType}</if>
            <if test="url != null  and url != ''">and url = #{url}</if>
            <if test="isAppendPage != null ">and is_append_page = #{isAppendPage}</if>
            <if test="operate != null ">and operate = #{operate}</if>
            <if test="operateObject != null  and operateObject != ''">and operate_object = #{operateObject}</if>
            <if test="operateGroupId != null ">and operate_group_id = #{operateGroupId}</if>
            <if test="operateElementId != null ">and operate_element_id = #{operateElementId}</if>
            <if test="operateLocType != null  and operateLocType != ''">and operate_loc_type = #{operateLocType}</if>
            <if test="operateLocValue != null  and operateLocValue != ''">and operate_loc_value = #{operateLocValue}
            </if>
            <if test="clickMethod != null  and clickMethod != ''">and click_method = #{clickMethod}</if>
            <if test="inputValue != null  and inputValue != ''">and Input_value = #{inputValue}</if>
            <if test="windowSize != null ">and window_size = #{windowSize}</if>
            <if test="subOptions != null  and subOptions != ''">and sub_options = #{subOptions}</if>
            <if test="subOptionsValue != null  and subOptionsValue != ''">and sub_options_value = #{subOptionsValue}
            </if>
            <if test="awaitValue != null  and awaitValue != ''">and await_value = #{awaitValue}</if>
            <if test="isDisabled != null ">and is_disabled = #{isDisabled}</if>
            <if test="orderNumber != null ">and order_number = #{orderNumber}</if>
            <if test="handleId != null  and handleId != ''">and handle_id = #{handleId}</if>
            <if test="pageIndex != null ">and page_index = #{pageIndex}</if>
            <if test="frameIndex != null ">and frame_index = #{frameIndex}</if>
            <if test="delFlag != null ">and del_flag = #{delFlag}</if>
        </where>
    </select>

    <select id="selectUiSceneStepsById" parameterType="Long" resultMap="UiSceneStepsResult">
        <include refid="selectUiSceneStepsVo"/>
        where automation_id = #{automationId} and del_flag = 0
        order by order_number asc
    </select>

    <insert id="insertUiSceneSteps" parameterType="UiSceneSteps" useGeneratedKeys="true" keyProperty="id">
        insert into ui_scene_steps
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="automationId != null">automation_id,</if>
            <if test="operateType != null">operate_type,</if>
            <if test="name != null">name,</if>
            <if test="stepType != null">step_type,</if>
            <if test="url != null">url,</if>
            <if test="isAppendPage != null">is_append_page,</if>
            <if test="operate != null">operate,</if>
            <if test="operateObject != null">operate_object,</if>
            <if test="operateGroupId != null">operate_group_id,</if>
            <if test="operateElementId != null">operate_element_id,</if>
            <if test="operateLocType != null">operate_loc_type,</if>
            <if test="operateLocValue != null">operate_loc_value,</if>
            <if test="clickMethod != null">click_method,</if>
            <if test="inputValue != null">Input_value,</if>
            <if test="windowSize != null">window_size,</if>
            <if test="subOptions != null">sub_options,</if>
            <if test="subOptionsValue != null">sub_options_value,</if>
            <if test="awaitValue != null">await_value,</if>
            <if test="isDisabled != null">is_disabled,</if>
            <if test="delFlag != null">del_flag,</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="orderNumber != null">order_number,</if>
            <if test="handleId != null">handle_id,</if>
            <if test="pageIndex != null">page_index,</if>
            <if test="frameIndex != null">frame_index,</if>
            <if test="isEnter != null">is_enter,</if>
            <if test="operateWay != null">operate_way,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="automationId != null">#{automationId},</if>
            <if test="operateType != null">#{operateType},</if>
            <if test="name != null">#{name},</if>
            <if test="stepType != null">#{stepType},</if>
            <if test="url != null">#{url},</if>
            <if test="isAppendPage != null">#{isAppendPage},</if>
            <if test="operate != null">#{operate},</if>
            <if test="operateObject != null">#{operateObject},</if>
            <if test="operateGroupId != null">#{operateGroupId},</if>
            <if test="operateElementId != null">#{operateElementId},</if>
            <if test="operateLocType != null">#{operateLocType},</if>
            <if test="operateLocValue != null">#{operateLocValue},</if>
            <if test="clickMethod != null">#{clickMethod},</if>
            <if test="inputValue != null">#{inputValue},</if>
            <if test="windowSize != null">#{windowSize},</if>
            <if test="subOptions != null">#{subOptions},</if>
            <if test="subOptionsValue != null">#{subOptionsValue},</if>
            <if test="awaitValue != null">#{awaitValue},</if>
            <if test="isDisabled != null">#{isDisabled},</if>
            <if test="delFlag != null">#{delFlag},</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="orderNumber != null">#{orderNumber},</if>
            <if test="handleId != null">#{handleId},</if>
            <if test="pageIndex != null">#{pageIndex},</if>
            <if test="frameIndex != null">#{frameIndex},</if>
            <if test="isEnter != null">#{isEnter},</if>
            <if test="operateWay != null">#{operateWay},</if>
        </trim>
    </insert>

    <update id="updateUiSceneSteps" parameterType="UiSceneSteps">
        update ui_scene_steps
        <trim prefix="SET" suffixOverrides=",">
            <if test="automationId != null">automation_id = #{automationId},</if>
            <if test="operateType != null">operate_type = #{operateType},</if>
            <if test="name != null">name = #{name},</if>
            <if test="stepType != null">step_type = #{stepType},</if>
            <if test="url != null">url = #{url},</if>
            <if test="isAppendPage != null">is_append_page = #{isAppendPage},</if>
            <if test="operate != null">operate = #{operate},</if>
            <if test="operateObject != null">operate_object = #{operateObject},</if>
            <if test="operateGroupId != null">operate_group_id = #{operateGroupId},</if>
            <if test="operateElementId != null">operate_element_id = #{operateElementId},</if>
            <if test="operateLocType != null">operate_loc_type = #{operateLocType},</if>
            <if test="operateLocValue != null">operate_loc_value = #{operateLocValue},</if>
            <if test="clickMethod != null">click_method = #{clickMethod},</if>
            <if test="inputValue != null">Input_value = #{inputValue},</if>
            <if test="windowSize != null">window_size = #{windowSize},</if>
            <if test="subOptions != null">sub_options = #{subOptions},</if>
            <if test="subOptionsValue != null">sub_options_value = #{subOptionsValue},</if>
            <if test="awaitValue != null">await_value = #{awaitValue},</if>
            <if test="isDisabled != null">is_disabled = #{isDisabled},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="orderNumber != null">order_number = #{orderNumber},</if>
            <if test="handleId != null">handle_id = #{handleId},</if>
            <if test="pageIndex != null">page_index = #{pageIndex},</if>
            <if test="frameIndex != null">frame_index = #{frameIndex},</if>
            <if test="isEnter != null">is_enter = #{isEnter},</if>
            <if test="operateWay != null">operate_way = #{operateWay},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUiSceneStepsById" parameterType="Long">
        delete
        from ui_scene_steps
        where automation_id = #{automationId}
    </delete>

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