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

import com.bonus.canteen.core.menu.dto.AppletDishesDetailDTO;
import com.bonus.canteen.core.menu.dto.AppletWeekCanteenDTO;
import com.bonus.canteen.core.menu.dto.AppletWeekRecipeDTO;
import com.bonus.canteen.core.menu.service.AppletRecipeH5Service;
import com.bonus.canteen.core.menu.vo.AppletDishesDetailVO;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import java.time.LocalDate;

import static com.bonus.common.core.web.domain.AjaxResult.success;

/**
 * @author xliu
 * @date 2025/4/15 16:31
 */
@RestController
@RequestMapping("/h5/menurecipe")
public class AppletRecipeH5Controller extends BaseController {


    @Resource
    private AppletRecipeH5Service appletRecipeH5Service;


    @PostMapping({"/list/week/canteen"})
    @ApiOperation("获取一周菜谱食堂列表")
    public AjaxResult getWeekMealList(@RequestBody AppletWeekCanteenDTO appletWeekCanteenDTO) {
        try {
//            if (StringUtils.isBlank(String.valueOf(appletWeekCanteenDTO.getUserId()))){
//                return AjaxResult.error("客户id不能为空");
//            }
            return AjaxResult.success(this.appletRecipeH5Service.getWeekMealList(appletWeekCanteenDTO));
        } catch (Exception e) {
            return AjaxResult.error("获取一周菜谱食堂列表失败");
        }
    }


    @ApiOperation("获取一周菜谱详情")
    @GetMapping({"/week/recipe/detail"})
    public TableDataInfo getWeekRecipeDetailList(@Valid AppletWeekRecipeDTO content) {
        try {
            startPage();
            return getDataTable(this.appletRecipeH5Service.getWeekRecipeDetailList(content));
        } catch (Exception e) {
            throw new RuntimeException(e.toString());
        }

    }


    @PostMapping({"/detail"})
    @ApiOperation("根据菜品id获取菜品详情")
    public AjaxResult getRecipeDetail(@RequestBody AppletDishesDetailDTO dto) {
        try {
            AppletDishesDetailVO dishesDetailVO = this.appletRecipeH5Service.getDishesDetailByDishesId(dto);
            return success(dishesDetailVO);
        }catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }



    ///下面是与订餐




}
