From 8bb0e02e8fd166f35782870983fd2140142df409 Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Mon, 30 Nov 2020 15:52:12 +0800
Subject: [PATCH] 获取账户地图信息添加权限校验
---
src/main/java/com/moral/controller/WebController.java | 171 +++++++++++++++++++++++++-------------------------------
1 files changed, 76 insertions(+), 95 deletions(-)
diff --git a/src/main/java/com/moral/controller/WebController.java b/src/main/java/com/moral/controller/WebController.java
index 6cdf281..11b9b2d 100644
--- a/src/main/java/com/moral/controller/WebController.java
+++ b/src/main/java/com/moral/controller/WebController.java
@@ -44,6 +44,7 @@
AccountService accountService;
@Resource
DictionaryDataService dictionaryDataService;
+ @Resource
OrganizationService organizationService;
@Resource
WebTokenService webTokenService;
@@ -67,17 +68,35 @@
@GetMapping("test")
public ResultBean<List<WebProvince>> add(HttpServletRequest request) {
- String token = request.getHeader("token");
+ String token = request.getHeader("token");
List<WebProvince> mapPath = mapPathService.getMapPath(token);
- if(ObjectUtils.isEmpty(mapPath))
- return new ResultBean<>("������������������������",ResultBean.FAIL);
+ if (ObjectUtils.isEmpty(mapPath))
+ return new ResultBean<>("������������������������", ResultBean.FAIL);
+ return new ResultBean<>(mapPath);
+ }
+
+ @GetMapping("redisTest")
+ public ResultBean<List<WebProvince>> redisTest(HttpServletRequest request) {
+ String token = request.getHeader("token");
+ List<WebProvince> mapPath = mapPathService.getMapPath(token);
+ if (ObjectUtils.isEmpty(mapPath))
+ return new ResultBean<>("������������������������", ResultBean.FAIL);
+ return new ResultBean<>(mapPath);
+ }
+
+ @GetMapping("sqlTest")
+ public ResultBean<List<WebProvince>> sqlTest(HttpServletRequest request) {
+ String token = request.getHeader("token");
+ List<WebProvince> mapPath = mapPathService.getMapPathTest(token);
+ if (ObjectUtils.isEmpty(mapPath))
+ return new ResultBean<>("������������������������", ResultBean.FAIL);
return new ResultBean<>(mapPath);
}
/**
* @Description: ������������
* @Param: [parameters]
- * @return: java.util.Map<java.lang.String , java.lang.Object>
+ * @return: java.util.Map<java.lang.String , java.lang.Object>
* @Author: ������������
* @Date: 2020/10/19
*/
@@ -101,7 +120,7 @@
/**
* @Description: ������������
* @Param: [request]
- * @return: java.util.Map<java.lang.String , java.lang.Object>
+ * @return: java.util.Map<java.lang.String , java.lang.Object>
* @Author: ������������
* @Date: 2020/10/19
*/
@@ -116,13 +135,7 @@
return resultMap;
}
- /**
- * @Description:
- * @Param: [request]
- * @return: java.util.Map<java.lang.String , java.lang.Object>
- * @Author: ������������
- * @Date: 2020/10/19
- */
+
@UserLoginToken
@GetMapping("getAccountInfo")
public Map<String, Object> getAccountInfo(HttpServletRequest request) {
@@ -134,48 +147,9 @@
throw new WebAuthException("401,token������");
}
Map<String, Object> resultMap = accountService.getAccountInfoById(id);
- Object orgId = resultMap.get("orgId");
- if (resultMap.get("orgId") != null && resultMap.get("orgId") instanceof Integer) {
- StringBuilder areaNamesBuilder = new StringBuilder("������");
- //���������������������������������
- if (!((Integer) orgId).equals(dictionaryDataService.querySupperOrgId())) {
- //���������������������������������������������������
- Organization organization = organizationService.getOrganizationById((Integer) orgId);
- if (organization.getAreaNames() != null) {
- Map<String, String> areaNameMap = BeanUtils.beanToMap(organization.getAreaNames());
- List<String> names = areaNameMap.entrySet().stream().filter(item -> {
- return item.getValue() != null;
- }).map(item -> {
- return item.getValue();
- }).collect(Collectors.toList());
- AreaNames areaNames = organization.getAreaNames();
- areaNamesBuilder.append("/");
- areaNamesBuilder.append(String.join("/", names));
- }
- // ������������
- if (organization.getRank() != null && organization.getRank() == 0) {
- resultMap.put("type", "enterprise");
- } else {
- resultMap.put("type", "government");
- }
- Number mapAreaCode = null;
- if (organization.getVillageCode() != null) {
- mapAreaCode = organization.getVillageCode();
- } else if (organization.getTownCode() != null) {
- mapAreaCode = organization.getTownCode();
- } else if (organization.getAreaCode() != null) {
- mapAreaCode = organization.getAreaCode();
- } else if (organization.getCityCode() != null) {
- mapAreaCode = organization.getCityCode();
- } else if (organization.getProvinceCode() != null) {
- mapAreaCode = organization.getProvinceCode();
- }
- resultMap.put("mapAreaCode", mapAreaCode.toString());
- }
- resultMap.put("mapPath", areaNamesBuilder.toString());
- String accountId = String.valueOf(resultMap.get("accountId"));
- resultMap.put("token", webTokenService.getToken(accountId));
- }
+ String accountId = String.valueOf(resultMap.get("accountId"));
+ resultMap.put("token", webTokenService.getToken(accountId));
+
return resultMap;
}
@@ -183,7 +157,7 @@
/**
* @Description: ������������������������
* @Param: [request]
- * @return: com.moral.common.bean.ResultBean<java.util.List < java.util.Map < java.lang.String , java.lang.Object>>>
+ * @return: com.moral.common.bean.ResultBean<java.util.List < java.util.Map < java.lang.String , java.lang.Object>>>
* @Author: ������������
* @Date: 2020/10/19
*/
@@ -212,7 +186,7 @@
/**
* @Description: ������������������������������
* @Param: [request]
- * @return: com.moral.common.bean.ResultBean<java.util.List < com.moral.entity.MonitorPoint>>
+ * @return: com.moral.common.bean.ResultBean<java.util.List < com.moral.entity.MonitorPoint>>
* @Author: ������������
* @Date: 2020/10/19
*/
@@ -228,7 +202,7 @@
/**
* @Description: ���������������������������������������
* @Param: [request]
- * @return: com.moral.common.bean.ResultBean<java.util.List < com.moral.entity.Device>>
+ * @return: com.moral.common.bean.ResultBean<java.util.List < com.moral.entity.Device>>
* @Author: ������������
* @Date: 2020/10/19
*/
@@ -243,13 +217,13 @@
/**
* @Description: ������monitorId���������������������������������������������������������������������
* @Param: []
- * @return: com.moral.common.bean.ResultBean<java.util.Map < java.lang.String , java.lang.Object>>
+ * @return: com.moral.common.bean.ResultBean<java.util.Map < java.lang.String , java.lang.Object>>
* @Author: ������������
* @Date: 2020/10/19
*/
@GetMapping("fiveMinuteAvgData")
- public ResultBean<Map<String,Object>> getSensorFiveMinuteAvgData(HttpServletRequest request) {
+ public ResultBean<Map<String, Object>> getSensorFiveMinuteAvgData(HttpServletRequest request) {
//���������������������������monitorpointId
Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
if ((!parameters.containsKey("sensorKey")) || (!parameters.containsKey("monitorPointId")))
@@ -284,30 +258,30 @@
datas = insertDeviceInfo(datas, devices);
//������monitorPointId���������������������
- List<Map<String,Object>> coordinate = new ArrayList<>();
+ List<Map<String, Object>> coordinate = new ArrayList<>();
MonitorPoint monitorPoint = monitorPointService.queryMonitorPointById(monitorPointId);
Integer orgId = monitorPoint.getOrganizationId();
List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByOrganizationId(orgId);
- monitorPoints.forEach(value->{
- if("���������".equals(value.getDescription())) {
+ monitorPoints.forEach(value -> {
+ if ("���������".equals(value.getDescription())) {
List list = LatLngTransformation.Convert_BD09_To_GCJ02(value.getLatitude(), value.getLongitude());
- Map<String,Object> controlStation = new HashMap<>();
- controlStation.put("name",value.getName());
+ Map<String, Object> controlStation = new HashMap<>();
+ controlStation.put("name", value.getName());
controlStation.put("longitude", list.get(0));
controlStation.put("latitude", list.get(1));
coordinate.add(controlStation);
}
});
- Map<String,Object> datasMap = new HashMap<>();
- datasMap.put("coordinate",coordinate);
- datasMap.put("device",datas);
+ Map<String, Object> datasMap = new HashMap<>();
+ datasMap.put("coordinate", coordinate);
+ datasMap.put("device", datas);
- return new ResultBean<Map<String,Object>>(datasMap);
+ return new ResultBean<Map<String, Object>>(datasMap);
}
@GetMapping("cangzhouMIdGetAllDevice")
- public ResultBean<Map<String,Object>> cangzhouMIdGetAllDevice(HttpServletRequest request) {
+ public ResultBean<Map<String, Object>> cangzhouMIdGetAllDevice(HttpServletRequest request) {
//���������������������������monitorpointId
Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
if ((!parameters.containsKey("sensorKey")) || (!parameters.containsKey("monitorPointId")))
@@ -317,10 +291,10 @@
MonitorPoint mPoint = monitorPointService.queryMonitorPointById(monitorPointId);
Integer code = mPoint.getCityCode();
List<Device> devices = null;
- if (code == 130900){
- devices = deviceService.getDeviceByCode();
- }else {
- devices = deviceService.getDevicesByMonitorPointId(monitorPointId);
+ if (code == 130900) {
+ devices = deviceService.getDeviceByCode();
+ } else {
+ devices = deviceService.getDevicesByMonitorPointId(monitorPointId);
}
//������monitorpointId������������������������������mac������
if (ObjectUtils.isEmpty(devices))
@@ -348,35 +322,35 @@
datas = insertDeviceInfo(datas, devices);
//������monitorPointId���������������������
- List<Map<String,Object>> coordinate = new ArrayList<>();
+ List<Map<String, Object>> coordinate = new ArrayList<>();
MonitorPoint monitorPoint = monitorPointService.queryMonitorPointById(monitorPointId);
Integer orgId = monitorPoint.getOrganizationId();
List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByOrganizationId(orgId);
- monitorPoints.forEach(value->{
- if("���������".equals(value.getDescription())) {
+ monitorPoints.forEach(value -> {
+ if ("���������".equals(value.getDescription())) {
List list = LatLngTransformation.Convert_BD09_To_GCJ02(value.getLatitude(), value.getLongitude());
- Map<String,Object> controlStation = new HashMap<>();
- controlStation.put("name",value.getName());
+ Map<String, Object> controlStation = new HashMap<>();
+ controlStation.put("name", value.getName());
controlStation.put("longitude", list.get(0));
controlStation.put("latitude", list.get(1));
coordinate.add(controlStation);
}
});
- Map<String,Object> datasMap = new HashMap<>();
- datasMap.put("coordinate",coordinate);
- datasMap.put("device",datas);
+ Map<String, Object> datasMap = new HashMap<>();
+ datasMap.put("coordinate", coordinate);
+ datasMap.put("device", datas);
- return new ResultBean<Map<String,Object>>(datasMap);
+ return new ResultBean<Map<String, Object>>(datasMap);
}
- /**
- * @Description: ������mac���������������������������������������������������������������������������������
- * @Param: [request]
- * @return: com.moral.common.bean.ResultBean<java.util.Map<java.lang.String,java.lang.Object>>
- * @Author: ������������
- * @Date: 2020/10/22
- */
+ /**
+ * @Description: ������mac���������������������������������������������������������������������������������
+ * @Param: [request]
+ * @return: com.moral.common.bean.ResultBean<java.util.Map < java.lang.String , java.lang.Object>>
+ * @Author: ������������
+ * @Date: 2020/10/22
+ */
@GetMapping("fiveMinuteAvgDataByMac")
public ResultBean<Map<String, Object>> fiveMinuteAvgDataByMac(HttpServletRequest request) {
//���������������mac���
@@ -446,22 +420,29 @@
return new ResultBean<Map<String, Object>>(sortDatas);
}
+ /**
+ * @Description: ������token������������������
+ * @Param: [request]
+ * @return: com.moral.common.bean.ResultBean<java.util.List < com.moral.entity.WebProvince>>
+ * @Author: ������������
+ * @Date: 2020/11/27
+ */
+
+ @UserLoginToken
@GetMapping("mapPath")
public ResultBean<List<WebProvince>> mapPath(HttpServletRequest request) {
- String token = request.getHeader("token");
+ String token = request.getHeader("token");
List<WebProvince> mapPath = mapPathService.getMapPath(token);
- if(ObjectUtils.isEmpty(mapPath))
- return new ResultBean<>("������������������������",ResultBean.FAIL);
+ if (ObjectUtils.isEmpty(mapPath))
+ return new ResultBean<>("������������������������", ResultBean.FAIL);
return new ResultBean<>(mapPath);
}
-
-
/**
* @Description: ���������������������������������������state
* @Param: [datas, devices]
- * @return: java.util.List<java.util.Map < java.lang.String , java.lang.Object>>
+ * @return: java.util.List<java.util.Map < java.lang.String , java.lang.Object>>
* @Author: ������������
* @Date: 2020/10/19
*/
--
Gitblit v1.8.0