package com.zjrs.zwnw.sxgl.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mohrss.leaf.core.framework.persistens.PageResult;
import org.mohrss.leaf.core.framework.web.controller.AjaxResponse;
import com.zjrs.zwnw.sxgl.bpo.SxtjBPO;
import com.zjrs.zwnw.sxgl.dto.SxtjQueryDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;
import java.util.Map;

@Api("事项统计")
@RestController
@RequestMapping("/api/sxgl/sxtj")
public class SxtjController {
    private static final Logger LOG = LoggerFactory.getLogger(SxtjController.class);

    @Resource
    private SxtjBPO sxtjBPO;

    @ApiOperation(value = "事项统计", notes = "事项统计")
    @GetMapping("/getSxtj")
    public AjaxResponse getSxtj(String ssbmmc) {
        LOG.info("获取事项统计数据开始");
        AjaxResponse ajaxResponse = new AjaxResponse();
        try {
            Map<String, Object> result = this.sxtjBPO.getSxtj(ssbmmc);
            ajaxResponse.setData("data", result);
        } catch (Exception e) {
            LOG.error(e.getMessage());
            ajaxResponse.setAppcode("1");
            ajaxResponse.setErrorMsg("系统异常");
        }
        LOG.info("获取事项统计数据结束");
        return ajaxResponse;
    }

    @ApiOperation(value = "查询事项统计结果分页list", notes = "查询事项统计结果分页list")
    @PostMapping("/querySxtjList")
    public AjaxResponse querySxtjList(@RequestBody SxtjQueryDTO dto) {
        LOG.info("查询事项统计结果列表开始");
        AjaxResponse ajaxResponse = new AjaxResponse();
        Integer pagenum = dto.getPagenum();
        Integer pagesize = dto.getPagesize();
        try {
            PageResult pageResult = this.sxtjBPO.querySxtjList(dto, pagenum, pagesize);
            ajaxResponse.setData("data", pageResult);
            ajaxResponse.setData("pagesize", pagesize);
            ajaxResponse.setData("pagenum", pagenum);
        } catch (Exception e) {
            LOG.error(e.getMessage());
            ajaxResponse.setAppcode("1");
            ajaxResponse.setErrorMsg("系统异常");
        }
        LOG.info("查询事项统计结果列表结束");
        return ajaxResponse;
    }
}
