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

import com.bonus.canteen.core.supply.purchase.domain.param.DrpMarketPricePageDTO;
import com.bonus.canteen.core.supply.purchase.domain.param.DrpMarketPriceCommitDTO;
import com.bonus.canteen.core.supply.purchase.domain.vo.DrpMarketPricePageVO;
import com.bonus.canteen.core.supply.purchase.service.DrpMarketPriceService;
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;

@RestController
@RequestMapping({"/api/v1/DrpMarketPrice"})
@Api(
   value = "市场价格采集"
)
public class DrpMarketPriceController extends BaseController {
   private static final Logger log = LoggerFactory.getLogger(DrpMarketPriceController.class);
   @Autowired
   @Lazy
   private DrpMarketPriceService drpMarketPriceService;

   @PostMapping({"/commit"})
   @ApiOperation("新增采集")
   public AjaxResult commit(@RequestBody @Valid DrpMarketPriceCommitDTO request) {
      return AjaxResult.success(this.drpMarketPriceService.commit(request));
   }

   @PostMapping({"/page"})
   @ApiOperation("分页查询采集价格")
   public TableDataInfo page(@RequestBody @Valid DrpMarketPricePageDTO request) {
      startPage();
      return getDataTable(this.drpMarketPriceService.page(request));
   }

   @PostMapping({"/detail/{id}"})
   @ApiOperation("采集详情")
   public AjaxResult detail(@PathVariable("id") String id) {
      return AjaxResult.success(this.drpMarketPriceService.detail(id));
   }

   @PostMapping({"/remove/{id}"})
   @ApiOperation("删除采集")
   public AjaxResult remove(@PathVariable("id") String id) {
      this.drpMarketPriceService.remove(id);
      return AjaxResult.success();
   }
}
