package com.njcn.device.pq.controller;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
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.device.pq.pojo.dto.CvtHarmonicCorrectionFactorsDTO;
import com.njcn.device.pq.pojo.param.CvtHarmonicCorrectionFactorsParam;
import com.njcn.device.pq.pojo.param.CvtLineRelationParam;
import com.njcn.device.pq.pojo.po.CvtHarmonicCorrectionFactors;
import com.njcn.device.pq.pojo.vo.CvtHarmonicCorrectionFactorsVO;
import com.njcn.device.pq.service.CvtHarmonicCorrectionFactorsService;
import com.njcn.device.pq.service.CvtLineRelationService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * Description:
 * Date: 2025/02/11  上午 9:29【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Validated
@Slf4j
@Api(tags = "cvt系数绑定")
@RestController
@RequestMapping("/cvtBind")
@RequiredArgsConstructor
public class CvtLineRelationController extends BaseController {
    private final CvtLineRelationService cvtLineRelationService;
    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @ApiOperation("新增cvt系数绑定")
    @ApiImplicitParam(value = "cvt系数绑定信息",name = "cvtLineRelationParam",required = true)
    @PostMapping("add")
    public HttpResult<Boolean> add(@Validated @RequestBody CvtLineRelationParam cvtLineRelationParam){
        String methodDescribe = getMethodDescribe("add");
        boolean result = cvtLineRelationService.add(cvtLineRelationParam);
        if (result){
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
        } else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
        }
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
    @ApiOperation("根据监测点id查询绑定cvt系数")
    @PostMapping("queryByLineId")
    public HttpResult<CvtHarmonicCorrectionFactorsDTO> queryByLineId(@RequestParam String lineId){
        String methodDescribe = getMethodDescribe("queryByLineId");
        CvtHarmonicCorrectionFactorsDTO result = cvtLineRelationService.queryByLineId(lineId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);

    }
}
