package cn.iocoder.yudao.module.system.dal.mysql.dishes;


import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 菜品管理 Mapper
 *
 * @author 开发账号
 */
@Mapper
public interface DishesMapper extends BaseMapperX<DishesDO> {

    default PageResult<DishesDO> selectPage(DishesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DishesDO>()
                .eqIfPresent(DishesDO::getCarteenId,reqVO.getCarteenId())
                .likeIfPresent(DishesDO::getDishesName, reqVO.getDishesName())
                .eqIfPresent(DishesDO::getDishesImageUrl, reqVO.getDishesImageUrl())
                .eqIfPresent(DishesDO::getDishesAttribute, reqVO.getDishesAttribute())
                .eqIfPresent(DishesDO::getDishesBasePrice, reqVO.getDishesBasePrice())
                .eqIfPresent(DishesDO::getDishesVipBasePrice, reqVO.getDishesVipBasePrice())
                .eqIfPresent(DishesDO::getDishesWeighPrice, reqVO.getDishesWeighPrice())
                .eqIfPresent(DishesDO::getDishesVipWeighPrice, reqVO.getDishesVipWeighPrice())
                .eqIfPresent(DishesDO::getDishecCook, reqVO.getDishecCook())
                .eqIfPresent(DishesDO::getDishecType, reqVO.getDishecType())
                .eqIfPresent(DishesDO::getWeekTime, reqVO.getWeekTime())
                .eqIfPresent(DishesDO::getTimeSlot,reqVO.getTimeSlot())
                .inIfPresent(DishesDO::getWeekTime, reqVO.getWeekTimes())
                .betweenIfPresent(DishesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DishesDO::getId));
    }
    @Select("select b.nickname from member_dining_plates as a INNER JOIN member_user as b on a.user_id=b.id where a.dining_plates_num=#{cId}")
    String selectByCidUserName(@Param("cId") String cId);

    @Select("select name from t_time where #{hour} >= start_time and  #{hour} <= end_time")
    String getTime(@Param("hour") int hour);


}