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

    <resultMap type="PerformanceTest" id="PerformanceTestResult">
        <result property="id"    column="id"    />
        <result property="performanceName"    column="performance_name"    />
        <result property="crontab"    column="crontab"    />
        <result property="crontabStatus"    column="crontab_status"    />
        <result property="concurrentThreads"    column="concurrent_threads"    />
        <result property="errorOperType"    column="error_oper_type"    />
        <result property="executeType"    column="execute_type"    />
        <result property="rampUpSeconds"    column="ramp_up_seconds"    />
        <result property="pressureHour"    column="pressure_hour"    />
        <result property="pressureMinute"    column="pressure_minute"    />
        <result property="pressureSecond"    column="pressure_second"    />
        <result property="loopCount"    column="loop_count"    />
        <result property="rpsStatus"    column="rps_status"    />
        <result property="rpsLimit"    column="rps_limit"    />
        <result property="status"    column="status"    />
        <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"    />
    </resultMap>

    <sql id="selectPerformanceTestVo">
        select id, performance_name, crontab, crontab_status, concurrent_threads, error_oper_type, execute_type, ramp_up_seconds, pressure_hour, pressure_minute, pressure_second, loop_count, rps_status, rps_limit, status, create_by, create_time, update_by, update_time, del_flag from performance_test
    </sql>

    <select id="selectPerformanceTestList" parameterType="PerformanceTest" resultMap="PerformanceTestResult">
        <include refid="selectPerformanceTestVo"/>
        <where>
            <if test="performanceName != null  and performanceName != ''"> and performance_name like concat('%', #{performanceName}, '%')</if>
            <if test="crontab != null  and crontab != ''"> and crontab = #{crontab}</if>
            <if test="crontabStatus != null "> and crontab_status = #{crontabStatus}</if>
            <if test="concurrentThreads != null "> and concurrent_threads = #{concurrentThreads}</if>
            <if test="errorOperType != null "> and error_oper_type = #{errorOperType}</if>
            <if test="executeType != null "> and execute_type = #{executeType}</if>
            <if test="rampUpSeconds != null "> and ramp_up_seconds = #{rampUpSeconds}</if>
            <if test="pressureHour != null "> and pressure_hour = #{pressureHour}</if>
            <if test="pressureMinute != null "> and pressure_minute = #{pressureMinute}</if>
            <if test="pressureSecond != null "> and pressure_second = #{pressureSecond}</if>
            <if test="loopCount != null "> and loop_count = #{loopCount}</if>
            <if test="rpsStatus != null "> and rps_status = #{rpsStatus}</if>
            <if test="rpsLimit != null "> and rps_limit = #{rpsLimit}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="delFlag != null  and delFlag != ''"> and del_flag = #{delFlag}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectPerformanceTestById" parameterType="Long" resultMap="PerformanceTestResult">
        <include refid="selectPerformanceTestVo"/>
        where id = #{id}
    </select>

    <insert id="insertPerformanceTest" parameterType="PerformanceTest" useGeneratedKeys="true" keyProperty="id">
        insert into performance_test
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="performanceName != null and performanceName != ''">performance_name,</if>
            <if test="crontab != null">crontab,</if>
            <if test="crontabStatus != null">crontab_status,</if>
            <if test="concurrentThreads != null">concurrent_threads,</if>
            <if test="errorOperType != null">error_oper_type,</if>
            <if test="executeType != null">execute_type,</if>
            <if test="rampUpSeconds != null">ramp_up_seconds,</if>
            <if test="pressureHour != null">pressure_hour,</if>
            <if test="pressureMinute != null">pressure_minute,</if>
            <if test="pressureSecond != null">pressure_second,</if>
            <if test="loopCount != null">loop_count,</if>
            <if test="rpsStatus != null">rps_status,</if>
            <if test="rpsLimit != null">rps_limit,</if>
            <if test="status != null and status != ''">status,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="delFlag != null and delFlag != ''">del_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="performanceName != null and performanceName != ''">#{performanceName},</if>
            <if test="crontab != null">#{crontab},</if>
            <if test="crontabStatus != null">#{crontabStatus},</if>
            <if test="concurrentThreads != null">#{concurrentThreads},</if>
            <if test="errorOperType != null">#{errorOperType},</if>
            <if test="executeType != null">#{executeType},</if>
            <if test="rampUpSeconds != null">#{rampUpSeconds},</if>
            <if test="pressureHour != null">#{pressureHour},</if>
            <if test="pressureMinute != null">#{pressureMinute},</if>
            <if test="pressureSecond != null">#{pressureSecond},</if>
            <if test="loopCount != null">#{loopCount},</if>
            <if test="rpsStatus != null">#{rpsStatus},</if>
            <if test="rpsLimit != null">#{rpsLimit},</if>
            <if test="status != null and status != ''">#{status},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
        </trim>
    </insert>

    <update id="updatePerformanceTest" parameterType="PerformanceTest">
        update performance_test
        <trim prefix="SET" suffixOverrides=",">
            <if test="performanceName != null and performanceName != ''">performance_name = #{performanceName},</if>
            <if test="crontab != null">crontab = #{crontab},</if>
            <if test="crontabStatus != null">crontab_status = #{crontabStatus},</if>
            <if test="concurrentThreads != null">concurrent_threads = #{concurrentThreads},</if>
            <if test="errorOperType != null">error_oper_type = #{errorOperType},</if>
            <if test="executeType != null">execute_type = #{executeType},</if>
            <if test="rampUpSeconds != null">ramp_up_seconds = #{rampUpSeconds},</if>
            <if test="pressureHour != null">pressure_hour = #{pressureHour},</if>
            <if test="pressureMinute != null">pressure_minute = #{pressureMinute},</if>
            <if test="pressureSecond != null">pressure_second = #{pressureSecond},</if>
            <if test="loopCount != null">loop_count = #{loopCount},</if>
            <if test="rpsStatus != null">rps_status = #{rpsStatus},</if>
            <if test="rpsLimit != null">rps_limit = #{rpsLimit},</if>
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePerformanceTestById" parameterType="Long">
        update performance_test set del_flag = '1' where id = #{id}
    </delete>

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