package com.njcn.system.controller;


import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.system.pojo.param.CsStatisticalSetAddParam;
import com.njcn.system.pojo.po.CsStatisticalSetPO;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.pojo.vo.CsStatisticalSetVO;
import com.njcn.system.service.CsStatisticalSetPOService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xuyang
 * @since 2023-05-24
 */
@Slf4j
@RestController
@RequestMapping("/csstatisticalset")
@RequiredArgsConstructor
@Api(tags = "绑定指标")
@Validated
public class CsStatisticalSetController extends BaseController {

    private final CsStatisticalSetPOService csStatisticalSetPOService;

    @PostMapping("/addStatistical")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("绑定指标")
    public HttpResult<Boolean> addStatistical(@RequestBody List<CsStatisticalSetAddParam> csStatisticalSetAddParams){
        log.info("根据模板录入字典数据");
        String methodDescribe = getMethodDescribe("addstatistical");
        Boolean result = csStatisticalSetPOService.saveData(csStatisticalSetAddParams);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @PostMapping("/queryStatistical")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("根据统计类型id查询已绑定指标及未绑定数据")
    public HttpResult<CsStatisticalSetVO> queryStatistical(@RequestParam("id")String id){
        log.info("根据模板录入字典数据");
        String methodDescribe = getMethodDescribe("querystatistical");
        CsStatisticalSetVO result = csStatisticalSetPOService.queryStatistical(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @PostMapping("/queryStatisticalSelect")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("根据统计类型id组查询已绑定指标")
    public HttpResult<List<EleEpdPqd>> queryStatisticalSelect(@RequestBody List<String> list){
        log.info("根据模板录入字典数据");
        String methodDescribe = getMethodDescribe("queryStatisticalSelect");
        List<EleEpdPqd> result = csStatisticalSetPOService.queryStatisticalSelect(list);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @PostMapping("/queryStatisticalById")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("根据id查询数据")
    public HttpResult<List<CsStatisticalSetPO>> queryStatisticalById(@RequestBody List<String> list){
        log.info("根据模板录入字典数据");
        String methodDescribe = getMethodDescribe("queryStatisticalById");
        List<CsStatisticalSetPO> result = csStatisticalSetPOService.queryStatisticalById(list);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

}

