package com.njcn.energy.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.energy.pojo.param.ElDataBindParam;
import com.njcn.energy.pojo.po.EleBind;
import com.njcn.energy.pojo.vo.YunCaiDataVO;
import com.njcn.energy.service.IEleBindService;
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.web.bind.annotation.*;

import java.util.List;

/**
 * pqs
 *
 * @author cdf
 * @date 2022/3/29
 */
@Slf4j
@RestController
@RequestMapping("/bind")
@RequiredArgsConstructor
@Api(tags = "用能组态数据绑定")
public class EleBindController extends BaseController {

    private final IEleBindService iEleBindService;

    @PostMapping("/add")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @ApiOperation("新增绑定关系")
    @ApiImplicitParam(name = "elDataBindParam", value = "绑定信息", required = true)
    public HttpResult add(@RequestBody ElDataBindParam elDataBindParam){
        String methodDescribe = getMethodDescribe("add");

        boolean line = iEleBindService.addBind(elDataBindParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @GetMapping("/list")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @ApiOperation("查询指定网关下的数据绑定关系")
    @ApiImplicitParam(name = "ndid", value = "绑定信息", required = true)
    public HttpResult<List<EleBind>> getList(@RequestParam String ndid){
        String methodDescribe = getMethodDescribe("getList");
        List<EleBind> line = iEleBindService.getList(ndid);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, line, methodDescribe);
    }


    @PostMapping("/getLineListDetail")
    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @ApiOperation("获取指定系统下的数据")
    @ApiImplicitParam(name = "lineList", value = "绑定信息", required = true)
    public HttpResult<List<YunCaiDataVO>> getLineListDetail(@RequestBody List<String> lineList){
        String methodDescribe = getMethodDescribe("getLineListDetail");
        List<YunCaiDataVO> line = iEleBindService.getLineListDetail(lineList);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, line, methodDescribe);
    }




}
