<?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.alloc.mapper.AllocCanteenEvaluateMapper">
    <resultMap type="com.bonus.canteen.core.alloc.domain.AllocCanteenEvaluate" id="AllocCanteenEvaluateResult">
        <result property="evaluateId"    column="evaluate_id"    />
        <result property="userId"    column="user_id"    />
        <result property="nickName"    column="nick_name"    />
        <result property="areaId"    column="area_id"    />
        <result property="areaName"    column="area_name"    />
        <result property="canteenId"    column="canteen_id"    />
        <result property="canteenName"    column="canteen_name"    />
        <result property="shopstallId"    column="shopstall_id"    />
        <result property="shopstallName"    column="stall_name"    />
        <result property="evaluateDate"    column="evaluate_date"    />
        <result property="appearance"    column="appearance"    />
        <result property="attitude"    column="attitude"    />
        <result property="taste"    column="taste"    />
        <result property="varieties"    column="varieties"    />
        <result property="hygiene"    column="hygiene"    />
        <result property="price"    column="price"    />
        <result property="weight"    column="weight"    />
        <result property="customize1"    column="customize1"    />
        <result property="customize2"    column="customize2"    />
        <result property="customize3"    column="customize3"    />
        <result property="customizeText1"    column="customize_text1"    />
        <result property="customizeText2"    column="customize_text2"    />
        <result property="proposal"    column="proposal"    />
        <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="selectAllocCanteenEvaluateVo">
        select ace.evaluate_id, ace.user_id, ace.area_id, ace.canteen_id, ace.shopstall_id, ace.evaluate_date, ace.appearance, ace.attitude, ace.taste,
               ace.varieties, ace.hygiene, ace.price, ace.weight, ace.customize1, ace.customize2, ace.customize3, ace.customize_text1,
               ace.customize_text2, ace.proposal, ace.revision, ace.create_by, ace.create_time, ace.update_by, ace.update_time,
               su.nick_name, aa.area_name, ac.canteen_name, ast.stall_name
        from alloc_canteen_evaluate ace
        left join sys_user su on ace.user_id = su.user_id
        left join alloc_area aa on ace.area_id = aa.area_id
        left join alloc_canteen ac on ace.canteen_id = ac.canteen_id
        left join alloc_stall ast on ace.shopstall_id = ast.stall_id
    </sql>

    <select id="selectAllocCanteenEvaluateList" parameterType="com.bonus.canteen.core.alloc.domain.AllocCanteenEvaluate" resultMap="AllocCanteenEvaluateResult">
        <include refid="selectAllocCanteenEvaluateVo"/>
        <where>  
            <if test="userId != null "> and ace.user_id = #{userId}</if>
            <if test="areaId != null "> and ace.area_id = #{areaId}</if>
            <if test="canteenId != null "> and ace.canteen_id = #{canteenId}</if>
            <if test="shopstallId != null "> and ace.shopstall_id = #{shopstallId}</if>
            <if test="evaluateDate != null "> and ace.evaluate_date = #{evaluateDate}</if>
            <if test="appearance != null "> and ace.appearance = #{appearance}</if>
            <if test="attitude != null "> and ace.attitude = #{attitude}</if>
            <if test="taste != null "> and ace.taste = #{taste}</if>
            <if test="varieties != null "> and ace.varieties = #{varieties}</if>
            <if test="hygiene != null "> and ace.hygiene = #{hygiene}</if>
            <if test="price != null "> and ace.price = #{price}</if>
            <if test="weight != null "> and ace.weight = #{weight}</if>
            <if test="customize1 != null "> and ace.customize1 = #{customize1}</if>
            <if test="customize2 != null "> and ace.customize2 = #{customize2}</if>
            <if test="customize3 != null "> and ace.customize3 = #{customize3}</if>
            <if test="customizeText1 != null  and customizeText1 != ''"> and ace.customize_text1 = #{customizeText1}</if>
            <if test="customizeText2 != null  and customizeText2 != ''"> and ace.customize_text2 = #{customizeText2}</if>
            <if test="proposal != null  and proposal != ''"> and ace.proposal = #{proposal}</if>
            <if test="revision != null "> and ace.revision = #{revision}</if>
        </where>
    </select>
    
    <select id="selectAllocCanteenEvaluateByEvaluateId" parameterType="Long" resultMap="AllocCanteenEvaluateResult">
        <include refid="selectAllocCanteenEvaluateVo"/>
        where ace.evaluate_id = #{evaluateId}
    </select>
        
    <insert id="insertAllocCanteenEvaluate" parameterType="com.bonus.canteen.core.alloc.domain.AllocCanteenEvaluate" useGeneratedKeys="true" keyProperty="evaluateId">
        insert into alloc_canteen_evaluate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="areaId != null">area_id,</if>
            <if test="canteenId != null">canteen_id,</if>
            <if test="shopstallId != null">shopstall_id,</if>
            <if test="evaluateDate != null">evaluate_date,</if>
            <if test="appearance != null">appearance,</if>
            <if test="attitude != null">attitude,</if>
            <if test="taste != null">taste,</if>
            <if test="varieties != null">varieties,</if>
            <if test="hygiene != null">hygiene,</if>
            <if test="price != null">price,</if>
            <if test="weight != null">weight,</if>
            <if test="customize1 != null">customize1,</if>
            <if test="customize2 != null">customize2,</if>
            <if test="customize3 != null">customize3,</if>
            <if test="customizeText1 != null">customize_text1,</if>
            <if test="customizeText2 != null">customize_text2,</if>
            <if test="proposal != null">proposal,</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="userId != null">#{userId},</if>
            <if test="areaId != null">#{areaId},</if>
            <if test="canteenId != null">#{canteenId},</if>
            <if test="shopstallId != null">#{shopstallId},</if>
            <if test="evaluateDate != null">#{evaluateDate},</if>
            <if test="appearance != null">#{appearance},</if>
            <if test="attitude != null">#{attitude},</if>
            <if test="taste != null">#{taste},</if>
            <if test="varieties != null">#{varieties},</if>
            <if test="hygiene != null">#{hygiene},</if>
            <if test="price != null">#{price},</if>
            <if test="weight != null">#{weight},</if>
            <if test="customize1 != null">#{customize1},</if>
            <if test="customize2 != null">#{customize2},</if>
            <if test="customize3 != null">#{customize3},</if>
            <if test="customizeText1 != null">#{customizeText1},</if>
            <if test="customizeText2 != null">#{customizeText2},</if>
            <if test="proposal != null">#{proposal},</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="updateAllocCanteenEvaluate" parameterType="com.bonus.canteen.core.alloc.domain.AllocCanteenEvaluate">
        update alloc_canteen_evaluate
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="canteenId != null">canteen_id = #{canteenId},</if>
            <if test="shopstallId != null">shopstall_id = #{shopstallId},</if>
            <if test="evaluateDate != null">evaluate_date = #{evaluateDate},</if>
            <if test="appearance != null">appearance = #{appearance},</if>
            <if test="attitude != null">attitude = #{attitude},</if>
            <if test="taste != null">taste = #{taste},</if>
            <if test="varieties != null">varieties = #{varieties},</if>
            <if test="hygiene != null">hygiene = #{hygiene},</if>
            <if test="price != null">price = #{price},</if>
            <if test="weight != null">weight = #{weight},</if>
            <if test="customize1 != null">customize1 = #{customize1},</if>
            <if test="customize2 != null">customize2 = #{customize2},</if>
            <if test="customize3 != null">customize3 = #{customize3},</if>
            <if test="customizeText1 != null">customize_text1 = #{customizeText1},</if>
            <if test="customizeText2 != null">customize_text2 = #{customizeText2},</if>
            <if test="proposal != null">proposal = #{proposal},</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 evaluate_id = #{evaluateId}
    </update>

    <delete id="deleteAllocCanteenEvaluateByEvaluateId" parameterType="Long">
        delete from alloc_canteen_evaluate where evaluate_id = #{evaluateId}
    </delete>

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