<?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.iamberry.wechat.service.mapper.AccessFlowMapper">
    <resultMap  id="BaseResultMap" type="AccessFlow" >
        <result    column="flow_id"    property="flowId" />
        <result    column="flow_product_id"    property="flowProductId" />
        <result    column="flow_color_id"    property="flowColorId" />
        <result    column="user_open_id"    property="userOpenId" />
        <result    column="flow_create_date"    property="flowCreateDate" />
    </resultMap>
    <sql    id="Base_List" >
        t.flow_id,
        t.flow_product_id,
        t.flow_color_id,
        t.user_open_id,
        t.flow_create_date
    </sql>
    <select id="getAccessFlowList" resultMap="BaseResultMap" parameterType="AccessFlow" >
        select
        <include refid="Base_List" />
        from tb_iamberry_access_flow t
        <where>
            <if test="flowId != null ">
                AND t.flow_id = #{flowId}
            </if >
            <if test="flowProductId != null ">
                AND t.flow_product_id = #{flowProductId}
            </if >
            <if test="flowColorId != null ">
                AND t.flow_color_id = #{flowColorId}
            </if >
            <if test="userOpenId != null and userOpenId != ''">
                AND t.user_open_id = #{userOpenId}
            </if >
        </where>
    </select>
    <select id="getAccessFlowById" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_access_flow t
        where t.flow_id= #{flowId}
    </select>
    <insert id="save" parameterType="AccessFlow" >
        insert into
        tb_iamberry_access_flow
        (
        flow_product_id,
        flow_color_id,
        user_open_id
        )
        values
        (
        #{flowProductId},
        #{flowColorId},
        #{userOpenId}
        )
    </insert>
    <update id="update" parameterType="AccessFlow" >
        update
        tb_iamberry_access_flow
        <set >
            <if test="flowProductId != null ">
                flow_product_id = #{flowProductId},
            </if >
            <if test="flowColorId != null ">
                flow_color_id = #{flowColorId},
            </if >
            <if test="userOpenId != null and userOpenId != ''">
                user_open_id = #{userOpenId},
            </if >
        </set >
        where flow_id= #{flowId}
    </update>
    <delete id="delete" parameterType="Integer" >
        delete FROM
        tb_iamberry_access_flow
        where flow_id=#{flowId}
    </delete>
</mapper>