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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.canteen.core.supply.dto.DrpOrderGoodsPageDTO;
import com.bonus.canteen.core.supply.dto.DrpQuoteAddDTO;
import com.bonus.canteen.core.supply.dto.DrpQuotePageDTO;
import com.bonus.canteen.core.supply.service.DrpSupplierManagementService;
import com.bonus.canteen.core.supply.vo.DrpOrderGoodsPageVO;
import com.bonus.canteen.core.supply.vo.DrpQuotePageVO;
import com.bonus.canteen.core.supply.vo.DrpSupplierPageVO;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.page.TableDataInfo;
import com.github.pagehelper.page.PageMethod;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
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 javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping({"/supplier_management"})
@Api(tags = {"gyp_供应商管理端接口"})
public class SupplierManagementController extends BaseController {
   private static final Logger log = LoggerFactory.getLogger(SupplierManagementController.class);

   @Resource
   private DrpSupplierManagementService drpSupplierManagementService;


   @GetMapping({"/quote/page"})
   @ApiOperation("采购询价-分页查看报价单")
   public TableDataInfo queryInquiry( DrpQuotePageDTO content) {
      startPage();
      List<DrpQuotePageVO> list = this.drpSupplierManagementService.queryInquiry(content);
      return getDataTable(list);
   }

   @GetMapping({"/order-goods/page"})
   @ApiOperation("采购订单-供货商分页查询采购订单")
   public TableDataInfo getDrpOrderGoodsSupplierPage( DrpOrderGoodsPageDTO content) {
      startPage();
      List<DrpOrderGoodsPageVO> drpOrderGoodsList = this.drpSupplierManagementService.getDrpOrderGoodsSupplierList(content);
      return getDataTable(drpOrderGoodsList);
   }


   @PostMapping({"/quote/commit"})
   @ApiOperation("采购询价-提交报价")
   public void commitQuote(@RequestBody DrpQuoteAddDTO content) {
      this.drpSupplierManagementService.commitQuote(content);
   }


   @GetMapping({"/information"})
   @ApiOperation("我的信息")
   public DrpSupplierPageVO information(@Param("supplierId") Long supplierId) {
      return this.drpSupplierManagementService.information(supplierId);
   }

}
