<?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.siwei.rsmonitoring.mapper.TDkAuditflowStepMapper">
    
    <resultMap type="TDkAuditflowStep" id="TDkAuditflowStepResult">
        <result property="id"    column="id"    />
        <result property="auditflowCode"    column="auditflow_code"    />
        <result property="stepCode"    column="step_code"    />
        <result property="stepValue"    column="step_value"    />
        <result property="sort"    column="sort"    />
        <result property="checkBean"    column="check_bean"    />
        <result property="checkMethod"    column="check_method"    />
        <result property="nextSuccess"    column="next_success"    />
        <result property="nextFull"    column="next_full"    />
        <result property="nextCheck"    column="next_check"    />
        <result property="operationType"    column="operation_type"    />
        <result property="operationState"    column="operation_state"    />
    </resultMap>

    <sql id="selectTDkAuditflowStepVo">
        select id, auditflow_code, step_code, step_value, sort,check_bean,check_method,
               next_success, next_full, operation_type,operation_state,next_check  from t_dk_auditflow_step
    </sql>

    <select id="selectTDkAuditflowStepList" parameterType="TDkAuditflowStep" resultMap="TDkAuditflowStepResult">
        <include refid="selectTDkAuditflowStepVo"/>
        <where>  
            <if test="auditflowCode != null  and auditflowCode != ''"> and auditflow_code = #{auditflowCode}</if>
            <if test="stepCode != null  and stepCode != ''"> and step_code = #{stepCode}</if>
            <if test="stepValue != null  and stepValue != ''"> and step_value = #{stepValue}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="nextCheck != null and nextCheck != '' "> and next_check = #{nextCheck}</if>
        </where>
        order by sort asc
    </select>
    
    <select id="selectTDkAuditflowStepById" parameterType="String" resultMap="TDkAuditflowStepResult">
        <include refid="selectTDkAuditflowStepVo"/>
        where id = #{id}
    </select>

    <insert id="insertTDkAuditflowStep" parameterType="TDkAuditflowStep">
        insert into t_dk_auditflow_step
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">id,</if>
            <if test="auditflowCode != null and auditflowCode != ''">auditflow_code,</if>
            <if test="stepCode != null and stepCode != ''">step_code,</if>
            <if test="stepValue != null">step_value,</if>
            <if test="sort != null">sort,</if>
            <if test="checkBean != null  and checkBean != '' ">check_bean,</if>
            <if test="checkMethod != null  and checkBean != '' ">check_method,</if>
            <if test="nextSuccess != null  and nextSuccess != '' ">next_success,</if>
            <if test="nextFull != null and nextFull != '' ">next_full,</if>
            <if test="operationType != null and operationType != '' ">operation_type,</if>
            <if test="nextCheck != null and nextCheck != '' ">next_check,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">#{id},</if>
            <if test="auditflowCode != null and auditflowCode != ''">#{auditflowCode},</if>
            <if test="stepCode != null and stepCode != ''">#{stepCode},</if>
            <if test="stepValue != null">#{stepValue},</if>
            <if test="sort != null">#{sort},</if>
            <if test="checkBean != null  and checkBean != '' ">#{checkBean},</if>
            <if test="checkMethod != null  and checkMethod != '' ">#{checkMethod},</if>
            <if test="nextOperateData != null  and nextOperateData != '' ">#{nextOperateData},</if>
            <if test="resetPoint != null and resetPoint != '' ">#{resetPoint},</if>
            <if test="nextSuccess != null  and nextSuccess != '' ">#{nextSuccess},</if>
            <if test="nextFull != null and nextFull != '' ">#{nextFull},</if>
            <if test="operationType != null and operationType != '' ">#{operationType},</if>
            <if test="nextCheck != null and nextCheck != '' ">#{nextCheck},</if>
         </trim>
    </insert>

    <update id="updateTDkAuditflowStep" parameterType="TDkAuditflowStep">
        update t_dk_auditflow_step
        <trim prefix="SET" suffixOverrides=",">
            <if test="auditflowCode != null and auditflowCode != ''">auditflow_code = #{auditflowCode},</if>
            <if test="stepCode != null and stepCode != ''">step_code = #{stepCode},</if>
            <if test="stepValue != null">step_value = #{stepValue},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="checkBean != null  and checkBean != '' ">check_bean=#{checkBean},</if>
            <if test="checkMethod != null  and checkMethod != '' ">check_method=#{checkMethod},</if>
            <if test="nextSuccess != null  and nextSuccess != '' ">next_success=#{nextSuccess},</if>
            <if test="nextFull != null and nextFull != '' ">next_full = #{nextFull},</if>
            <if test="operationType != null and operationType != '' ">operation_type = #{operationType},</if>
            <if test="nextCheck != null and nextCheck != '' ">next_check = #{nextCheck},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTDkAuditflowStepById" parameterType="String">
        delete from t_dk_auditflow_step where id = #{id}
    </delete>

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