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

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.canteen.core.customer.model.CustInfo;
import com.bonus.canteen.core.marketing.vo.MktEffectiveUserVO;
import com.bonus.canteen.core.menu.entity.MenuRecipe;
import com.bonus.canteen.core.menu.vo.AppletRecommendDishesVO;
import com.bonus.canteen.core.menu.vo.AppletReserveRecipeVO;
import com.bonus.canteen.core.menu.vo.AppletWeekRecipeVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface MenuRecipeMapper extends BaseMapper<MenuRecipe> {

   CustInfo selectOrgAndPsnByCustLimitId(CustInfo custInfo);
   List<MktEffectiveUserVO> selectAllUserEff(@Param("effType") Integer effType, @Param("delFlag") Integer delFlag);

   List<AppletWeekRecipeVO> selectWeekRecipe(@Param("applyDate") LocalDate applyDate, @Param("recipeId") Long recipeId, @Param("recipeIdList") List<Long> recipeIdList);

   List<AppletRecommendDishesVO> selectAllRecipeDishesList(@Param("recipeId") Long recipeId, @Param("mealtimeType") Integer mealtimeType);

   List<AppletReserveRecipeVO> selectReserveRecipe(@Param("applyDate") LocalDate applyDate, @Param("recipeId") Long recipeId);

   @Select({"select stall_id from menu_recipe ${ew.customSqlSegment}"})
   Long selectStallIdByWrappers(@Param("ew") Wrapper<MenuRecipe> wrapper);

   @Select({"select mr.stall_id from menu_recipe mr left join menu_recipe_detail mrd on mr.recipe_id = mrd.recipe_id where mrd.detail_id = #{detailId}"})
   Long selectShopstallIdByDetailId(Long detailId);

   @Select({"select recipe_id, recipe_name from menu_recipe ${ew.customSqlSegment}"})
   List<MenuRecipe> selectRecipeNameMap(@Param("ew") Wrapper<MenuRecipe> wrapper);

}
