| | |
| | | import com.moral.api.entity.ManageRole; |
| | | import com.moral.api.mapper.ManageAccountMapper; |
| | | import com.moral.api.mapper.ManageAccountRoleMapper; |
| | | import com.moral.api.mapper.ManageMenuMapper; |
| | | import com.moral.api.mapper.ManageRoleMapper; |
| | | import com.moral.api.pojo.dto.account.*; |
| | | import com.moral.api.pojo.dto.login.AccountInfoDTO; |
| | | import com.moral.api.pojo.redisBean.AccountInfoDTO; |
| | | import com.moral.api.pojo.dto.login.LoginDTO; |
| | | import com.moral.api.pojo.form.account.AccountDeleteForm; |
| | | import com.moral.api.pojo.form.account.AccountInsertForm; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | import java.util.function.Predicate; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | List<ManageRole> roles = manageRoleMapper.getManageRoleByAccountId(manageAccount.getId()); |
| | | |
| | | //查询菜单 |
| | | List<ManageMenu> menus = null; |
| | | List<ManageMenu> menus = new ArrayList<>(); |
| | | if (!ObjectUtils.isEmpty(roles)) { |
| | | menus = manageMenuService.getParentChildrenMenusByRoles(roles); |
| | | } |
| | |
| | | |
| | | //查询结果 |
| | | Page resultPage = manageAccountMapper.selectPage(queryPage, wrapper); |
| | | |
| | | //查询用户对应的角色 |
| | | List<ManageAccount> accounts = resultPage.getRecords(); |
| | | //过滤系统最高权限账号admin,除admin角色外无法查看 |
| | | AccountInfoDTO accountInfoDTO = (AccountInfoDTO) TokenUtils.getUserInfoByToken(); |
| | | List<ManageRole> ownRoles = accountInfoDTO.getRoles(); |
| | | boolean ownAdminRole = false; |
| | | for (ManageRole ownRole : ownRoles) { |
| | | String roleName = ownRole.getName(); |
| | | if ("admin".equals(roleName)) |
| | | ownAdminRole = true; |
| | | } |
| | | if (!ownAdminRole) { |
| | | accounts.removeIf(new Predicate<ManageAccount>() { |
| | | @Override |
| | | public boolean test(ManageAccount manageAccount) { |
| | | if (manageAccount.getAccount().equals("admin")) |
| | | return true; |
| | | return false; |
| | | } |
| | | }); |
| | | } |
| | | //查询用户对应的角色 |
| | | List<AccountDTO> accountDTOS = new ArrayList<>(); |
| | | for (ManageAccount manageAccount : accounts) { |
| | | AccountDTO accountDTO = new AccountDTO(); |
| | |
| | | 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()); |
| | |
| | | manageAccountRoleMapper.insert(manageAccountRole); |
| | | } |
| | | } |
| | | //操作插入日志 |
| | | insertUpdateLog(accountUpdateForm, oldManageAccount, oldRoles); |
| | | //销毁token |
| | | TokenUtils.destoryToken(manageAccount.getId()); |
| | | //封装返回结果 |
| | | accountDTO.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | //操作插入日志 |
| | | insertUpdateLog(accountUpdateForm, oldManageAccount, oldRoles); |
| | | return accountDTO; |
| | | } |
| | | |