From 3b29244703787dda85386167dca4126b5b0f150c Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Fri, 16 Jul 2021 13:58:34 +0800
Subject: [PATCH] screen-api 添加查询五分钟数据接口以及查询国控站位置接口
---
screen-api/src/main/java/com/moral/api/controller/WebController.java | 66 +++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/screen-api/src/main/java/com/moral/api/controller/WebController.java b/screen-api/src/main/java/com/moral/api/controller/WebController.java
new file mode 100644
index 0000000..ae6bf47
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/controller/WebController.java
@@ -0,0 +1,66 @@
+package com.moral.api.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.moral.api.service.HistoryDailyService;
+import com.moral.api.service.HistoryHourlyService;
+import com.moral.constant.ResponseCodeEnum;
+import com.moral.constant.ResultMessage;
+import com.moral.util.WebUtils;
+
+@Slf4j
+@Api(tags = {"web���������"})
+@RestController
+@RequestMapping("/web")
+public class WebController {
+
+ @Autowired
+ private HistoryHourlyService historyHourlyService;
+
+ @Autowired
+ private HistoryDailyService historyDailyService;
+
+ @GetMapping("getHourlyAqi")
+ @ApiOperation(value = "���������������AQI", notes = "���������������AQI")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
+ @ApiImplicitParam(name = "mac", value = "������mac", required = true, paramType = "query", dataType = "String")
+ })
+ public ResultMessage getHourlyAqi(HttpServletRequest request) {
+ Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
+ if (!params.containsKey("mac")) {
+ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+ }
+ Map<String, Object> result = historyHourlyService.getHourlyAqiByMac(params.get("mac").toString());
+ return ResultMessage.ok(result);
+ }
+
+ @GetMapping("getMonthAvg")
+ @ApiOperation(value = "������������������������������������", notes = "������������������������������������")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
+ @ApiImplicitParam(name = "mac", value = "������mac", required = true, paramType = "query", dataType = "String"),
+ @ApiImplicitParam(name = "sensorCode", value = "������code", required = true, paramType = "query", dataType = "String")
+ })
+ public ResultMessage getMonthAvg(HttpServletRequest request) {
+ Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
+ if (!params.containsKey("mac") || !params.containsKey("sensorCode")) {
+ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+ }
+ Map<String, Object> result = historyDailyService.getMonthAvg(params);
+ return ResultMessage.ok(result);
+ }
+
+}
--
Gitblit v1.8.0