From 68a49e074e779e1960f827ff02d69d3b73fa9165 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Thu, 15 Jul 2021 09:13:11 +0800
Subject: [PATCH] web端小时aqi,因子月均值
---
screen-api/src/main/java/com/moral/api/controller/WebController.java | 84 +++++++++++++++++-------------------------
1 files changed, 34 insertions(+), 50 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
index 73a11d1..ae6bf47 100644
--- a/screen-api/src/main/java/com/moral/api/controller/WebController.java
+++ b/screen-api/src/main/java/com/moral/api/controller/WebController.java
@@ -5,78 +5,62 @@
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.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.moral.api.entity.Group;
-import com.moral.api.service.GroupService;
-import com.moral.api.service.UserService;
+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.TokenUtils;
import com.moral.util.WebUtils;
@Slf4j
-@Api(tags = {"������"})
+@Api(tags = {"web���������"})
@RestController
-@RequestMapping("/api")
+@RequestMapping("/web")
public class WebController {
@Autowired
- private UserService userService;
+ private HistoryHourlyService historyHourlyService;
@Autowired
- private GroupService groupService;
+ private HistoryDailyService historyDailyService;
- @ApiOperation(value = "������", notes = "������")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "account", value = "������", required = false, paramType = "query", dataType = "String"),
- @ApiImplicitParam(name = "password", value = "������", required = false, paramType = "query", dataType = "String")
+ @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")
})
- @RequestMapping(value = "login", method = RequestMethod.POST)
- public ResultMessage login(HttpServletRequest request) {
- Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
- if (!(parameters.containsKey("account") && parameters.containsKey("password"))) {
- return ResultMessage.fail("���������������������������������");
+ 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> map = userService.login(parameters);
- if (map.get("token") == null) {
- return ResultMessage.fail(map.get("msg").toString());
- }
- return ResultMessage.ok(map);
+ Map<String, Object> result = historyHourlyService.getHourlyAqiByMac(params.get("mac").toString());
+ return ResultMessage.ok(result);
}
- @ApiOperation(value = "������", notes = "������")
- @RequestMapping(value = "logout", method = RequestMethod.POST)
- public ResultMessage logout(HttpServletRequest request) {
- String userId = request.getHeader("uid");
- String token = request.getHeader("token");
- TokenUtils.destoryToken(userId, token);
- return ResultMessage.ok();
- }
-
- @ApiOperation(value = "���������", notes = "���������")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "groupName", value = "������", required = true, paramType = "query", dataType = "String")
+ @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")
})
- @RequestMapping(value = "addGroup", method = RequestMethod.POST)
- private ResultMessage addGroup(Group group, HttpServletRequest request) {
- String currentUserId = request.getHeader("uid");
- Map<String, Object> map = groupService.addGroup(group, currentUserId);
- String msg = map.get("msg").toString();
- boolean flag = Boolean.parseBoolean(map.get("flag").toString());
- if (flag) {
- return ResultMessage.ok(msg);
+ 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());
}
- return ResultMessage.fail(msg);
+ Map<String, Object> result = historyDailyService.getMonthAvg(params);
+ return ResultMessage.ok(result);
}
}
--
Gitblit v1.8.0