From f2b3cbd3a0639f55eef38a4e90ad52ef8e63b1c1 Mon Sep 17 00:00:00 2001 From: 이민희 <mhlee@maprex.co.kr> Date: 목, 04 11월 2021 20:24:32 +0900 Subject: [PATCH] "사용자 관리" 프론트 수정 완료! --- src/main/java/kr/wisestone/owl/service/impl/UserWorkspaceServiceImpl.java | 60 ++++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 38 insertions(+), 22 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..6271319 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/UserWorkspaceServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/UserWorkspaceServiceImpl.java @@ -3,11 +3,13 @@ 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.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; @@ -39,6 +41,9 @@ @Autowired private UserService userService; + + @Autowired + private UserLevelService userLevelService; @Autowired private UserWorkspaceMapper userWorkspaceMapper; @@ -104,32 +109,43 @@ public void modifyUserWorkspace(UserWorkspaceForm userWorkspaceForm) { UserWorkspace userWorkspace = this.getUserWorkspace(userWorkspaceForm.getId()); - // 李몄뿬濡� �긽�깭瑜� 蹂�寃쏀븯�젮怨� �븷�븣 - 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 { + UserLevel currentUserlevel = userWorkspace.getUser().getUserLevel(); + if (currentUserlevel.getId() != userWorkspaceForm.getLevelId()) { + // �궗�슜�옄 �벑湲� 蹂�寃쎌떆 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())); - } - - // 李몄뿬 ��湲� �긽�깭濡� 蹂�寃쏀븯硫� �빐�떦 �궗�슜�옄�쓽 留덉�留� �젒洹� �뾽臾� 怨듦컙�뒗 �옄�떊�씠 愿�由ы븯�뒗 �뾽臾� 怨듦컙濡� 蹂�寃쏀븳�떎. - this.userService.updateLastMyWorkspace(user); + UserLevel userLevel = this.userLevelService.getUserLevel(userWorkspaceForm.getLevelId()); + user.setUserLevel(userLevel); + userWorkspace.setUser(user); } - userWorkspace.setUseYn(!userWorkspace.getUseYn()); - this.userWorkspaceRepository.saveAndFlush(userWorkspace); + //todo 遺��꽌 蹂�寃쎌떆 + // 李몄뿬濡� �긽�깭瑜� 蹂�寃쏀븯�젮怨� �븷�븣 + 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())); + } + + // 李몄뿬 ��湲� �긽�깭濡� 蹂�寃쏀븯硫� �빐�떦 �궗�슜�옄�쓽 留덉�留� �젒洹� �뾽臾� 怨듦컙�뒗 �옄�떊�씠 愿�由ы븯�뒗 �뾽臾� 怨듦컙濡� 蹂�寃쏀븳�떎. + this.userService.updateLastMyWorkspace(user); + } + userWorkspace.setUseYn(!userWorkspace.getUseYn()); + } + + this.userWorkspaceRepository.saveAndFlush(userWorkspace); } -- Gitblit v1.8.0