| | |
| | | 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.setAccount(manageAccount); |
| | | accountDTOS.add(accountDTO); |
| | | } |
| | | } |
| | | |
| | | |
| | | //封装返回结果 |
| | | accountQueryDTO.setAccountDTOS(accountDTOS); |
| | |
| | | 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表中没有相应字段更新则不更新 |
| | | if (manageAccountMap.size() > 1) {//判断如果没有除了id以外的任何属性则不更新 |
| | | manageAccountMapper.updateById(manageAccount); |
| | | } |
| | | //获取更新后的对象 |
| | |
| | | accountDTO.setAccount(manageAccount); |
| | | |
| | | //操作插入日志 |
| | | insertUpdateLog(accountUpdateForm, exitManageAccount, oldRoles); |
| | | insertUpdateLog(accountUpdateForm, oldManageAccount, oldRoles); |
| | | |
| | | return accountDTO; |
| | | } |