<?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.basic.mapper.BasicCanteenSuggestionPictureMapper">
    <resultMap type="com.bonus.canteen.core.basic.domain.BasicCanteenSuggestionPicture" id="BasicCanteenSuggestionPictureResult">
        <result property="id"    column="id"    />
        <result property="suggestionId"    column="suggestion_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="selectBasicCanteenSuggestionPictureVo">
        select id, suggestion_id, img_url, create_by, create_time, update_by, update_time from basic_canteen_suggestion_picture
    </sql>

    <select id="selectBasicCanteenSuggestionPictureList" parameterType="com.bonus.canteen.core.basic.domain.BasicCanteenSuggestionPicture" resultMap="BasicCanteenSuggestionPictureResult">
        <include refid="selectBasicCanteenSuggestionPictureVo"/>
        <where>  
            <if test="suggestionId != null "> and suggestion_id = #{suggestionId}</if>
            <if test="imgUrl != null  and imgUrl != ''"> and img_url = #{imgUrl}</if>
        </where>
    </select>
    
    <select id="selectBasicCanteenSuggestionPictureById" parameterType="Long" resultMap="BasicCanteenSuggestionPictureResult">
        <include refid="selectBasicCanteenSuggestionPictureVo"/>
        where id = #{id}
    </select>

    <select id="selectBasicCanteenSuggestionPictureBySuggestionId" parameterType="Long" resultMap="BasicCanteenSuggestionPictureResult">
        <include refid="selectBasicCanteenSuggestionPictureVo"/>
        where suggestion_id = #{suggestionId}
    </select>
        
    <insert id="insertBasicCanteenSuggestionPicture" parameterType="com.bonus.canteen.core.basic.domain.BasicCanteenSuggestionPicture" useGeneratedKeys="true" keyProperty="id">
        insert into basic_canteen_suggestion_picture
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="suggestionId != null">suggestion_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="suggestionId != null">#{suggestionId},</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="updateBasicCanteenSuggestionPicture" parameterType="com.bonus.canteen.core.basic.domain.BasicCanteenSuggestionPicture">
        update basic_canteen_suggestion_picture
        <trim prefix="SET" suffixOverrides=",">
            <if test="suggestionId != null">suggestion_id = #{suggestionId},</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="deleteBasicCanteenSuggestionPictureById" parameterType="Long">
        delete from basic_canteen_suggestion_picture where id = #{id}
    </delete>

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