<?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.MenuDishesLabelMapper">

    <!-- 根据菜品id获取菜品标签 -->
    <select id="selectListByDishesId" resultType="com.bonus.canteen.core.menu.vo.MenuLabelDishesPageVO">
        select mdl.label_id   labelId,
               mdl.label_name labelName
        from menu_dishes_label mdl
                 left join menu_label_dishes mld on mdl.label_id = mld.label_id
        where mdl.del_flag = #{delFlag}
          and mld.dishes_id = #{dishesId}
    </select>

    <!-- 分页获取标签列表 -->
    <select id="selectAllList" resultType="com.bonus.canteen.core.menu.vo.MenuDishesLabelPageVO">
        select
            label_id labelId,
            label_name labelName,
            crby,
            crtime,
            upby,
            uptime
        from
            menu_dishes_label
        where
            del_flag = #{delFlag}
        <if test="dishesLabelPageDTO.labelId != null">
            and label_id = #{dishesLabelPageDTO.labelId}
        </if>
        <if test="dishesLabelPageDTO.labelName != null and dishesLabelPageDTO.labelName != ''">
            and label_name like #{dishesLabelPageDTO.labelName}
        </if>
        order by
            id desc
    </select>

</mapper>
