<?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.CookEvaluaPictureMapper">
    <resultMap type="com.bonus.canteen.core.cook.domain.CookEvaluaPicture" id="CookEvaluaPictureResult">
        <result property="id"    column="id"    />
        <result property="evaluaId"    column="evalua_id"    />
        <result property="imgUrl"    column="img_url"    />
        <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="selectCookEvaluaPictureVo">
        select id, evalua_id, img_url, create_by, create_time, update_by, update_time from cook_evalua_picture
    </sql>

    <select id="selectCookEvaluaPictureList" parameterType="com.bonus.canteen.core.cook.domain.CookEvaluaPicture" resultMap="CookEvaluaPictureResult">
        <include refid="selectCookEvaluaPictureVo"/>
        <where>  
            <if test="evaluaId != null "> and evalua_id = #{evaluaId}</if>
            <if test="imgUrl != null  and imgUrl != ''"> and img_url = #{imgUrl}</if>
        </where>
    </select>
    
    <select id="selectCookEvaluaPictureById" parameterType="Long" resultMap="CookEvaluaPictureResult">
        <include refid="selectCookEvaluaPictureVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCookEvaluaPicture" parameterType="com.bonus.canteen.core.cook.domain.CookEvaluaPicture" useGeneratedKeys="true" keyProperty="id">
        insert into cook_evalua_picture
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="evaluaId != null">evalua_id,</if>
            <if test="imgUrl != null and imgUrl != ''">img_url,</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="imgUrl != null and imgUrl != ''">#{imgUrl},</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="updateCookEvaluaPicture" parameterType="com.bonus.canteen.core.cook.domain.CookEvaluaPicture">
        update cook_evalua_picture
        <trim prefix="SET" suffixOverrides=",">
            <if test="evaluaId != null">evalua_id = #{evaluaId},</if>
            <if test="imgUrl != null and imgUrl != ''">img_url = #{imgUrl},</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="deleteCookEvaluaPictureById" parameterType="Long">
        delete from cook_evalua_picture where id = #{id}
    </delete>

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