<?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.menu.mapper.MenuEvaluaPictureMapper">
    <resultMap type="com.bonus.canteen.core.menu.domain.MenuEvaluaPicture" id="MenuEvaluaPictureResult">
        <result property="id"    column="id"    />
        <result property="evaluaId"    column="evalua_id"    />
        <result property="pictureUrl"    column="picture_url"    />
        <result property="revision"    column="revision"    />
        <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="selectMenuEvaluaPictureVo">
        select id, evalua_id, picture_url, revision, create_by, create_time, update_by, update_time from menu_evalua_picture
    </sql>

    <select id="selectMenuEvaluaPictureList" parameterType="com.bonus.canteen.core.menu.domain.MenuEvaluaPicture" resultMap="MenuEvaluaPictureResult">
        <include refid="selectMenuEvaluaPictureVo"/>
        <where>  
            <if test="evaluaId != null "> and evalua_id = #{evaluaId}</if>
            <if test="pictureUrl != null  and pictureUrl != ''"> and picture_url = #{pictureUrl}</if>
            <if test="revision != null "> and revision = #{revision}</if>
        </where>
    </select>
    
    <select id="selectMenuEvaluaPictureById" parameterType="Long" resultMap="MenuEvaluaPictureResult">
        <include refid="selectMenuEvaluaPictureVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMenuEvaluaPicture" parameterType="com.bonus.canteen.core.menu.domain.MenuEvaluaPicture" useGeneratedKeys="true" keyProperty="id">
        insert into menu_evalua_picture
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="evaluaId != null">evalua_id,</if>
            <if test="pictureUrl != null and pictureUrl != ''">picture_url,</if>
            <if test="revision != null">revision,</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="evaluaId != null">#{evaluaId},</if>
            <if test="pictureUrl != null and pictureUrl != ''">#{pictureUrl},</if>
            <if test="revision != null">#{revision},</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="updateMenuEvaluaPicture" parameterType="com.bonus.canteen.core.menu.domain.MenuEvaluaPicture">
        update menu_evalua_picture
        <trim prefix="SET" suffixOverrides=",">
            <if test="evaluaId != null">evalua_id = #{evaluaId},</if>
            <if test="pictureUrl != null and pictureUrl != ''">picture_url = #{pictureUrl},</if>
            <if test="revision != null">revision = #{revision},</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="deleteMenuEvaluaPictureById" parameterType="Long">
        delete from menu_evalua_picture where id = #{id}
    </delete>

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