package com.njcn.product.terminal.mysqlTerminal.controller;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.dto.SimpleDTO;
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.product.terminal.mysqlTerminal.pojo.dto.LedgerTreeDTO;
import com.njcn.product.terminal.mysqlTerminal.pojo.enums.StatisticsEnum;
import com.njcn.product.terminal.mysqlTerminal.pojo.param.DeviceInfoParam;
import com.njcn.product.terminal.mysqlTerminal.pojo.vo.TerminalTree;
import com.njcn.product.terminal.mysqlTerminal.service.LineService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: cdf
 * @CreateTime: 2025-08-28
 * @Description:
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "台账树")
@RequestMapping("/terminalTree")
public class LedgerTreeController extends BaseController {

    private final LineService lineService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("获取台账树")
    @GetMapping(value = "/tree")
    public HttpResult<Object> tree() {
        String methodDescribe = getMethodDescribe("tree");
        List<LedgerTreeDTO> treeDTOList = lineService.getTree();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, treeDTOList, methodDescribe);
    }


    /**
     * 获取终端台账设备树
     * @author cdf
     * @date 2021/7/19
     */

    @ApiOperation("获取5层终端树")
    @OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
    @PostMapping("getTerminalTreeForFive")
    @ApiImplicitParam(name = "deviceInfoParam", value = "台账查询参数", required = true)
    public HttpResult<List<TerminalTree>> getTerminalTreeForFive(@RequestBody @Validated DeviceInfoParam deviceInfoParam){
        String methodDescribe = getMethodDescribe("getTerminalTreeForFive");
        SimpleDTO simpleDTO = new SimpleDTO();
        simpleDTO.setCode(StatisticsEnum.POWER_NETWORK.getCode());
        deviceInfoParam.setStatisticalType(simpleDTO);
        List<TerminalTree> tree = lineService.getTerminalTreeForFive(deviceInfoParam);

        return com.njcn.common.utils.HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tree, methodDescribe);
    }




}
