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

        <select id="getAllMenuDishesTypeList" resultType="com.bonus.canteen.core.menu.vo.MenuDishesTypeAllVO">
            select type_id, type_name from menu_dishes_type where del_flag = '0'
            order by create_time desc
        </select>

        <select id="selectAllList" resultType="com.bonus.canteen.core.menu.vo.DrpUnitPageVO" parameterType="com.bonus.canteen.core.menu.vo.DrpUnitPageVO">
            select du.unit_id    unitId,
            du.unit_name  unitName,
            du.rate,
            du.weigh_type weighType,
            du.create_by as crby,
            du.create_time as crtime,
            du.update_by as upby,
            du.update_time as uptime,
            du.area_id,
            aa.area_name
            from drp_unit du
            left join alloc_area aa on du.area_id = aa.area_id
            <!--            where du.del_flag = #{delFlag}-->
            where 1=1
            <if test="unitId != null">
                and du.unit_id = #{unitId}
            </if>
            <if test="areaId != null">
                and (du.area_id = #{areaId} or du.area_id is null)
            </if>
            <if test="ifListUse == 1 and areaId == null">
                and du.area_id is null
            </if>
            <!--区域权限-->
            <if test="areaAuth != null and areaAuth.size() > 0">
                and (du.area_id in
                <foreach collection="content.areaAuth" item="areaId" separator="," open="(" close=")">
                    #{areaId}
                </foreach>
                or du.area_id is null )
            </if>
            <if test="unitName != null and unitName != ''">
                and du.unit_name like concat(concat('%', #{unitName}), '%')
            </if>
            order by du.id desc

        </select>
    <select id="checkIsExistRelation" resultType="java.lang.Integer">
        select count(1) from menu_dishes where type_id = #{typeId}
    </select>

    <update id="updateMenuDishesType">
            update menu_dishes_type set type_name = #{typeName} where type_id = #{typeId}
        </update>

        <update id="delMenuDishesType">
            update menu_dishes_type set del_flag = '2' where type_id = #{typeId}
        </update>


</mapper>
