| | |
| | | |
| | | import kr.wisestone.owl.constant.Constants; |
| | | import kr.wisestone.owl.constant.MsgConstants; |
| | | import kr.wisestone.owl.domain.User; |
| | | import kr.wisestone.owl.domain.UserLevel; |
| | | import kr.wisestone.owl.domain.UserWorkspace; |
| | | import kr.wisestone.owl.domain.Workspace; |
| | | import kr.wisestone.owl.domain.*; |
| | | import kr.wisestone.owl.exception.OwlRuntimeException; |
| | | import kr.wisestone.owl.mapper.UserWorkspaceMapper; |
| | | import kr.wisestone.owl.repository.UserWorkspaceRepository; |
| | | import kr.wisestone.owl.service.UserLevelService; |
| | | import kr.wisestone.owl.service.UserService; |
| | | import kr.wisestone.owl.service.UserWorkspaceService; |
| | | import kr.wisestone.owl.service.WorkspaceService; |
| | | import kr.wisestone.owl.service.*; |
| | | import kr.wisestone.owl.util.CommonUtil; |
| | | import kr.wisestone.owl.util.ConvertUtil; |
| | | import kr.wisestone.owl.vo.DepartmentVo; |
| | | import kr.wisestone.owl.vo.ResPage; |
| | | import kr.wisestone.owl.vo.UserWorkspaceVo; |
| | | import kr.wisestone.owl.web.condition.UserCondition; |
| | | import kr.wisestone.owl.web.condition.UserWorkspaceCondition; |
| | | import kr.wisestone.owl.web.form.UserWorkspaceForm; |
| | | import org.slf4j.Logger; |
| | |
| | | |
| | | @Autowired |
| | | private UserLevelService userLevelService; |
| | | |
| | | @Autowired |
| | | private DepartmentService departmentService; |
| | | |
| | | @Autowired |
| | | private UserWorkspaceMapper userWorkspaceMapper; |
| | |
| | | |
| | | for (UserWorkspaceVo userWorkspaceVo : userWorkspaceVos) { |
| | | userWorkspaceVo.setAccount(CommonUtil.decryptAES128(userWorkspaceVo.getAccount())); |
| | | |
| | | // UserCondition 는 원래 userId 가 없었다. |
| | | UserCondition con = new UserCondition(); |
| | | // 그래서 Condition에 추가 해주고 set 하는데 그건 userWorkspaceVo 에서 Id 를 가져온다 |
| | | con.setId(userWorkspaceVo.getUserId()); |
| | | // findByDepartmentIds 라는걸 mapper로 만들어서 쿼리 for문을 돌리고 us |
| | | List<Map<String, Object>> re = this.departmentService.findByDepartmentIds(con); |
| | | List<DepartmentVo> vos = ConvertUtil.convertListToListClass(re, DepartmentVo.class); |
| | | |
| | | userWorkspaceVo.setDepartmentVos(vos); |
| | | } |
| | | |
| | | resJsonData.put(Constants.REQ_KEY_PAGE_VO, new ResPage(pageable.getPageNumber(), pageable.getPageSize(), |
| | |
| | | public void modifyUserWorkspace(UserWorkspaceForm userWorkspaceForm) { |
| | | UserWorkspace userWorkspace = this.getUserWorkspace(userWorkspaceForm.getId()); |
| | | |
| | | UserLevel currentUserlevel = userWorkspace.getUser().getUserLevel(); |
| | | User user = userWorkspace.getUser(); |
| | | |
| | | // 사용자 등급 변경 |
| | | UserLevel currentUserlevel = user.getUserLevel(); |
| | | if (currentUserlevel.getId() != userWorkspaceForm.getLevelId()) { |
| | | // 사용자 등급 변경시 |
| | | User user = userWorkspace.getUser(); |
| | | UserLevel userLevel = this.userLevelService.getUserLevel(userWorkspaceForm.getLevelId()); |
| | | user.setUserLevel(userLevel); |
| | | userWorkspace.setUser(user); |
| | | } |
| | | |
| | | //todo 부서 변경시 |
| | | // 부서 변경 |
| | | // DepartmentManage currentDepartment = user.getDepartmentManage(); |
| | | // if (currentDepartment == null || (userWorkspaceForm.getDepartmentId() != null && currentDepartment.getId() != userWorkspaceForm.getDepartmentId())) { |
| | | // // 부서명 변경시 |
| | | // DepartmentManage departmentManage = this.departmentService.getDepartment(userWorkspaceForm.getDepartmentId()); |
| | | // user.setDepartmentManage(departmentManage); |
| | | // userWorkspace.setUser(user); |
| | | // } |
| | | |
| | | // 참여로 상태를 변경하려고 할때 |
| | | if (userWorkspace.getUseYn() != userWorkspaceForm.getUseYn()) { |
| | |
| | | this.messageAccessor.getMessage(MsgConstants.WORKSPACE_MAX_USER_EXCESS_NOT_INCLUDE)); |
| | | } |
| | | } else { |
| | | User user = userWorkspace.getUser(); |
| | | user = userWorkspace.getUser(); |
| | | // 참여 대기 사용자가 현재 해당 업무 공간을 사용하고 있을 경우 즉시 해당 업무 공간에서 튕기게 한다. |
| | | if (user.getLastWorkspaceId().equals(userWorkspace.getWorkspace().getId())) { |
| | | // 업무 공간에 참여하던 사용자에게 제외 알림 및 화면 새로고침 |
| | |
| | | public void disabledUserWorkspace(User user, Workspace workspace) { |
| | | UserWorkspace userWorkspace = this.userWorkspaceRepository.findByUserIdAndWorkspaceId(user.getId(), workspace.getId()); |
| | | |
| | | if (userWorkspace.getManagerYn()) { |
| | | /*if (userWorkspace.getManagerYn()) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.WORKSPACE_MANAGER_NOT_CHANGE_USE_YN)); |
| | | } |
| | | }*/ |
| | | |
| | | userWorkspace.setUseYn(false); |
| | | this.userWorkspaceRepository.saveAndFlush(userWorkspace); |
| | |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public UserWorkspace findMyWorkspace(Long userId) { |
| | | return this.userWorkspaceRepository.findByUserIdAndManagerYn(userId, true); |
| | | //return this.userWorkspaceRepository.findByUserIdAndManagerYn(userId, true); |
| | | return this.userWorkspaceRepository.findByUserId(userId); |
| | | } |
| | | |
| | | // 업무 공간 사용자 연결 아이디로 업무 공간 사용자 연결 정보를 조회한다. |
| | |
| | | // 업무 공간 담당자 여부를 확인한다. |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public boolean checkWorkspaceManager() { |
| | | public boolean checkWorkspaceManager(User user) { |
| | | boolean bIsManager = false; |
| | | User loginUser = this.userService.getUser(this.webAppUtil.getLoginId()); |
| | | |
| | | try |
| | | { |
| | | Workspace workspace = this.workspaceService.getWorkspace(loginUser.getLastWorkspaceId()); // 현재 접속한 업무 공간 |
| | | Workspace workspace = this.workspaceService.getWorkspace(user.getLastWorkspaceId()); // 현재 접속한 업무 공간 |
| | | // 로그인한 사용자가 관리하는 업무 공간을 찾는다. |
| | | UserWorkspace userWorkspace = this.findMyWorkspace(this.webAppUtil.getLoginId()); |
| | | UserWorkspace userWorkspace = this.findMyWorkspace(user.getId()); |
| | | |
| | | bIsManager = workspace.getId().equals(userWorkspace.getWorkspace().getId()); |
| | | } |
| | |
| | | this.userWorkspaceRepository.saveAll(userWorkspaces); |
| | | } |
| | | } |
| | | |
| | | } |