<?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.lz.modules.flow.dao.FlowRelationMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.lz.modules.flow.entity.FlowRelation">
        <id column="id" property="id"/>
        <result column="is_delete" property="isDelete"/>
        <result column="gmt_create" property="gmtCreate"/>
        <result column="gmt_modified" property="gmtModified"/>
        <result column="child" property="child"/>
        <result column="parent" property="parent"/>
        <result column="can_replace" property="canReplace"/>
    </resultMap>


    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, child AS child, parent AS parent, can_replace AS canReplace
    </sql>




    <select id="selectFlowRelationById" resultType="FlowRelation" >
        select * from lz_flow_relation  where id=#{id} and is_delete = 0 limit 1 
    </select>



    <insert id="insertFlowRelation" parameterType="FlowRelation" useGeneratedKeys="true" keyProperty="id" >
        insert into lz_flow_relation(
            <if test="child != null">child, </if>
            <if test="parent != null">parent, </if>
            <if test="canReplace != null">can_replace, </if>
            is_delete,
            gmt_create,
            gmt_modified
        )values(
            <if test="child != null">#{ child}, </if>
            <if test="parent != null">#{ parent}, </if>
            <if test="canReplace != null">#{ canReplace}, </if>
            0,
            now(),
            now()
        )
    </insert>


    <update id="updateFlowRelationById" parameterType="FlowRelation" >
        update
            lz_flow_relation
        <trim prefix="set" suffixOverrides=",">
            <if test="isDelete != null">is_delete = #{isDelete},</if>
            <if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
            <if test="child != null">child = #{child},</if>
            <if test="parent != null">parent = #{parent},</if>
            <if test="canReplace != null">can_replace = #{canReplace}</if>                
        </trim>
        ,gmt_modified = now()
        where id = #{id}
    </update>


    <update id="updateCoverFlowRelationById" parameterType="FlowRelation" >
        update
            lz_flow_relation    
        set     
            is_delete = #{isDelete},
            gmt_create = #{gmtCreate},
            child = #{child},
            parent = #{parent},
            can_replace = #{canReplace}                
        ,gmt_modified = now()
        where id = #{id}
    </update>


    <update id="deleteFlowRelationById" parameterType="java.lang.Long">
        update lz_flow_relation set is_delete = 1 where id=#{id} limit 1  
    </update>



    <select id="selectFlowRelationAll" resultType="com.lz.modules.flow.entity.FlowRelation">
        select * from lz_flow_relation  where  is_delete = 0
    </select>

</mapper>

