package com.njcn.gather.systemops.database.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.systemops.database.pojo.vo.DatabaseOverviewVO;
import com.njcn.gather.systemops.database.service.DatabaseService;
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.RestController;

/**
 * 数据库监控基础接口。
 */
@Slf4j
@Api(tags = "数据库监控")
@RestController
@RequestMapping("/database")
@RequiredArgsConstructor
public class DatabaseController extends BaseController {

    private final DatabaseService databaseService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("查询数据库监控基础信息")
    @GetMapping("/overview")
    public HttpResult<DatabaseOverviewVO> overview() {
        String methodDescribe = getMethodDescribe("overview");
        LogUtil.njcnDebug(log, "{}，开始查询数据库监控基础信息", methodDescribe);
        DatabaseOverviewVO result = databaseService.overview();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
}
