@Test(expected = NotFoundException.class) public void updateGroup2() { GroupDO group = GroupDO.builder().name("测试分组1").info("just for test").build(); groupMapper.insert(group); UpdateGroupDTO dto = new UpdateGroupDTO(); dto.setName("测试分组2"); dto.setInfo("测试分组2info"); Random random = new Random(); boolean ok = adminService.updateGroup((long) random.nextInt(100), dto); assertFalse(ok); }
@Override public boolean updateGroup(Long id, UpdateGroupDTO dto) { GroupDO exist = groupService.getById(id); if (exist == null) { throw new NotFoundException("group not found", 10024); } if (!exist.getName().equals(dto.getName())) { throwGroupNameExist(dto.getName()); } GroupDO group = GroupDO.builder().id(id).name(dto.getName()).info(dto.getInfo()).build(); return groupService.updateById(group); }
AdminServiceImpl implements AdminService { @Override public boolean updateGroup(Long id, UpdateGroupDTO dto) { GroupDO exist = groupService.getById(id); if (exist == null) { throw new NotFoundException("group not found", 10024); } if (!exist.getName().equals(dto.getName())) { throwGroupNameExist(dto.getName()); } GroupDO group = GroupDO.builder().id(id).name(dto.getName()).info(dto.getInfo()).build(); return groupService.updateById(group); } }
AdminServiceImpl implements AdminService { @Override public boolean updateGroup(Long id, UpdateGroupDTO dto) { GroupDO exist = groupService.getById(id); if (exist == null) { throw new NotFoundException("group not found", 10024); } if (!exist.getName().equals(dto.getName())) { throwGroupNameExist(dto.getName()); } GroupDO group = GroupDO.builder().id(id).name(dto.getName()).info(dto.getInfo()).build(); return groupService.updateById(group); }  }
AdminServiceImpl implements AdminService { @Override public boolean updateGroup(Long id, UpdateGroupDTO dto) { GroupDO exist = groupService.getById(id); if (exist == null) { throw new NotFoundException("group not found", 10024); } if (!exist.getName().equals(dto.getName())) { throwGroupNameExist(dto.getName()); } GroupDO group = GroupDO.builder().id(id).name(dto.getName()).info(dto.getInfo()).build(); return groupService.updateById(group); }  @Override IPage<UserDO> getUserPageByGroupId(Long groupId, Long count, Long page); @Override boolean changeUserPassword(Long id, ResetPasswordDTO dto); @Transactional @Override boolean deleteUser(Long id); @Override boolean updateUserInfo(Long id, UpdateUserInfoDTO validator); @Override IPage<GroupDO> getGroupPage(Long page, Long count); @Override GroupPermissionsBO getGroup(Long id); @Transactional @Override boolean createGroup(NewGroupDTO dto); @Override boolean updateGroup(Long id, UpdateGroupDTO dto); @Override boolean deleteGroup(Long id); @Override boolean dispatchPermission(DispatchPermissionDTO dto); @Override boolean dispatchPermissions(DispatchPermissionsDTO dto); @Override boolean removePermissions(RemovePermissionsDTO dto); @Override List<GroupDO> getAllGroups(); @Override List<PermissionDO> getAllPermissions(); @Override Map<String, List<PermissionDO>> getAllStructualPermissions(); }
AdminServiceImpl implements AdminService { @Override public boolean updateGroup(Long id, UpdateGroupDTO dto) { GroupDO exist = groupService.getById(id); if (exist == null) { throw new NotFoundException("group not found", 10024); } if (!exist.getName().equals(dto.getName())) { throwGroupNameExist(dto.getName()); } GroupDO group = GroupDO.builder().id(id).name(dto.getName()).info(dto.getInfo()).build(); return groupService.updateById(group); }  @Override IPage<UserDO> getUserPageByGroupId(Long groupId, Long count, Long page); @Override boolean changeUserPassword(Long id, ResetPasswordDTO dto); @Transactional @Override boolean deleteUser(Long id); @Override boolean updateUserInfo(Long id, UpdateUserInfoDTO validator); @Override IPage<GroupDO> getGroupPage(Long page, Long count); @Override GroupPermissionsBO getGroup(Long id); @Transactional @Override boolean createGroup(NewGroupDTO dto); @Override boolean updateGroup(Long id, UpdateGroupDTO dto); @Override boolean deleteGroup(Long id); @Override boolean dispatchPermission(DispatchPermissionDTO dto); @Override boolean dispatchPermissions(DispatchPermissionsDTO dto); @Override boolean removePermissions(RemovePermissionsDTO dto); @Override List<GroupDO> getAllGroups(); @Override List<PermissionDO> getAllPermissions(); @Override Map<String, List<PermissionDO>> getAllStructualPermissions();  }