| | |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了用户:").append(manageAccount.getUserName() + ";") |
| | | .append("account:" + manageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage(request, content.toString(),Constants.INSERT_OPERATE_TYPE); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | |
| | | return accountDTO; |
| | | } |
| | |
| | | AccountQueryDTO accountQueryDTO = new AccountQueryDTO(); |
| | | |
| | | //取参 |
| | | Integer pageCount = accountQueryForm.getPage(); |
| | | Integer page = accountQueryForm.getPage(); |
| | | Integer size = accountQueryForm.getSize(); |
| | | String userName = accountQueryForm.getUserName(); |
| | | String email = accountQueryForm.getEmail(); |
| | |
| | | String order = accountQueryForm.getOrder(); |
| | | String orderType = accountQueryForm.getOrderType(); |
| | | Date createStartTime = accountQueryForm.getCreateStartTime(); |
| | | Date createEndTime = DateUtils.getDateOfDay(accountQueryForm.getCreateEndTime(), 1); |
| | | Date createEndTime = accountQueryForm.getCreateEndTime(); |
| | | |
| | | //组装查询条件 |
| | | Page<ManageAccount> page = new Page<>(pageCount, size); |
| | | Page<ManageAccount> queryPage = new Page<>(page, size); |
| | | NullFilterWrapper<ManageAccount> wrapper = new NullFilterWrapper<>(); |
| | | |
| | | wrapper.like("user_name", userName); |
| | |
| | | wrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | |
| | | //查询结果 |
| | | Page resultPage = manageAccountMapper.selectPage(page, wrapper); |
| | | Page resultPage = manageAccountMapper.selectPage(queryPage, wrapper); |
| | | |
| | | //查询用户对应的角色 |
| | | List<ManageAccount> accounts = resultPage.getRecords(); |
| | | List<AccountDTO> accountDTOS = new ArrayList<>(); |
| | | if (!ObjectUtils.isEmpty(accounts)) { |
| | | for (ManageAccount manageAccount : accounts) { |
| | | AccountDTO accountDTO = new AccountDTO(); |
| | | List<ManageRole> roles = manageRoleMapper.getManageRoleByAccountId(manageAccount.getId()); |
| | | accountDTO.setRoles(roles); |
| | | accountDTO.setAccount(manageAccount); |
| | | accountDTOS.add(accountDTO); |
| | | } |
| | | for (ManageAccount manageAccount : accounts) { |
| | | AccountDTO accountDTO = new AccountDTO(); |
| | | List<ManageRole> roles = manageRoleMapper.getManageRoleByAccountId(manageAccount.getId()); |
| | | accountDTO.setRoles(roles); |
| | | accountDTO.setAccount(manageAccount); |
| | | accountDTOS.add(accountDTO); |
| | | } |
| | | |
| | | |
| | | //封装返回结果 |
| | | accountQueryDTO.setAccountDTOS(accountDTOS); |
| | |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了用户:").append(existManageAccount.getUserName() + ";") |
| | | .append("账号:" + existManageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage(request, content.toString(),Constants.DELETE_OPERATE_TYPE); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | |
| | | return accountDTO; |
| | | } |
| | |
| | | ManageAccount manageAccount = accountUpdateForm.formConvertEntity(); |
| | | List<Integer> roleIds = accountUpdateForm.getRoleIds(); |
| | | |
| | | //判断要更新的用户是否存在 |
| | | QueryWrapper<ManageAccount> exitWrapper = new QueryWrapper<>(); |
| | | ManageAccount exitManageAccount = new ManageAccount(); |
| | | exitManageAccount.setId(manageAccount.getId()); |
| | | exitManageAccount.setIsDelete(Constants.NOT_DELETE); |
| | | exitWrapper.setEntity(exitManageAccount); |
| | | exitManageAccount = manageAccountMapper.selectOne(exitWrapper); |
| | | if (ObjectUtils.isEmpty(exitManageAccount)) { |
| | | //查找要更新的用户用于插入日志 |
| | | QueryWrapper<ManageAccount> oldAccountWrapper = new QueryWrapper<>(); |
| | | ManageAccount oldManageAccount = new ManageAccount(); |
| | | oldManageAccount.setId(manageAccount.getId()); |
| | | oldManageAccount.setIsDelete(Constants.NOT_DELETE); |
| | | oldAccountWrapper.setEntity(oldManageAccount); |
| | | oldManageAccount = manageAccountMapper.selectOne(oldAccountWrapper); |
| | | if (ObjectUtils.isEmpty(oldManageAccount)) { |
| | | accountDTO.setCode(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode()); |
| | | accountDTO.setMsg(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getMsg()); |
| | | return accountDTO; |
| | | } |
| | | |
| | | //更新ManageAccount表 |
| | | Map manageAccountMap = JSONObject.parseObject(JSON.toJSONString(manageAccount),Map.class);//转换为Map判断属性是否有更新 |
| | | if (manageAccountMap.size()>1) {//判断如果account表中没有相应字段更新则不更新 |
| | | Map manageAccountMap = JSONObject.parseObject(JSON.toJSONString(manageAccount), Map.class);//转换为Map判断属性是否有更新 |
| | | if (manageAccountMap.size() > 1) {//判断如果没有除了id以外的任何属性则不更新 |
| | | manageAccountMapper.updateById(manageAccount); |
| | | } |
| | | //获取更新后的对象 |
| | |
| | | accountDTO.setAccount(manageAccount); |
| | | |
| | | //操作插入日志 |
| | | insertUpdateLog(accountUpdateForm, exitManageAccount, oldRoles); |
| | | insertUpdateLog(accountUpdateForm, oldManageAccount, oldRoles); |
| | | |
| | | return accountDTO; |
| | | } |
| | |
| | | } |
| | | |
| | | if (!ObjectUtils.isEmpty(oldRoles)) { |
| | | oldRolesName.deleteCharAt(oldRolesName.length()-1);//删除 "空" |
| | | oldRolesName.deleteCharAt(oldRolesName.length() - 1);//删除 "空" |
| | | oldRolesName.append("["); |
| | | for (ManageRole role : oldRoles) { |
| | | oldRolesName.append(role.getName() + ","); |
| | |
| | | } |
| | | |
| | | if (!ObjectUtils.isEmpty(newRoles)) { |
| | | newRolesName.deleteCharAt(newRolesName.length()-1);//删除 "空" |
| | | newRolesName.deleteCharAt(newRolesName.length() - 1);//删除 "空" |
| | | newRolesName.append("["); |
| | | for (ManageRole role : newRoles) { |
| | | newRolesName.append(role.getName() + ","); |
| | |
| | | newRolesName.append("]"); |
| | | } |
| | | //拼接完整content |
| | | content.append(value+":"+oldRolesName + "->" + newRolesName + ";"); |
| | | content.append(value + ":" + oldRolesName + "->" + newRolesName + ";"); |
| | | } |
| | | } else {//其他属性处理 |
| | | if (newParameters.get(key) != null) { |