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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.canteen.core.menu.domain.MenuMaterial;
import com.bonus.canteen.core.menu.dto.DrpUnitPageDTO;
import com.bonus.canteen.core.menu.dto.MenuDishesTypeAddDTO;
import com.bonus.canteen.core.menu.dto.MenuDishesTypeEditDTO;
import com.bonus.canteen.core.menu.service.MenuDishesTypeService;
import com.bonus.canteen.core.menu.vo.DrpUnitPageVO;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author xliu
 * @date 2025/4/8 19:14
 */
@Api(tags = "商家菜品套餐")
@RestController
@RequestMapping("/menu_material")
public class MenuDishesTypeController extends BaseController {


    @Resource
    private MenuDishesTypeService menuDishesTypeService;

    @ApiOperation(value = "获取所有菜品类别")
    //@PreventRepeatSubmit
    //@RequiresPermissions("menu:material:edit")
    @SysLog(title = "获取所有菜品类别", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->获取所有菜品类")
    @PostMapping("/getAllMenuDishesTypeList")
    public AjaxResult getAllMenuDishesTypeList() {
        try {
            return success(menuDishesTypeService.getAllMenuDishesTypeList());
        } catch (Exception e) {
            return error("系统错误, " + e.getMessage());
        }
    }

    @ApiOperation(value = "新增菜品类别")
    //@PreventRepeatSubmit
    //@RequiresPermissions("menu:material:edit")
    @SysLog(title = "新增菜品类别", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->新增菜品类别")
    @PostMapping("/addMenuDishesType")
    public AjaxResult addMenuDishesType(@RequestBody MenuDishesTypeAddDTO content) {
        try {
            return success(menuDishesTypeService.addMenuDishesType(content));
        } catch (Exception e) {
            return error("系统错误, " + e.getMessage());
        }
    }

    @PostMapping({"/getDrpUnit"})
    @ApiOperation("获取计量单位")
    public AjaxResult getDrpUnitPage(@RequestBody DrpUnitPageDTO dto) {
        List<DrpUnitPageVO> resultPage = menuDishesTypeService.getDrpUnitPage(dto);
        return AjaxResult.success(resultPage);
    }


    @ApiOperation(value = "修改菜品类别")
    @SysLog(title = "修改菜品类别", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改菜品类别")
    @PostMapping("/updateMenuDishesType")
    public AjaxResult updateMenuDishesType(@RequestBody MenuDishesTypeEditDTO content) {
        try {
            return success(menuDishesTypeService.updateMenuDishesType(content));
        } catch (Exception e) {
            return error("系统错误, " + e.getMessage());
        }
    }

    @ApiOperation(value = "删除菜品类别")
    //@PreventRepeatSubmit
    //@RequiresPermissions("menu:material:edit")
    @SysLog(title = "删除菜品类别", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->删除菜品类别")
    @PostMapping("/delMenuDishesType")
    public AjaxResult delMenuDishesType(@RequestBody MenuDishesTypeEditDTO content) {
        try {
            return success(menuDishesTypeService.delMenuDishesType(content));
        } catch (Exception e) {
            return error("系统错误, " + e.getMessage());
        }
    }



}
