package com.jiayue.ipfcst.controller;

import com.jiayue.ipfcst.common.core.web.vo.ResponseVO;
import com.jiayue.ipfcst.service.UploadFileCountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 上报统计restful接口
 *
 * @author yh
 * @version 1.0
 * @since 2019/8/7 10:12
 */
@RestController
@Slf4j
public class UploadFileCountController {
  private final UploadFileCountService uploadFileCountService;
  @Autowired
  public UploadFileCountController(UploadFileCountService uploadFileCountService){
    this.uploadFileCountService = uploadFileCountService;
  }

  @GetMapping(value = "/uploadFileCount/{queryTime}")
  public ResponseVO getUploadFileRate(@PathVariable("queryTime")Long queryTime){
    try {
      Map<String, Object> map = uploadFileCountService.reportingRateCount(queryTime);
      return ResponseVO.success(map);
    }catch (Exception e){
      e.printStackTrace();
      log.error("查询场站信息错误");
      return ResponseVO.fail(e.toString());
    }
  }
}
