|
@@ -96,8 +96,8 @@ public class UserInfoServiceImpl implements UserInfoService { |
|
@@ -96,8 +96,8 @@ public class UserInfoServiceImpl implements UserInfoService { |
96
|
String errorMessage = "";
|
96
|
String errorMessage = "";
|
97
|
|
97
|
|
98
|
String username = userInfo.getUsername();
|
98
|
String username = userInfo.getUsername();
|
99
|
- String password = userInfo.getPassword();
|
|
|
100
|
- if (StringUtil.isNullOrEmpty(password) || StringUtil.isNullOrEmpty(username)) {
|
99
|
+// String password = userInfo.getPassword();StringUtil.isNullOrEmpty(password) ||
|
|
|
100
|
+ if (StringUtil.isNullOrEmpty(username)) {
|
101
|
return new ResultJson<>("400", "用户名以及密码,不得为空,请务必选择");
|
101
|
return new ResultJson<>("400", "用户名以及密码,不得为空,请务必选择");
|
102
|
}
|
102
|
}
|
103
|
String virtualHostId = userInfo.getVirtualHostId();
|
103
|
String virtualHostId = userInfo.getVirtualHostId();
|
|
@@ -134,8 +134,8 @@ public class UserInfoServiceImpl implements UserInfoService { |
|
@@ -134,8 +134,8 @@ public class UserInfoServiceImpl implements UserInfoService { |
134
|
+ "-->的默认队列已存在,请联系管理员;" + "\r\n" + "<------->";
|
134
|
+ "-->的默认队列已存在,请联系管理员;" + "\r\n" + "<------->";
|
135
|
} else {
|
135
|
} else {
|
136
|
int num = userInfoMapper.insertSelective(userInfo);
|
136
|
int num = userInfoMapper.insertSelective(userInfo);
|
137
|
- ClientUtils.addRabbitUser(userInfo, busServer, password);
|
|
|
138
|
- ClientUtils.userRelation(userInfo, busServer);
|
137
|
+// ClientUtils.addRabbitUser(userInfo, busServer, password);
|
|
|
138
|
+// ClientUtils.userRelation(userInfo, busServer);
|
139
|
createQueue(userInfo);
|
139
|
createQueue(userInfo);
|
140
|
index = index + num;
|
140
|
index = index + num;
|
141
|
}
|
141
|
}
|
|
@@ -177,8 +177,8 @@ public class UserInfoServiceImpl implements UserInfoService { |
|
@@ -177,8 +177,8 @@ public class UserInfoServiceImpl implements UserInfoService { |
177
|
+ ",虚拟主机名称:" + userInfo.getVirtualHostName() + "-->的默认队列已存在,请联系管理员";
|
177
|
+ ",虚拟主机名称:" + userInfo.getVirtualHostName() + "-->的默认队列已存在,请联系管理员";
|
178
|
} else {
|
178
|
} else {
|
179
|
num = userInfoMapper.insertSelective(userInfo);
|
179
|
num = userInfoMapper.insertSelective(userInfo);
|
180
|
- ClientUtils.addRabbitUser(userInfo, busServer, password);
|
|
|
181
|
- ClientUtils.userRelation(userInfo, busServer);
|
180
|
+// ClientUtils.addRabbitUser(userInfo, busServer, password);
|
|
|
181
|
+// ClientUtils.userRelation(userInfo, busServer);
|
182
|
createQueue(userInfo);
|
182
|
createQueue(userInfo);
|
183
|
}
|
183
|
}
|
184
|
}
|
184
|
}
|
|
@@ -200,10 +200,11 @@ public class UserInfoServiceImpl implements UserInfoService { |
|
@@ -200,10 +200,11 @@ public class UserInfoServiceImpl implements UserInfoService { |
200
|
*/
|
200
|
*/
|
201
|
void createQueue(UserInfo userInfo) throws IOException, TimeoutException
|
201
|
void createQueue(UserInfo userInfo) throws IOException, TimeoutException
|
202
|
{
|
202
|
{
|
|
|
203
|
+ String queueNameRule = userInfo.getVirtualHostName() + "_" + userInfo.getUsername() + "_R";
|
203
|
BusQueue busQueue = BusQueue.builder()
|
204
|
BusQueue busQueue = BusQueue.builder()
|
204
|
.id(IdUtils.generateId())
|
205
|
.id(IdUtils.generateId())
|
205
|
.username(userInfo.getUsername())
|
206
|
.username(userInfo.getUsername())
|
206
|
- .queueName(userInfo.getVirtualHostName() + "_" + userInfo.getUsername() + "_R")
|
207
|
+ .queueName(queueNameRule)
|
207
|
.virtualHostId(userInfo.getVirtualHostId())
|
208
|
.virtualHostId(userInfo.getVirtualHostId())
|
208
|
.durability(true)
|
209
|
.durability(true)
|
209
|
.autoDelete(false)
|
210
|
.autoDelete(false)
|
|
@@ -322,12 +323,12 @@ public class UserInfoServiceImpl implements UserInfoService { |
|
@@ -322,12 +323,12 @@ public class UserInfoServiceImpl implements UserInfoService { |
322
|
String username = userInfo.getUsername();
|
323
|
String username = userInfo.getUsername();
|
323
|
String serverName = userInfo.getServerName();
|
324
|
String serverName = userInfo.getServerName();
|
324
|
|
325
|
|
325
|
- List<UserInfo> userInfoList = userInfoMapper.selectByUsernameAndServerName(username, serverName);
|
326
|
+// List<UserInfo> userInfoList = userInfoMapper.selectByUsernameAndServerName(username, serverName);
|
326
|
int num = userInfoMapper.deleteByUsernameAndServerName(username, serverName);
|
327
|
int num = userInfoMapper.deleteByUsernameAndServerName(username, serverName);
|
327
|
- for (UserInfo item : userInfoList) {
|
|
|
328
|
- BusServer busServer = busServerService.selectByPrimaryKey(item.getServerId());
|
|
|
329
|
- ClientUtils.deleteMQUser(username, busServer);
|
|
|
330
|
- }
|
328
|
+// for (UserInfo item : userInfoList) {
|
|
|
329
|
+// BusServer busServer = busServerService.selectByPrimaryKey(item.getServerId());
|
|
|
330
|
+// ClientUtils.deleteMQUser(username, busServer);
|
|
|
331
|
+// }
|
331
|
|
332
|
|
332
|
/**
|
333
|
/**
|
333
|
* TODO: 删除该用户对应的队列
|
334
|
* TODO: 删除该用户对应的队列
|
|
@@ -368,18 +369,26 @@ public class UserInfoServiceImpl implements UserInfoService { |
|
@@ -368,18 +369,26 @@ public class UserInfoServiceImpl implements UserInfoService { |
368
|
{
|
369
|
{
|
369
|
String virtualHostName = userInfo.getVirtualHostName();
|
370
|
String virtualHostName = userInfo.getVirtualHostName();
|
370
|
String userInfoId = userInfo.getId();
|
371
|
String userInfoId = userInfo.getId();
|
|
|
372
|
+ int index = 0;
|
371
|
|
373
|
|
372
|
String splitItem = ",";
|
374
|
String splitItem = ",";
|
373
|
- if (virtualHostName.contains(splitItem)) {
|
|
|
374
|
- String[] split = virtualHostName.split(splitItem);
|
|
|
375
|
- for (int i = 0; i < split.length; i++) {
|
|
|
376
|
-
|
375
|
+ if (userInfoId.contains(splitItem)) {
|
|
|
376
|
+ String[] split = userInfoId.split(splitItem);
|
|
|
377
|
+ for (String id : split) {
|
|
|
378
|
+ int num = userInfoMapper.deleteByPrimaryKey(id);
|
|
|
379
|
+ if (num > 0) {
|
|
|
380
|
+ index = index + num;
|
|
|
381
|
+ }
|
|
|
382
|
+ }
|
|
|
383
|
+ if (index != split.length) {
|
|
|
384
|
+ index = 0;
|
377
|
}
|
385
|
}
|
|
|
386
|
+ } else {
|
|
|
387
|
+ index = userInfoMapper.deleteByPrimaryKey(userInfoId);
|
378
|
}
|
388
|
}
|
379
|
- int num = userInfoMapper.deleteByPrimaryKey(userInfo.getId());
|
|
|
380
|
- BusServer busServer = busServerService.selectByPrimaryKey(userInfo.getServerId());
|
|
|
381
|
- ClientUtils.clearPermissions(busServer, userInfo.getVirtualHostName(), userInfo.getUsername());
|
|
|
382
|
- return num > 0
|
389
|
+// BusServer busServer = busServerService.selectByPrimaryKey(userInfo.getServerId());
|
|
|
390
|
+// ClientUtils.clearPermissions(busServer, userInfo.getVirtualHostName(), userInfo.getUsername());
|
|
|
391
|
+ return index > 0
|
383
|
? new ResultJson<>("200", "删除用户关系,成功!")
|
392
|
? new ResultJson<>("200", "删除用户关系,成功!")
|
384
|
: new ResultJson<>("500", "删除用户关系,失败!");
|
393
|
: new ResultJson<>("500", "删除用户关系,失败!");
|
385
|
}
|
394
|
}
|
|
@@ -402,8 +411,8 @@ public class UserInfoServiceImpl implements UserInfoService { |
|
@@ -402,8 +411,8 @@ public class UserInfoServiceImpl implements UserInfoService { |
402
|
if (StringUtil.isNullOrEmpty(serverName) || StringUtil.isNullOrEmpty(username)) {
|
411
|
if (StringUtil.isNullOrEmpty(serverName) || StringUtil.isNullOrEmpty(username)) {
|
403
|
continue;
|
412
|
continue;
|
404
|
}
|
413
|
}
|
405
|
- BusServer busServer = busServerMapper.selectByServerName(serverName);
|
|
|
406
|
- ClientUtils.deleteMQUser(username, busServer);
|
414
|
+// BusServer busServer = busServerMapper.selectByServerName(serverName);
|
|
|
415
|
+// ClientUtils.deleteMQUser(username, busServer);
|
407
|
num = userInfoMapper.deleteByUsernameAndServerName(username, serverName);
|
416
|
num = userInfoMapper.deleteByUsernameAndServerName(username, serverName);
|
408
|
if (num > 0) {
|
417
|
if (num > 0) {
|
409
|
index = index + num;
|
418
|
index = index + num;
|
|
@@ -428,13 +437,13 @@ public class UserInfoServiceImpl implements UserInfoService { |
|
@@ -428,13 +437,13 @@ public class UserInfoServiceImpl implements UserInfoService { |
428
|
if (ids.contains(splitItem)) {
|
437
|
if (ids.contains(splitItem)) {
|
429
|
String[] split = ids.split(splitItem);
|
438
|
String[] split = ids.split(splitItem);
|
430
|
for (String id : split) {
|
439
|
for (String id : split) {
|
431
|
- UserInfo userInfo = userInfoMapper.selectByPrimaryKey(id);
|
|
|
432
|
- String username = userInfo.getUsername();
|
|
|
433
|
- String serverName = userInfo.getServerName();
|
|
|
434
|
- String virtualHostName = userInfo.getVirtualHostName();
|
|
|
435
|
- BusServer busServer = busServerMapper.selectByServerName(serverName);
|
440
|
+// UserInfo userInfo = userInfoMapper.selectByPrimaryKey(id);
|
|
|
441
|
+// String username = userInfo.getUsername();
|
|
|
442
|
+// String serverName = userInfo.getServerName();
|
|
|
443
|
+// String virtualHostName = userInfo.getVirtualHostName();
|
|
|
444
|
+// BusServer busServer = busServerMapper.selectByServerName(serverName);
|
436
|
int num = userInfoMapper.deleteByPrimaryKey(id);
|
445
|
int num = userInfoMapper.deleteByPrimaryKey(id);
|
437
|
- ClientUtils.clearPermissions(busServer, virtualHostName, username);
|
446
|
+// ClientUtils.clearPermissions(busServer, virtualHostName, username);
|
438
|
if (num > 0) {
|
447
|
if (num > 0) {
|
439
|
index = index + num;
|
448
|
index = index + num;
|
440
|
}
|
449
|
}
|
|
@@ -443,13 +452,13 @@ public class UserInfoServiceImpl implements UserInfoService { |
|
@@ -443,13 +452,13 @@ public class UserInfoServiceImpl implements UserInfoService { |
443
|
? new ResultJson<>("200", "批量删除用户关系,成功!")
|
452
|
? new ResultJson<>("200", "批量删除用户关系,成功!")
|
444
|
: new ResultJson<>("500", "批量删除用户关系,失败!");
|
453
|
: new ResultJson<>("500", "批量删除用户关系,失败!");
|
445
|
}
|
454
|
}
|
446
|
- UserInfo userInfo = userInfoMapper.selectByPrimaryKey(ids);
|
|
|
447
|
- String username = userInfo.getUsername();
|
|
|
448
|
- String serverName = userInfo.getServerName();
|
|
|
449
|
- String virtualHostName = userInfo.getVirtualHostName();
|
|
|
450
|
- BusServer busServer = busServerMapper.selectByServerName(serverName);
|
455
|
+// UserInfo userInfo = userInfoMapper.selectByPrimaryKey(ids);
|
|
|
456
|
+// String username = userInfo.getUsername();
|
|
|
457
|
+// String serverName = userInfo.getServerName();
|
|
|
458
|
+// String virtualHostName = userInfo.getVirtualHostName();
|
|
|
459
|
+// BusServer busServer = busServerMapper.selectByServerName(serverName);
|
451
|
int num = userInfoMapper.deleteByPrimaryKey(ids);
|
460
|
int num = userInfoMapper.deleteByPrimaryKey(ids);
|
452
|
- ClientUtils.clearPermissions(busServer, virtualHostName, username);
|
461
|
+// ClientUtils.clearPermissions(busServer, virtualHostName, username);
|
453
|
return num > 0
|
462
|
return num > 0
|
454
|
? new ResultJson<>("200", "批量删除用户关系,成功!")
|
463
|
? new ResultJson<>("200", "批量删除用户关系,成功!")
|
455
|
: new ResultJson<>("500", "批量删除用户关系,失败!");
|
464
|
: new ResultJson<>("500", "批量删除用户关系,失败!");
|