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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.canteen.core.supply.dto.DrpSupplierQualificationAddDTO;
import com.bonus.canteen.core.supply.dto.DrpSupplierQualificationEditDTO;
import com.bonus.canteen.core.supply.dto.DrpSupplierQualificationExpireVO;
import com.bonus.canteen.core.supply.dto.DrpSupplierQualificationPageDTO;
import com.bonus.canteen.core.supply.service.DrpSupplierQualificationService;
import com.bonus.canteen.core.supply.vo.DrpSupplierQualificationPageVO;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
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.*;

import java.util.List;

@RestController
@RequestMapping({"/api/v1/drpsupplierqualification"})
@Api(
   value = "gyp_供应商资质管理",
   tags = {"gyp_供应商资质管理"}
)
public class SupplierQualificationController extends BaseController {
   private static final Logger log = LoggerFactory.getLogger(SupplierQualificationController.class);
   @Autowired
   @Lazy
   private DrpSupplierQualificationService drpSupplierQualificationService;
//   @Autowired
//   @Lazy
//   private DrpAuthorityApi drpAuthorityApi;

   @PostMapping({"/page"})
   @ApiOperation("分页获取供应商资质")
   public AjaxResult getDrpSupplierQualificationPage(@RequestBody DrpSupplierQualificationPageDTO content) {
      List<DrpSupplierQualificationPageVO> resultPage = this.drpSupplierQualificationService.getDrpSupplierQualificationPage(content);
      return success(resultPage);
   }

   @PostMapping({"/add"})
   @ApiOperation("新增供应商资质")
   public AjaxResult addDrpSupplierQualificationQualification(@RequestBody DrpSupplierQualificationAddDTO content) {
      this.drpSupplierQualificationService.addDrpSupplierQualification(content);
      return success();
   }

   @PostMapping({"/edit"})
   @ApiOperation("修改供应商资质")
   public AjaxResult editDrpSupplierQualification(@RequestBody DrpSupplierQualificationEditDTO content) {
      this.drpSupplierQualificationService.editDrpSupplierQualification(content);
      return success();
   }

   @PostMapping({"/remove/{id}"})
   @ApiOperation("删除供应商资质")
   public AjaxResult removeBySupplierQualificationId(@PathVariable Long id) {
      this.drpSupplierQualificationService.removeBySupplierQualificationId(id);
      return success();
   }

   @PostMapping({"/expire"})
   @ApiOperation("供应商资质到期查询")
   public AjaxResult expire(@RequestBody DrpSupplierQualificationPageDTO content) {
     List<DrpSupplierQualificationExpireVO> page = this.drpSupplierQualificationService.expire(content);
      return success(page);
   }
}
