package com.nantian.cloud.dbcapp.controller;

import com.nantian.cloud.dbcapp.service.OpsRecordService;
import com.nantian.sc.cloud.common.core.util.R;
import com.nantian.sc.cloud.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@AllArgsConstructor
@RequestMapping("/opsRecord")
@Api(value = "opsRecord", tags = "运维记录")
public class OpsRecordController {

    @Autowired
    private OpsRecordService opsRecordService;

    @GetMapping("/summaryInfo")
    @SysLog("获取汇总表信息（运维记录）")
    @ApiOperation("获取汇总表信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startDate", value = "报告开始时间（如2022-01-01）", required = true, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "endDate", value = "报告结束时间（如2022-01-31）", required = true, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "type", value = "汇总类型（1平台运行至报告截止日期；2报告所属年1月至报告截止日期；3报告期内）", required = true, dataType = "string", paramType = "path"),
    })
    public R getSummaryInfo(String startDate, String endDate, String type){
        return opsRecordService.getSummaryInfo(startDate, endDate, type);
    }

    @GetMapping("/accountInfo")
    @ApiOperation("按月获取登录和活跃账户数据")
    @SysLog("按月获取登录和活跃账户数据（运维记录）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startDate", value = "报告开始时间（如2022-01-01）", required = true, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "endDate", value = "报告结束时间（如2022-01-31）", required = true, dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "type", value = "汇总类型（1平台运行至报告截止日期；2报告所属年1月至报告截止日期；3报告期内）", required = true, dataType = "string", paramType = "path"),
    })
    public R getAccountInfo(String startDate, String endDate, String type){
        return opsRecordService.getAccountInfo(startDate, endDate, type);
    }

}
