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.MenuNutritionDTO;
import com.bonus.canteen.core.menu.entity.MenuNutrition;
import com.bonus.canteen.core.menu.utils.NutritionEntity;
import com.bonus.canteen.core.menu.vo.MenuInitCategoryVO;
import com.bonus.canteen.core.menu.vo.MenuNutritionAllVO;
import com.bonus.canteen.core.menu.vo.MenuNutritionDetailVO;
import com.bonus.canteen.core.menu.vo.MenuNutritionPageVO;
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 MenuNutritionMapper extends BaseMapper<MenuNutrition> {
   @Select({"select distinct big_type from menu_nutrition"})
   List<String> selectBigTypeList();

   @Select({"select distinct little_type from menu_nutrition where big_type = #{bigType}"})
   List<String> selectLittleTypeList(String bigType);

   List<NutritionEntity> selectNutritionWeightList(Long dishesId);

   @Select({"select distinct big_type, little_type from menu_nutrition"})
   List<MenuInitCategoryVO> selectTypeList();

   @Select({"select nutrition_id, nutrition_name from menu_nutrition ${ew.customSqlSegment}"})
   List<MenuNutritionAllVO> selectAllList(@Param("ew") Wrapper<MenuNutrition> wrapper);

   Page<MenuNutritionPageVO> selectNutritionList(Page<MenuNutritionPageVO> page, @Param("menuNutritionDTO") MenuNutritionDTO menuNutritionDTO);

   @Select({"select nutrition_id from menu_nutrition ${ew.customSqlSegment}"})
   Long selectNutritionIdByWrapper(@Param("ew") Wrapper<MenuNutrition> wrapper);

   MenuNutritionDetailVO selectMenuNutritionDetailById(Long nutritionId);
}
