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

    <resultMap type="UiReport" id="UiReportResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="reportType"    column="report_type"    />
        <result property="triggerMode"    column="trigger_mode"    />
        <result property="description"    column="description"    />
        <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="delFlag"    column="del_flag"    />
        <result property="status"    column="status"    />
        <result property="take"    column="take"    />
        <result property="faiiRate"    column="faiI_rate"    />
        <result property="successAssertion"    column="success_assertion"    />
        <result property="scenesNumber"    column="scenes_number"    />
        <result property="scenesSucceedNumber"    column="scenes_succeed_number"    />
        <result property="scenesErrorNumber"    column="scenes_error_number"    />
        <result property="scenesNotNumber"    column="scenes_not_number"    />
        <result property="stepsNumber"    column="steps_number"    />
        <result property="stepsSucceedNumber"    column="steps_succeed_number"    />
        <result property="stepsErrorNumber"    column="steps_error_number"    />
        <result property="stepsNotNumber"    column="steps_not_number"    />
        <result property="consoleStr"    column="console_str"    />
    </resultMap>

    <sql id="selectUiReportVo">
        select id, name, report_type, trigger_mode, description, create_by, create_time, update_by, update_time, del_flag, status, take, faiI_rate, success_assertion, scenes_number, scenes_succeed_number, scenes_error_number, scenes_not_number, steps_number, steps_succeed_number, steps_error_number, steps_not_number,console_str from ui_report
    </sql>


    <select id="selectUiReportList" parameterType="UiReport" resultMap="UiReportResult">
        <include refid="selectUiReportVo"/>
        <where>
            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
            <if test="reportType != null  and reportType != ''">and report_type = #{reportType}</if>
            <if test="triggerMode != null  and triggerMode != ''">and trigger_mode = #{triggerMode}</if>
            <if test="description != null  and description != ''">and description = #{description}</if>
            <if test="status != null ">and status = #{status}</if>
            <if test="delFlag != null ">and del_flag = #{delFlag}</if>
            <if test="take != null  and take != ''"> and take = #{take}</if>
            <if test="faiiRate != null  and faiiRate != ''"> and faiI_rate = #{faiiRate}</if>
            <if test="successAssertion != null  and successAssertion != ''"> and success_assertion = #{successAssertion}</if>
            <if test="scenesNumber != null "> and scenes_number = #{scenesNumber}</if>
            <if test="scenesSucceedNumber != null "> and scenes_succeed_number = #{scenesSucceedNumber}</if>
            <if test="scenesErrorNumber != null "> and scenes_error_number = #{scenesErrorNumber}</if>
            <if test="scenesNotNumber != null "> and scenes_not_number = #{scenesNotNumber}</if>
            <if test="stepsNumber != null "> and steps_number = #{stepsNumber}</if>
            <if test="stepsSucceedNumber != null "> and steps_succeed_number = #{stepsSucceedNumber}</if>
            <if test="stepsErrorNumber != null "> and steps_error_number = #{stepsErrorNumber}</if>
            <if test="stepsNotNumber != null "> and steps_not_number = #{stepsNotNumber}</if>
        </where>
        order by create_time asc
    </select>

    <select id="selectUiReportById" parameterType="Long" resultMap="UiReportResult">
        <include refid="selectUiReportVo"/>
        where id = #{id}
    </select>

    <insert id="insertUiReport" parameterType="UiReport" useGeneratedKeys="true" keyProperty="id">
        insert into ui_report
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="reportType != null">report_type,</if>
            <if test="triggerMode != null">trigger_mode,</if>
            <if test="description != null">description,</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="delFlag != null">del_flag,</if>
            <if test="status != null">status,</if>
            <if test="take != null">take,</if>
            <if test="faiiRate != null">faiI_rate,</if>
            <if test="successAssertion != null">success_assertion,</if>
            <if test="scenesNumber != null">scenes_number,</if>
            <if test="scenesSucceedNumber != null">scenes_succeed_number,</if>
            <if test="scenesErrorNumber != null">scenes_error_number,</if>
            <if test="scenesNotNumber != null">scenes_not_number,</if>
            <if test="stepsNumber != null">steps_number,</if>
            <if test="stepsSucceedNumber != null">steps_succeed_number,</if>
            <if test="stepsErrorNumber != null">steps_error_number,</if>
            <if test="stepsNotNumber != null">steps_not_number,</if>
            <if test="consoleStr != null">console_str,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="reportType != null">#{reportType},</if>
            <if test="triggerMode != null">#{triggerMode},</if>
            <if test="description != null">#{description},</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="delFlag != null">#{delFlag},</if>
            <if test="status != null">#{status},</if>
            <if test="take != null">#{take},</if>
            <if test="faiiRate != null">#{faiiRate},</if>
            <if test="successAssertion != null">#{successAssertion},</if>
            <if test="scenesNumber != null">#{scenesNumber},</if>
            <if test="scenesSucceedNumber != null">#{scenesSucceedNumber},</if>
            <if test="scenesErrorNumber != null">#{scenesErrorNumber},</if>
            <if test="scenesNotNumber != null">#{scenesNotNumber},</if>
            <if test="stepsNumber != null">#{stepsNumber},</if>
            <if test="stepsSucceedNumber != null">#{stepsSucceedNumber},</if>
            <if test="stepsErrorNumber != null">#{stepsErrorNumber},</if>
            <if test="stepsNotNumber != null">#{stepsNotNumber},</if>
            <if test="consoleStr != null">#{consoleStr},</if>
        </trim>
    </insert>

    <update id="updateUiReport" parameterType="UiReport">
        update ui_report
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="reportType != null">report_type = #{reportType},</if>
            <if test="triggerMode != null">trigger_mode = #{triggerMode},</if>
            <if test="description != null">description = #{description},</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="delFlag != null">del_flag = #{delFlag},</if>
            <if test="status != null">status = #{status},</if>
            <if test="take != null">take = #{take},</if>
            <if test="faiiRate != null">faiI_rate = #{faiiRate},</if>
            <if test="successAssertion != null">success_assertion = #{successAssertion},</if>
            <if test="scenesNumber != null">scenes_number = #{scenesNumber},</if>
            <if test="scenesSucceedNumber != null">scenes_succeed_number = #{scenesSucceedNumber},</if>
            <if test="scenesErrorNumber != null">scenes_error_number = #{scenesErrorNumber},</if>
            <if test="scenesNotNumber != null">scenes_not_number = #{scenesNotNumber},</if>
            <if test="stepsNumber != null">steps_number = #{stepsNumber},</if>
            <if test="stepsSucceedNumber != null">steps_succeed_number = #{stepsSucceedNumber},</if>
            <if test="stepsErrorNumber != null">steps_error_number = #{stepsErrorNumber},</if>
            <if test="stepsNotNumber != null">steps_not_number = #{stepsNotNumber},</if>
            <if test="consoleStr != null">console_str = #{consoleStr},</if>
        </trim>
        where id = #{id}
    </update>


    <delete id="deleteUiReportById" parameterType="Long">
        update ui_report set del_flag = 1 where id = #{id}
    </delete>

    <delete id="deleteUiReportByIds" parameterType="String">
        update ui_report set del_flag = 1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>