package com.unis.crk.report.controller;

import com.unis.crk.report.entity.vo.SearchFieldVo;
import com.unis.crk.report.service.IReporterService;
import com.unis.crk.utils.ResultUtil;
import com.unis.crk.violation.service.IViolationWoringService;
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.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * <p>
 * 通用查询
 * </p>
 *
 * @author Wys
 * @since 2021-12-10
 */
@Api(value = "通用查询",tags = {"通用查询"})
@RestController
@RequestMapping("reporter")
@CrossOrigin
public class ReporterController {

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


    @Autowired
    private IReporterService reporterService;

    /**
     * 查询待处理列表数据
     * @return
     */
    @ApiOperation(value="查询", notes="查询报表数据")
    @PostMapping(value="/customReport/{rptid}")
    public ResultUtil customReport(@PathVariable("rptid") String rptid,@RequestBody List<SearchFieldVo> searchFieldVos) {
        ResultUtil<List<Map<String,Object>>> data = new ResultUtil<>();
        data.success(this.reporterService.CustomReport(rptid,searchFieldVos));
        return data;
    }
    /**
     * 查询待处理列表数据
     * @return
     */
    @ApiOperation(value="查询", notes="查询报表数据")
    @PostMapping(value="/customReportOnePage/{rptid}")
    public ResultUtil customReportOnePage(@PathVariable("rptid") String rptid,
                                   @RequestParam(name = "pageSize", required = true) int pageSize,
                                   @RequestParam(name = "pageNum", required = true) int pageNum,
                                   @RequestBody List<SearchFieldVo> searchFieldVos) {
        return this.reporterService.CustomReportOnePage(rptid,pageSize,pageNum,searchFieldVos);
    }
    /**
     * 查询自定义报表动态字段
     * @return
     */
    @ApiOperation(value="查询", notes="查询自定义报表动态字段")
    @PostMapping(value="/customReportDynamicFields/{rptid}")
    public ResultUtil customReportDynamicFields(@PathVariable("rptid") String rptid,@RequestParam("lspz") String lspz) {
        ResultUtil<List<Map<String,Object>>> data = new ResultUtil<>();
        data.success(this.reporterService.CustomReportDynamicFields(rptid,lspz));
        return data;
    }
}

