package com.njcn.csdevice.controller.equipment;


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.csdevice.pojo.param.DataArrayParam;
import com.njcn.csdevice.pojo.po.CsDataArray;
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerDetailVO;
import com.njcn.csdevice.service.ICsDataArrayService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 详细数据表 前端控制器
 * </p>
 *
 * @author xuyang
 * @since 2023-05-31
 */
@Slf4j
@RestController
@RequestMapping("/csDataArray")
@Api(tags = "终端详细数据")
@AllArgsConstructor
public class CsDataArrayController extends BaseController {

    private final ICsDataArrayService csDataArrayService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getArrayBySet")
    @ApiOperation("根据数据集获取详细数据")
    @ApiImplicitParam(name = "dataSet", value = "数据集id", required = true)
    public HttpResult<List<CsDataArray>> getArrayBySet(@RequestParam("dataSet") String dataSet){
        String methodDescribe = getMethodDescribe("getArrayBySet");
        List<CsDataArray> list = csDataArrayService.getArrayBySet(dataSet);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getTargetById")
    @ApiOperation("根据数据集获取指标数据")
    @ApiImplicitParam(name = "id", value = "数据集Id", required = true)
    public HttpResult<List<DeviceManagerDetailVO>> getTargetById(@RequestParam("id") String id){
        String methodDescribe = getMethodDescribe("getTargetById");
        List<DeviceManagerDetailVO> list = csDataArrayService.getTargetById(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getDataArray")
    @ApiOperation("获取详细数据")
    @ApiImplicitParam(name = "dataSetList", value = "数据集集合", required = true)
    public HttpResult<List<DataArrayTreeVO>> getDataArray(@RequestBody List<String> dataSetList){
        String methodDescribe = getMethodDescribe("getDataArray");
        List<DataArrayTreeVO> list = csDataArrayService.getDataArray(dataSetList);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getDataArrayById")
    @ApiOperation("获取详细数据(id)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pid", value = "数据集id", required = true),
            @ApiImplicitParam(name = "name", value = "名称", required = true)
    })
    @Deprecated
    public HttpResult<List<CsDataArray>> getDataArrayById(@RequestParam("pid") String pid, @RequestParam("name") String name){
        String methodDescribe = getMethodDescribe("getDataArrayById");
        List<CsDataArray> list = csDataArrayService.getDataArrayById(pid, name);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getDataArrayByIds")
    @ApiOperation("获取详细数据(id)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "数据集id", required = true),
    })
    @Deprecated
    public HttpResult<List<CsDataArray>> getDataArrayByIds(@RequestParam("ids") List<String> ids){
        String methodDescribe = getMethodDescribe("getDataArrayByIds");
        List<CsDataArray> list = csDataArrayService.getDataArrayByIds(ids);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/findListByParam")
    @ApiOperation("根据条件查询详细数据")
    @ApiImplicitParam(name = "param", value = "参数集合", required = true)
    public HttpResult<List<CsDataArray>> findListByParam(@RequestBody DataArrayParam param){
        String methodDescribe = getMethodDescribe("findListByParam");
        List<CsDataArray> list = csDataArrayService.findListByParam(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }

}

