package com.bonus.canteen.core.menu.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.canteen.core.menu.dto.MenuDishesTypePageDTO;
import com.bonus.canteen.core.menu.entity.MenuDishesType;
import com.bonus.canteen.core.menu.vo.MenuDishesTypeAllVO;
import com.bonus.canteen.core.menu.vo.MenuDishesTypePageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MenuDishesTypeMapper extends BaseMapper<MenuDishesType> {
   Page<MenuDishesTypePageVO> selectAllList(Page<MenuDishesType> page,
                                            @Param("dishesTypePageDTO") MenuDishesTypePageDTO dishesTypePageDTO, @Param("delFlag") Integer delFlag);

   @Select({"select type_id from menu_dishes_type where default_flag = #{defaultFlag}"})
   Long selectDefaultTypeId(Integer defaultFlag);

   @Select({"select default_flag from menu_dishes_type where type_id = #{typeId}"})
   Integer selectDefaultFlagByTypeId(Long typeId);

   @Select({"select type_id, type_name from menu_dishes_type ${ew.customSqlSegment}"})
   List<MenuDishesTypeAllVO> selectAllListByWrapper(@Param("ew") Wrapper<MenuDishesType> wrapper);

   @Select({"select type_name from menu_dishes_type where del_flag = 2"})
   List<String> selectDishesTypeNameList();
}
