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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.canteen.core.menu.dto.MenuDishesStyleAddDTO;
import com.bonus.canteen.core.menu.dto.MenuDishesStyleEditDTO;
import com.bonus.canteen.core.menu.service.MenuDishesStyleService;
import com.bonus.canteen.core.menu.vo.MenuDishesStylePageVO;
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/menudishesstyle"})
@Api(
   value = "menudishesstyle",
   tags = {"gyp_菜系控制器"}
)
public class MenuDishesStyleController {
   @Autowired
   @Lazy
   private MenuDishesStyleService menuDishesStyleService;

   @PostMapping({"/add"})
   @ApiOperation("新增菜系信息")
   public AjaxResult addMenuDishesStyle(@RequestBody @Valid MenuDishesStyleAddDTO content) {
      this.menuDishesStyleService.addMenuDishesStyle(content);
      return AjaxResult.success();
   }

   @GetMapping({"/page"})
   @ApiOperation("分页获取菜系信息")
   public AjaxResult getMenuDishesStylePage(String content) {
      Page<MenuDishesStylePageVO> resultPage = this.menuDishesStyleService.getMenuDishesStylePage(content);
      return AjaxResult.success(resultPage);
   }

   @PostMapping({"/edit"})
   @ApiOperation("修改菜系信息")
   public AjaxResult editMenuDishesStyle(@RequestBody MenuDishesStyleEditDTO content) {
      this.menuDishesStyleService.editMenuDishesStyle(content);
      return AjaxResult.success();
   }

   @PostMapping({"/remove/{styleId}"})
   @ApiOperation("删除菜系信息")
   public AjaxResult removeByStyleId(@PathVariable Long styleId) {
      this.menuDishesStyleService.removeByStyleId(styleId);
      return AjaxResult.success();
   }
}
