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

import com.bonus.canteen.core.supply.dto.DrpSupplierScoreHistPageDTO;
import com.bonus.canteen.core.supply.dto.DrpSupplierScorePageDTO;
import com.bonus.canteen.core.supply.dto.DrpSupplierScoreRuleAddDTO;
import com.bonus.canteen.core.supply.service.DrpSupplierScoreRuleService;
import com.bonus.canteen.core.supply.vo.DrpSupplierScoreHistPageVO;
import com.bonus.canteen.core.supply.vo.DrpSupplierScorePageVO;
import com.bonus.canteen.core.supply.vo.DrpSupplierScoreRuleListVO;
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 com.github.pagehelper.page.PageMethod;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;

/**
 * @author xliu
 * @date 2025/5/13 13:06
 */
@Api(tags = "供应商评分")
@RestController
@RequestMapping("/supplier_score_rule")
public class SupplierScoreRuleController extends BaseController {
    @Resource
    private DrpSupplierScoreRuleService drpSupplierScoreRuleService;

    @PostMapping({"/add-or-edit"})
    @ApiOperation("新增/编辑供应商评分规则分数设定")
    public AjaxResult addOrEditSupplierScoreRule(@RequestBody @Valid List<DrpSupplierScoreRuleAddDTO> content) {
        this.drpSupplierScoreRuleService.addOrEditSupplierScoreRule(content);
         return  success();
    }

    @PostMapping({"/list"})
    @ApiOperation("查询供应商评分规则分数设定")
    public AjaxResult listSupplierScoreRule(@RequestBody Long areaId) {
        List<DrpSupplierScoreRuleListVO> resultList = this.drpSupplierScoreRuleService.listSupplierScoreRule(areaId);
        return success(resultList);
    }

    @GetMapping({"/page"})
    @ApiOperation("实时分页查询供应商评分")
    public TableDataInfo pageSupplierScoreRule( DrpSupplierScorePageDTO content) {
        startPage();
        List<DrpSupplierScorePageVO> resultList = this.drpSupplierScoreRuleService.pageSupplierScoreRule(content);
        return getDataTable(resultList);
    }

    @GetMapping({"/hist"})
    @ApiOperation("分页查询供应商历史评分")
    public TableDataInfo pageDrpSupplierScoreHist(DrpSupplierScoreHistPageDTO content) {
        startPage();
        List<DrpSupplierScoreHistPageVO> resultList = this.drpSupplierScoreRuleService.pageDrpSupplierScoreHist(content);;
        return getDataTable(resultList);
    }




}
