package com.njcn.csdevice.controller.data;


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.csdevice.param.IcdBzParam;
import com.njcn.csdevice.pojo.po.RStatOnlineRateD;
import com.njcn.csdevice.service.IRStatOnlineRateDService;
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 在线率日表 前端控制器
 * </p>
 *
 * @author xy
 * @since 2025-06-23
 */
@Slf4j
@RestController
@RequestMapping("/rStatOnlineRateD")
@Api(tags = "终端在线率接口")
@AllArgsConstructor
public class RStatOnlineRateDController extends BaseController {

    private final IRStatOnlineRateDService rStatOnlineRateDService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/add")
    @ApiOperation("新增终端在线率(可根据时间段进行补召)")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    public HttpResult<String> addData(@RequestBody @Validated StatisticsDataParam param){
        String methodDescribe = getMethodDescribe("addData");
        rStatOnlineRateDService.addData(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/list")
    @ApiOperation("获取数据")
    public HttpResult<List<RStatOnlineRateD>> list(@RequestBody @Validated IcdBzParam param){
        String methodDescribe = getMethodDescribe("list");
        List<RStatOnlineRateD> result = rStatOnlineRateDService.getData(param.getLineList(),param.getStartTime(),param.getEndTime());
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

}

