<?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.willalp.canteen.mapper.HsCanteenCuisineMapper">

    <resultMap type="HsCanteenCuisine" id="HsCanteenCuisineResult">
        <result property="cuisineId" column="cuisine_id"/>
        <result property="cuisineNumber" column="cuisine_number"/>
        <result property="cuisineName" column="cuisine_name"/>
        <result property="cuisinePictrue" column="cuisine_pictrue"/>
        <result property="cuisinePrice" column="cuisine_price"/>
        <result property="qybz" column="qybz"/>
        <result property="jgid" column="jgid"/>
        <result property="isDelete" column="is_delete"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectHsCanteenCuisineVo">
        select cuisine_id,
               cuisine_number,
               cuisine_name,
               cuisine_pictrue,
               cuisine_price,
               qybz,
               jgid,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hs_canteen_cuisine
    </sql>

    <select id="selectHsCanteenCuisineList" parameterType="HsCanteenCuisine" resultMap="HsCanteenCuisineResult">
        <include refid="selectHsCanteenCuisineVo"/>
        <where>
            is_delete = 0
            <if test="cuisineNumber != null  and cuisineNumber != ''">and cuisine_number like concat('%',
                #{cuisineNumber}, '%')
            </if>
            <if test="cuisineName != null  and cuisineName != ''">and cuisine_name like concat('%', #{cuisineName},
                '%')
            </if>
            <if test="qybz != null  and qybz != ''">and qybz = #{qybz}</if>
            <if test="jgid !=null and jgid != ''">and jgid = #{jgid}</if>
        </where>
    </select>

    <select id="selectRegList" parameterType="java.util.Map" resultMap="HsCanteenCuisineResult">
        <include refid="selectHsCanteenCuisineVo"/>
        <where>
            is_delete = 0
            <if test="menuNumber != null  and menuNumber != ''">
                and cuisine_number not in (
                select cuisine_number from hs_canteen_menu_register
                where menu_number = #{menuNumber} and is_delete = 0
                )
            </if>
            <if test="jgid != null and jgid != ''">and jgid = #{jgid}</if>
        </where>
    </select>
    <select id="menuItemsWithPictures" resultType="com.willalp.canteen.domain.HsCanteenCuisine">
        SELECT hcc.cuisine_id,
               hcc.cuisine_number,
               hcc.cuisine_name,
               hcc.cuisine_pictrue,
               hcmr.price as cuisine_price,
               hcc.qybz,
               hcc.jgid
        FROM hs_canteen_cuisine hcc,
             hs_canteen_menu_register hcmr
        WHERE hcc.is_delete = 0
          AND hcc.cuisine_number = hcmr.cuisine_number
          AND hcmr.menu_number = #{menuNumber}
          AND hcmr.jgid = #{jgid}
    </select>
</mapper>
