From ffb2063003d3e735f3f8848207078b75c3f05bfa Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Fri, 21 May 2021 16:24:40 +0800
Subject: [PATCH] screen-manage 修改删除用户BUG
---
screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java | 45 ++++++++++++++-------------------------------
1 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java b/screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java
index 5bfa013..2076867 100644
--- a/screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java
+++ b/screen-manage/src/main/java/com/moral/api/service/impl/ManageAccountServiceImpl.java
@@ -175,7 +175,7 @@
AccountDTO accountDTO = new AccountDTO();
//������
ManageAccount manageAccount = accountInsertForm.formConvertEntity();
- List<String> roleIdsStr = accountInsertForm.getRoleIds();
+ List<Integer> roleIds = accountInsertForm.getRoleIds();
/*������������������������*/
ManageAccount existAccount = new ManageAccount();
@@ -193,28 +193,19 @@
//������
manageAccountMapper.insert(manageAccount);
- //������account_role
- /*String to Integer*/
- List<ManageRole> roles = null;
//������������������������������������������������������
- if (!ObjectUtils.isEmpty(roleIdsStr)) {
- List<Integer> roleIds = new ArrayList<>();
- roleIdsStr.forEach(str -> roleIds.add(Integer.parseInt(str)));
-
+ if (!ObjectUtils.isEmpty(roleIds)) {
Integer accountId = manageAccount.getId();
- roleIdsStr.forEach(
+ roleIds.forEach(
value -> {
ManageAccountRole manageAccountRole = new ManageAccountRole();
manageAccountRole.setAccountId(accountId);
- manageAccountRole.setRoleId(Integer.parseInt(value));
+ manageAccountRole.setRoleId(value);
manageAccountRoleMapper.insert(manageAccountRole);
}
);
- roles = manageRoleMapper.selectBatchIds(roleIds);
}
//������������������
- accountDTO.setAccount(manageAccount);
- accountDTO.setRoles(roles);
accountDTO.setCode(ResponseCodeEnum.SUCCESS.getCode());
accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg());
@@ -314,7 +305,7 @@
AccountDTO accountDTO = new AccountDTO();
//������
Integer accountId = accountDeleteForm.getAccountId();
- //������������������
+ //���������������������������������������������
ManageAccount manageAccount = new ManageAccount();
manageAccount.setIsDelete(Constants.NOT_DELETE);
manageAccount.setId(accountId);
@@ -335,16 +326,16 @@
UpdateWrapper<ManageAccountRole> deleteManageAccountRoleWrapper = new UpdateWrapper<>();
deleteManageAccountRoleWrapper.set("is_delete", Constants.DELETE).eq("account_id", manageAccount.getId());
manageAccountRoleMapper.update(null, deleteManageAccountRoleWrapper);
+ //������token
+ TokenUtils.destoryToken(accountId);
//������������������
accountDTO.setCode(ResponseCodeEnum.SUCCESS.getCode());
accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg());
- accountDTO.setAccount(existManageAccount);
-
//������������������
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
StringBuilder content = new StringBuilder();
content.append("������������������").append(existManageAccount.getUserName() + ";")
- .append("���������" + existManageAccount.getAccount() + ";");
+ .append("������:" + existManageAccount.getAccount() + ";");
logUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE);
return accountDTO;
@@ -383,8 +374,7 @@
if (manageAccountMap.size() > 1) {//������������������������id���������������������������������
manageAccountMapper.updateById(manageAccount);
}
- //������������������������
- manageAccount = manageAccountMapper.selectById(manageAccount.getId());
+
//������������������������������
List<ManageRole> oldRoles = manageRoleMapper.getManageRoleByAccountId(manageAccount.getId());
@@ -394,8 +384,8 @@
* ������roleIds���������������������������������������������������
* ������roleIds���������������������������������������������
* */
- List<ManageRole> roles = null;
if (roleIds != null) {
+ //������������������
UpdateWrapper<ManageAccountRole> deleteWrapper = new UpdateWrapper<>();
deleteWrapper.eq("account_id", manageAccount.getId()).set("is_delete", Constants.DELETE);
manageAccountRoleMapper.update(null, deleteWrapper);
@@ -406,21 +396,14 @@
manageAccountRole.setRoleId(roleId);
manageAccountRoleMapper.insert(manageAccountRole);
}
- //������������������������
- if (roleIds.size() != 0)
- roles = manageRoleMapper.selectBatchIds(roleIds);
- } else {
- roles = manageRoleMapper.getManageRoleByAccountId(manageAccount.getId());
}
- accountDTO.setRoles(roles);
+ //������token
+ TokenUtils.destoryToken(manageAccount.getId());
//������������������
accountDTO.setCode(ResponseCodeEnum.SUCCESS.getCode());
accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg());
- accountDTO.setAccount(manageAccount);
-
//������������������
insertUpdateLog(accountUpdateForm, oldManageAccount, oldRoles);
-
return accountDTO;
}
@@ -436,7 +419,7 @@
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
StringBuilder content = new StringBuilder();
content.append("������������������").append(oldAccount.getUserName() + ";")
- .append("���������" + oldAccount.getAccount() + ";");
+ .append("������:" + oldAccount.getAccount() + ";");
//������������Map,���������������������������������
Map<String, Object> newParameters = JSONObject.parseObject(JSON.toJSONString(updateForm), Map.class);
Map<String, Object> oldParameters = JSONObject.parseObject(JSON.toJSONString(oldAccount), Map.class);
@@ -452,7 +435,7 @@
List<Integer> newRoleIds = updateForm.getRoleIds();
if (newRoleIds != null && 0 == newRoleIds.size()) {//���������������������������������������������������������������
- content.append("���������������������;");
+ content.append("������������������������������;");
}
if ((newRoleIds != null) && (newRoleIds.size() != 0)) {//���������������������������������������������null���������������������������
StringBuilder oldRolesName = new StringBuilder("���");
--
Gitblit v1.8.0