|
@@ -2,7 +2,7 @@ package com.zy.bms.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.zy.bms.common.ServerResponse;
|
|
|
-import com.zy.bms.common.enums.ResponseCode;
|
|
|
+import com.zy.bms.common.annotation.AdminAuthorWx;
|
|
|
import com.zy.bms.entity.DeviceBase;
|
|
|
import com.zy.bms.entity.User;
|
|
|
import com.zy.bms.entity.UserPrivilege;
|
|
@@ -73,24 +73,18 @@ public class UbiLpWxController extends BaseController {
|
|
|
/**
|
|
|
* 查看当前在线设备 rabbitMQ
|
|
|
*/
|
|
|
+ @AdminAuthorWx
|
|
|
@GetMapping("connections.do")
|
|
|
public ServerResponse connections() {
|
|
|
- User user = userService.getOne(new QueryWrapper<User>().eq("user_id", userId()));
|
|
|
- if (user == null || user.getAdmin() != 1) {
|
|
|
- return ServerResponse.custom(ResponseCode.AUTHOR);
|
|
|
- }
|
|
|
return ServerResponse.success(RabbitMQApi.connections());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查看当前注册的用户 rabbitMQ
|
|
|
*/
|
|
|
+ @AdminAuthorWx
|
|
|
@GetMapping("users.do")
|
|
|
public ServerResponse users() {
|
|
|
- User user = userService.getOne(new QueryWrapper<User>().eq("user_id", userId()));
|
|
|
- if (user == null || user.getAdmin() != 1) {
|
|
|
- return ServerResponse.custom(ResponseCode.AUTHOR);
|
|
|
- }
|
|
|
return ServerResponse.success(RabbitMQApi.users());
|
|
|
}
|
|
|
|
|
@@ -102,14 +96,6 @@ public class UbiLpWxController extends BaseController {
|
|
|
return ServerResponse.success(groupService.getByUserId(userId()));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 校验设备码是否存在
|
|
|
- */
|
|
|
- @GetMapping("checkOpenNum.do")
|
|
|
- public ServerResponse checkOpenNum(String openNum) {
|
|
|
- return ServerResponse.success(deviceBaseService.checkOpenNum(openNum));
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 通过设备组ID查询设备列表
|
|
|
*/
|
|
@@ -126,7 +112,7 @@ public class UbiLpWxController extends BaseController {
|
|
|
@GetMapping("getDevicesByUserId.do")
|
|
|
public ServerResponse getDevicesByUserId() {
|
|
|
List<String> groupIds = userPrivilegeService.getGroupIdsByUserId(userId());
|
|
|
- if (groupIds.isEmpty()) return ServerResponse.success(null);
|
|
|
+ if (groupIds == null || groupIds.isEmpty()) return ServerResponse.success(null);
|
|
|
return ServerResponse.success(deviceBaseService.listByGroupIdsWx(groupIds));
|
|
|
}
|
|
|
|
|
@@ -138,13 +124,10 @@ public class UbiLpWxController extends BaseController {
|
|
|
DeviceBase device = deviceBaseService.getOne(new QueryWrapper<DeviceBase>().eq("open_num", openNum));
|
|
|
if (device == null) return ServerResponse.warning("设备码错误!");
|
|
|
//如果该用户没有该设备组权限,则加上权限
|
|
|
- UserPrivilege userPrivilege = userPrivilegeService.getOne(new QueryWrapper<UserPrivilege>()
|
|
|
- .eq("group_id", device.getGroupId()).eq("user_id", userId()));
|
|
|
- if (userPrivilege == null) {
|
|
|
- UserPrivilege entity = new UserPrivilege();
|
|
|
- entity.setUserId(userId());
|
|
|
- entity.setGroupId(device.getGroupId());
|
|
|
- userPrivilegeService.save(entity);
|
|
|
+ if (userPrivilegeService.getOne(new QueryWrapper<UserPrivilege>()
|
|
|
+ .eq("group_id", device.getGroupId())
|
|
|
+ .eq("user_id", userId())) == null) {
|
|
|
+ userPrivilegeService.save(new UserPrivilege(userId(), device.getGroupId()));
|
|
|
}
|
|
|
return ServerResponse.success(deviceBaseService.getDetailWx(openNum));
|
|
|
}
|