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

import com.bonus.canteen.core.supply.purchase.domain.param.DrpInspectGoodsCommitAddDTO;
import com.bonus.canteen.core.supply.purchase.domain.param.DrpInspectGoodsDetailPageDTO;
import com.bonus.canteen.core.supply.purchase.domain.param.DrpInspectGoodsPageDTO;
import com.bonus.canteen.core.supply.purchase.domain.vo.DrpInspectGoodsAddVO;
import com.bonus.canteen.core.supply.purchase.domain.vo.DrpInspectGoodsDetailPageVO;
import com.bonus.canteen.core.supply.purchase.domain.vo.DrpInspectGoodsPageVO;
import com.bonus.canteen.core.supply.purchase.service.DrpInspectGoodsService;
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.aspectj.weaver.loadtime.Aj;
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 javax.validation.Valid;

@RestController
@RequestMapping({"/api/v2/drp/drp-inspect-goods"})
@Api(
   value = "采购验货",
   tags = {"采购验货"}
)
public class DrpInspectGoodsController extends BaseController {
   private static final Logger log = LoggerFactory.getLogger(DrpInspectGoodsController.class);
   @Autowired
   @Lazy
   private DrpInspectGoodsService drpInspectGoodsService;

   @PostMapping({"/commit"})
   @ApiOperation("新增/编辑提交验货单")
   public AjaxResult addCommitInspectGoods(@RequestBody @Valid DrpInspectGoodsCommitAddDTO content) {
      return AjaxResult.success(this.drpInspectGoodsService.addCommitInspectGoods(content));
   }

   @PostMapping({"/save"})
   @ApiOperation("新增/编辑保存验货单")
   public AjaxResult addSaveInspectGoods(@RequestBody @Valid DrpInspectGoodsCommitAddDTO content) {
     this.drpInspectGoodsService.addSaveInspectGoods(content);
      return AjaxResult.success();
   }

   @PostMapping({"/page"})
   @ApiOperation("分页查询验货单列表")
   public TableDataInfo pageInspectGoods(@RequestBody @Valid DrpInspectGoodsPageDTO content) {
      startPage();
      return getDataTable(this.drpInspectGoodsService.pageInspectGoods(content));
   }

   @PostMapping({"/page-detail"})
   @ApiOperation("分页查询验货单明细")
   public TableDataInfo pageInspectGoodsDetail(@RequestBody @Valid DrpInspectGoodsDetailPageDTO content) {
      startPage();
      return getDataTable(this.drpInspectGoodsService.pageInspectGoodsDetail(content));
   }
}
