<?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.ruoyi.project.business.mapper.flow.FlowConfigMapper">

    <resultMap type="FlowConfig" id="FlowConfigResult">
        <result property="id" column="id"/>
        <result property="companyId" column="company_id"/>
        <result property="auditFlow" column="audit_flow"/>
        <result property="flowData" column="flow_data"/>
        <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"/>
    </resultMap>

    <insert id="save" parameterType="FlowConfig">
        insert into flow_config
        (company_id, audit_flow, flow_data, del_flag, create_by, create_time, update_by, update_time)
        values (#{companyId}, #{auditFlow}, #{flowData}, '0', #{createBy}, #{createTime}, #{updateBy}, #{updateTime})
    </insert>

    <select id="getById" resultMap="FlowConfigResult">
        select id, company_id, audit_flow, flow_data
        from flow_config
        where id = #{id}
    </select>

    <select id="get" resultMap="FlowConfigResult">
        select id, company_id, audit_flow, flow_data
        from flow_config
        where company_id = #{companyId}
          and audit_flow = #{auditFlow}
          and del_flag = 0
    </select>

    <update id="remove" parameterType="FlowConfig">
        update flow_config
        set del_flag = 1
        where company_id = #{companyId}
          and audit_flow = #{auditFlow}
          and del_flag = 0
    </update>
</mapper>