package com.unis.crk.cplbusiness.controller;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.unis.crk.aop.SystemLog;
import com.unis.crk.cplbusiness.entity.DataCrkywCplpfDefault;
import com.unis.crk.cplbusiness.entity.vo.DataCrkywCplpfDefaultVo;
import com.unis.crk.cplbusiness.entity.vo.DataCrkywCpltzdxxDefaultVo;
import com.unis.crk.cplbusiness.service.IDataCrkywCplpfDefaultService;
import com.unis.crk.cplbusiness.service.IDataCrkywCpltzdxxDefaultService;
import com.unis.crk.utils.ResultUtil;
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.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 成品粮评分 前端控制器
 * </p>
 *
 * @author TangSong
 * @since 2022-04-25
 */
@CrossOrigin
@Api(value = "成品粮评分",tags = {"成品粮评分"})
@RestController
@RequestMapping("dataCrkywCplpfDefault")
public class DataCrkywCplpfDefaultController {

    private final static Logger LOGGER = LoggerFactory.getLogger(DataCrkywCplpfDefaultController.class);


    @Autowired
    private IDataCrkywCplpfDefaultService dataCrkywCplpfDefaultService;
    @Autowired
    private IDataCrkywCpltzdxxDefaultService dataCrkywCpltzdxxDefaultService;

    /**
     * 分页高级查询
     * @return
     */
    @ApiOperation(value="查询", notes="订单分页列表")
    @PostMapping(value="/findPage")
    public ResultUtil findPage(@RequestBody DataCrkywCplpfDefaultVo pageQuery) {
        ResultUtil<IPage<Map<String,Object>>> data = new ResultUtil<>();
        data.success(dataCrkywCplpfDefaultService.findPagepfDefaultVo(pageQuery));
        return data;
    }
    /**
     * 分页高级查询
     * @return
     */
    @ApiOperation(value="查询评分数据", notes="查询评分数据")
    @PostMapping(value="/findPagepf")
    public ResultUtil findPagepf(@RequestBody DataCrkywCplpfDefaultVo pageQuery) {
        ResultUtil<IPage<Map<String,Object>>> data = new ResultUtil<>();
        data.success(dataCrkywCplpfDefaultService.findPagepfDefault(pageQuery));
        return data;
    }

    /**
     * 分页高级查询
     * @return
     */
    @ApiOperation(value="保存修改评分数据", notes="保存修改评分数据")
    @PostMapping(value="/save")
    @SystemLog(module = "成品粮评分", methods = "保存修改",uploadName = "cpl.pf")
    public ResultUtil save(@RequestBody Collection<DataCrkywCplpfDefault> pageQuery) {
        ResultUtil<Boolean> data = new ResultUtil<>();
        boolean b = dataCrkywCplpfDefaultService.saveOrUpdateBatch(pageQuery);

        return data.success(b);
    }
}

