From b8ab6de032d3a6ee029331dbb58d764a5409189b Mon Sep 17 00:00:00 2001 From: 이민희 <mhlee@maprex.co.kr> Date: 월, 28 2월 2022 15:51:13 +0900 Subject: [PATCH] - api로 하위이슈 추가 시 상위이슈의 파트너 정보 적용 --- src/main/java/kr/wisestone/owl/service/impl/UserWorkspaceServiceImpl.java | 112 +++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 79 insertions(+), 33 deletions(-) diff --git a/src/main/java/kr/wisestone/owl/service/impl/UserWorkspaceServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/UserWorkspaceServiceImpl.java index 405cfe5..b192044 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/UserWorkspaceServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/UserWorkspaceServiceImpl.java @@ -2,19 +2,17 @@ import kr.wisestone.owl.constant.Constants; import kr.wisestone.owl.constant.MsgConstants; -import kr.wisestone.owl.domain.User; -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.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; @@ -39,6 +37,12 @@ @Autowired private UserService userService; + + @Autowired + private UserLevelService userLevelService; + + @Autowired + private DepartmentService departmentService; @Autowired private UserWorkspaceMapper userWorkspaceMapper; @@ -75,7 +79,7 @@ public List<UserWorkspaceVo> findUserWorkspace(Map<String, Object> resJsonData, UserWorkspaceCondition condition, Pageable pageable) { - UserWorkspace userWorkspace = this.findMyWorkspace(this.webAppUtil.getLoginId()); + UserWorkspace userWorkspace = this.findWorkspaceManager(this.webAppUtil.getLoginId()); Workspace myWorkspace = userWorkspace.getWorkspace(); condition.setPage(pageable.getPageNumber() * pageable.getPageSize()); condition.setPageSize(pageable.getPageSize()); @@ -89,6 +93,16 @@ 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(), @@ -104,32 +118,57 @@ public void modifyUserWorkspace(UserWorkspaceForm userWorkspaceForm) { UserWorkspace userWorkspace = this.getUserWorkspace(userWorkspaceForm.getId()); + User user = userWorkspace.getUser(); + + // �궗�슜�옄 �벑湲� 蹂�寃� + UserLevel currentUserlevel = user.getUserLevel(); + if (currentUserlevel.getId() != userWorkspaceForm.getLevelId()) { + UserLevel userLevel = this.userLevelService.getUserLevel(userWorkspaceForm.getLevelId()); + user.setUserLevel(userLevel); + userWorkspace.setUser(user); + + // �벑湲� 蹂�寃� �맂 �쑀�� 濡쒓렇�븘�썐 �떆�궎湲� + this.simpMessagingTemplate.convertAndSendToUser(user.getAccount(), "/notification/changeUserLevel", this.messageAccessor.getMessage(MsgConstants.USER_LEVEL_CHANGE)); + + // �꽭�뀡 �뾽�뜲�씠�듃 + //SecurityUtils.setUserToSession(user); + } + + // 遺��꽌 蹂�寃� +// 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()) { - Integer maxUserCount = userWorkspace.getWorkspace().getMaxUser(); // 理쒕� �궗�슜�옄 - Integer activeUserCount = this.countByWorkspaceIdAndUseYn(userWorkspace.getWorkspace().getId(), true); + if (userWorkspace.getUseYn() != userWorkspaceForm.getUseYn()) { + if (!userWorkspace.getUseYn()) { + Integer maxUserCount = userWorkspace.getWorkspace().getMaxUser(); // 理쒕� �궗�슜�옄 + Integer activeUserCount = this.countByWorkspaceIdAndUseYn(userWorkspace.getWorkspace().getId(), true); - // 理쒕� �궗�슜�옄 - �쁽�옱 李몄뿬 �궗�슜�옄媛� 0蹂대떎 �겕�떎硫� 李몄뿬 �긽�깭濡� 蹂�寃� - if ((maxUserCount - activeUserCount) < 1) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.WORKSPACE_MAX_USER_EXCESS_NOT_INCLUDE)); - } - } - else { - User user = userWorkspace.getUser(); - // 李몄뿬 ��湲� �궗�슜�옄媛� �쁽�옱 �빐�떦 �뾽臾� 怨듦컙�쓣 �궗�슜�븯怨� �엳�쓣 寃쎌슦 利됱떆 �빐�떦 �뾽臾� 怨듦컙�뿉�꽌 �뒘湲곌쾶 �븳�떎. - if (user.getLastWorkspaceId().equals(userWorkspace.getWorkspace().getId())){ - // �뾽臾� 怨듦컙�뿉 李몄뿬�븯�뜕 �궗�슜�옄�뿉寃� �젣�쇅 �븣由� 諛� �솕硫� �깉濡쒓퀬移� - this.simpMessagingTemplate.convertAndSendToUser(user.getAccount(), "/notification/workspace-disabled", this.messageAccessor.getMessage(MsgConstants.WORKSPACE_OUT, userWorkspace.getWorkspace().getName())); - } + // 理쒕� �궗�슜�옄 - �쁽�옱 李몄뿬 �궗�슜�옄媛� 0蹂대떎 �겕�떎硫� 李몄뿬 �긽�깭濡� 蹂�寃� + if ((maxUserCount - activeUserCount) < 1) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.WORKSPACE_MAX_USER_EXCESS_NOT_INCLUDE)); + } + } else { + user = userWorkspace.getUser(); + // 李몄뿬 ��湲� �궗�슜�옄媛� �쁽�옱 �빐�떦 �뾽臾� 怨듦컙�쓣 �궗�슜�븯怨� �엳�쓣 寃쎌슦 利됱떆 �빐�떦 �뾽臾� 怨듦컙�뿉�꽌 �뒘湲곌쾶 �븳�떎. + if (user.getLastWorkspaceId().equals(userWorkspace.getWorkspace().getId())) { + // �뾽臾� 怨듦컙�뿉 李몄뿬�븯�뜕 �궗�슜�옄�뿉寃� �젣�쇅 �븣由� 諛� �솕硫� �깉濡쒓퀬移� + this.simpMessagingTemplate.convertAndSendToUser(user.getAccount(), "/notification/workspace-disabled", this.messageAccessor.getMessage(MsgConstants.WORKSPACE_OUT, userWorkspace.getWorkspace().getName())); + } - // 李몄뿬 ��湲� �긽�깭濡� 蹂�寃쏀븯硫� �빐�떦 �궗�슜�옄�쓽 留덉�留� �젒洹� �뾽臾� 怨듦컙�뒗 �옄�떊�씠 愿�由ы븯�뒗 �뾽臾� 怨듦컙濡� 蹂�寃쏀븳�떎. - this.userService.updateLastMyWorkspace(user); + // 李몄뿬 ��湲� �긽�깭濡� 蹂�寃쏀븯硫� �빐�떦 �궗�슜�옄�쓽 留덉�留� �젒洹� �뾽臾� 怨듦컙�뒗 �옄�떊�씠 愿�由ы븯�뒗 �뾽臾� 怨듦컙濡� 蹂�寃쏀븳�떎. + this.userService.updateLastMyWorkspace(user); + } + userWorkspace.setUseYn(!userWorkspace.getUseYn()); } - userWorkspace.setUseYn(!userWorkspace.getUseYn()); this.userWorkspaceRepository.saveAndFlush(userWorkspace); - } @@ -139,10 +178,10 @@ 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); @@ -183,6 +222,13 @@ return this.userWorkspaceRepository.findByUserIdAndManagerYn(userId, true); } + // �썙�겕�뒪�럹�씠�뒪 愿�由ъ옄 議고쉶 + @Override + @Transactional(readOnly = true) + public UserWorkspace findWorkspaceManager(Long userId) { + return this.userWorkspaceRepository.findByUserId(userId); + } + // �뾽臾� 怨듦컙 �궗�슜�옄 �뿰寃� �븘�씠�뵒濡� �뾽臾� 怨듦컙 �궗�슜�옄 �뿰寃� �젙蹂대�� 議고쉶�븳�떎. @Override @Transactional(readOnly = true) @@ -205,15 +251,14 @@ // �뾽臾� 怨듦컙 �떞�떦�옄 �뿬遺�瑜� �솗�씤�븳�떎. @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()); } @@ -250,4 +295,5 @@ this.userWorkspaceRepository.saveAll(userWorkspaces); } } + } -- Gitblit v1.8.0