<?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.bonus.canteen.core.cook.mapper.CookRecipeBindAppMapper">
    <resultMap type="com.bonus.canteen.core.cook.domain.CookRecipeBindApp" id="CookRecipeBindAppResult">
        <result property="id"    column="id"    />
        <result property="recipeId"    column="recipe_id"    />
        <result property="bindType"    column="bind_type"    />
        <result property="bindTime"    column="bind_time"    />
        <result property="mealLineId"    column="meal_line_id"    />
        <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>

    <sql id="selectCookRecipeBindAppVo">
        select id, recipe_id, bind_type, bind_time, meal_line_id,
               create_by, create_time, update_by, update_time
        from cook_recipe_bind_app
    </sql>

    <select id="selectCookRecipeBindAppList" parameterType="com.bonus.canteen.core.cook.domain.CookRecipeBindApp" resultMap="CookRecipeBindAppResult">
        <include refid="selectCookRecipeBindAppVo"/>
        <where>  
            <if test="recipeId != null "> and recipe_id = #{recipeId}</if>
            <if test="bindType != null "> and bind_type = #{bindType}</if>
            <if test="bindTime != null "> and bind_time = #{bindTime}</if>
            <if test="mealLineId != null "> and meal_line_id = #{mealLineId}</if>
        </where>
    </select>
    
    <select id="selectCookRecipeBindAppById" parameterType="Long" resultMap="CookRecipeBindAppResult">
        <include refid="selectCookRecipeBindAppVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCookRecipeBindApp" parameterType="com.bonus.canteen.core.cook.domain.CookRecipeBindApp" useGeneratedKeys="true" keyProperty="id">
        insert into cook_recipe_bind_app
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="recipeId != null">recipe_id,</if>
            <if test="bindType != null">bind_type,</if>
            <if test="bindTime != null">bind_time,</if>
            <if test="mealLineId != null">meal_line_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="recipeId != null">#{recipeId},</if>
            <if test="bindType != null">#{bindType},</if>
            <if test="bindTime != null">#{bindTime},</if>
            <if test="mealLineId != null">#{mealLineId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateCookRecipeBindApp" parameterType="com.bonus.canteen.core.cook.domain.CookRecipeBindApp">
        update cook_recipe_bind_app
        <trim prefix="SET" suffixOverrides=",">
            <if test="recipeId != null">recipe_id = #{recipeId},</if>
            <if test="bindType != null">bind_type = #{bindType},</if>
            <if test="bindTime != null">bind_time = #{bindTime},</if>
            <if test="mealLineId != null">meal_line_id = #{mealLineId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCookRecipeBindAppById" parameterType="Long">
        delete from cook_recipe_bind_app where id = #{id}
    </delete>

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