package com.njcn.device.pms.controller.ledgerManger;


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.device.pms.pojo.param.SubstationExpendParam;
import com.njcn.device.pms.pojo.po.SubstationRelation;
import com.njcn.device.pms.pojo.vo.SubstationExpendVO;
import com.njcn.device.pms.pojo.vo.SubstationRelationVO;
import com.njcn.device.pms.service.ISubstationRelationService;
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 com.njcn.web.controller.BaseController;


/**
 * <p>
 * 2.电网拓扑图关系表 前端控制器
 * </p>
 *
 * @author zhuxinyu
 * @since 2023-05-08
 */
@Slf4j
@RestController
@RequestMapping("/pms/substationRelation")
@Api(tags = "变电站连接关系")
@RequiredArgsConstructor
public class SubstationRelationController extends BaseController {

    private final ISubstationRelationService substationRelationService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/saveSubstationRelation")
    @ApiOperation("配置变电站拓扑图")
    @ApiImplicitParam(name = "param", value = "配置变电站拓扑图", required = true)
    public HttpResult<Boolean> saveSubstationRelation(@RequestBody SubstationRelation param) {
        String methodDescribe = getMethodDescribe("saveSubstationRelation");
        Boolean result = substationRelationService.saveSubstationRelation(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getRelation")
    @ApiOperation("查询变电站拓扑图")
    @ApiImplicitParam(name = "param", value = "查询变电站拓扑图", required = true)
    public HttpResult<SubstationRelationVO> getRelation(@RequestBody SubstationExpendParam.Relation param) {
        String methodDescribe = getMethodDescribe("getRelation");
        SubstationRelationVO relation = substationRelationService.getRelation(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, relation, methodDescribe);
    }
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/removeRelation")
    @ApiOperation("删除变电站拓扑图")
    @ApiImplicitParam(name = "id", value = "删除变电站拓扑图", required = true)
    public HttpResult<Boolean> removeRelation(@RequestParam String id) {
        String methodDescribe = getMethodDescribe("removeRelation");
        boolean b = substationRelationService.removeById(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, b, methodDescribe);
    }

}

