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

import com.bonus.canteen.core.supply.purchase.domain.param.DrpMaterialSupplierWinRecordsDTO;
import com.bonus.canteen.core.supply.purchase.domain.param.DrpMaterialBidRecordsPageDTO;
import com.bonus.canteen.core.supply.purchase.domain.vo.DrpMaterialStoryBidPriceVO;
import com.bonus.canteen.core.supply.purchase.domain.vo.DrpMaterialSupplierWinRecordsVO;
import com.bonus.canteen.core.supply.purchase.service.DrpMaterialWinBidRecordsService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
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 javax.validation.Valid;
import java.util.List;

@RestController
@Api(
   value = "货品价格"
)
@RequestMapping({"/api/v1/drp/material-win-bid-records"})
public class DrpMaterialWinBidRecordsController extends BaseController {
   private static final Logger log = LoggerFactory.getLogger(DrpMaterialWinBidRecordsController.class);
   @Autowired
   @Lazy
   private DrpMaterialWinBidRecordsService drpMaterialWinBidRecordsService;

   @PostMapping({"/page"})
   @ApiOperation("分页获取原料中标信息")
   public TableDataInfo pageMaterialBidRecords(@RequestBody @Valid DrpMaterialBidRecordsPageDTO request) {
      startPage();
      return getDataTable(this.drpMaterialWinBidRecordsService.pageMaterialBidRecords(request));
   }

   @PostMapping({"/supplier/list"})
   @ApiOperation("获取供应商中标商品价格信息")
   public AjaxResult listSupplierWinRecords(@RequestBody @Valid DrpMaterialSupplierWinRecordsDTO request) {
      return AjaxResult.success(this.drpMaterialWinBidRecordsService.listSupplierWinRecords(request));
   }

   @PostMapping({"/story/bidPrice"})
   @ApiOperation("获取商品历史中标价")
   public DrpMaterialStoryBidPriceVO storyBidPrice(@PathVariable("bidId") Long bidId) {
      return this.drpMaterialWinBidRecordsService.storyBidPrice(bidId);
   }
}
