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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.canteen.core.menu.dto.MenuDishesLabelAddDTO;
import com.bonus.canteen.core.menu.dto.MenuDishesLabelEditDTO;
import com.bonus.canteen.core.menu.service.MenuDishesLabelService;
import com.bonus.canteen.core.menu.vo.MenuDishesLabelPageVO;
import com.bonus.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping({"/api/v1/menudisheslabel"})
@Api(
   value = "menudisheslabel",
   tags = {"pfy_菜品标签基础信息管理"}
)
public class MenuDishesLabelController {
   @Autowired
   @Lazy
   private MenuDishesLabelService menuDishesLabelService;

   @PostMapping({"/add"})
   @ApiOperation("新增菜品标签基础信息")
   public AjaxResult addMenuDishesLabel(@RequestBody @Valid MenuDishesLabelAddDTO dto) {
      this.menuDishesLabelService.addMenuDishesLabel(dto);
      return AjaxResult.success();
   }

   @GetMapping({"/page"})
   @ApiOperation("分页获取菜品标签基础信息")
   public AjaxResult getMenuDishesCookPage(String content) {
      Page<MenuDishesLabelPageVO> resultPage = this.menuDishesLabelService.getMenuMenuDishesLabelPage(content);
      return AjaxResult.success(resultPage);
   }

   @PostMapping({"/edit"})
   @ApiOperation("修改菜品标签基础信息")
   public AjaxResult editMenuDishesLabel(@RequestBody @Valid MenuDishesLabelEditDTO dto) {
      this.menuDishesLabelService.editMenuDishesLabel(dto);
      return AjaxResult.success();
   }

   @PostMapping({"/remove/{labelId}"})
   @ApiOperation("删除菜品标签基础信息")
   public AjaxResult removeByLabelId(@PathVariable Long labelId) {
      this.menuDishesLabelService.removeByLabelId(labelId);
      return AjaxResult.success();
   }
}
