package com.njcn.gather.steady.datavie.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.LogUtil;
import com.njcn.gather.steady.datavie.pojo.vo.SteadyDataViewLedgerNodeVO;
import com.njcn.gather.steady.datavie.service.SteadyDataViewLedgerService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 稳态趋势台账树接口。
 */
@Slf4j
@Api(tags = "稳态趋势台账树")
@RestController
@RequestMapping("/steady/data-view")
@RequiredArgsConstructor
public class SteadyDataViewLedgerController extends BaseController {

    private final SteadyDataViewLedgerService ledgerService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("查询稳态趋势台账树")
    @GetMapping("/ledger-tree")
    public HttpResult<List<SteadyDataViewLedgerNodeVO>> listLedgerTree(@RequestParam(value = "keyword", required = false) String keyword) {
        String methodDescribe = getMethodDescribe("listLedgerTree");
        LogUtil.njcnDebug(log, "{}，开始查询稳态趋势台账树，keyword={}", methodDescribe, keyword);
        List<SteadyDataViewLedgerNodeVO> result = ledgerService.listLedgerTree(keyword);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
}
