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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.canteen.core.allocation.canteen.dto.AllocKindDTO;
import com.bonus.canteen.core.allocation.canteen.dto.AllocKindUpdateDTO;
import com.bonus.canteen.core.allocation.canteen.model.AllocKind;
import com.bonus.canteen.core.allocation.canteen.param.AllocOtherPageParam;
import com.bonus.canteen.core.allocation.canteen.service.AllocKindService;
import com.bonus.canteen.core.allocation.canteen.vo.AllocKindVO;
import com.bonus.common.houqin.framework.annotation.RequiresGuest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
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 java.util.List;

@RestController
@RequestMapping({"/api/v2/alloc/kind"})
@Api(
   tags = {"lsh_品类控制器"}
)
public class AllocKindController {
   private static final Logger log = LoggerFactory.getLogger(AllocKindController.class);
   @Autowired
   @Lazy
   private AllocKindService allocKindService;

   @ApiOperation("分页查询品类列表")
   @PostMapping({"/page"})
   @RequiresGuest
   public Page<AllocKindVO> pageKind(@RequestBody AllocOtherPageParam request) {
      return this.allocKindService.pageKind(request);
   }

   @ApiOperation("查询品类列表")
   @PostMapping({"/list-name"})
   public List<AllocKind> listKindName() {
      return this.allocKindService.listKindName();
   }

   @ApiOperation("查询品类名称和图片列表")
   @PostMapping({"/list-name-img"})
   public List<AllocKind> listKindNameImg() {
      return this.allocKindService.listKindNameImg();
   }

   @ApiOperation("新增品类")
   @PostMapping({"/add"})
   public void addKind(@RequestBody AllocKindDTO request) {
      this.allocKindService.addKind(request);
   }

   @ApiOperation("修改品类")
   @PostMapping({"/modify"})
   public void modifyKind(@RequestBody AllocKindUpdateDTO request) {
      this.allocKindService.modifyKind(request);
   }

   @ApiOperation("删除品类")
   @PostMapping({"/remove"})
   public void removeKind(@RequestBody String request) {
      this.allocKindService.removeKind(request);
   }
}
