From 3aee03aa12596d719654fd53829533014875f781 Mon Sep 17 00:00:00 2001 From: HyunJun Mun <137624597+Mouon@users.noreply.github.com> Date: Sat, 6 Jul 2024 23:12:15 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EB=91=90=20=EC=BF=BC=EB=A6=AC?= =?UTF-8?q?=EB=A5=BC=20=ED=95=98=EB=82=98=EC=9D=98=20=ED=8A=B8=EB=9E=9C?= =?UTF-8?q?=EC=9E=AD=EC=85=98=EC=97=90=EC=84=9C=20=EC=8B=A4=ED=96=89?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 조건문 수정 --- .../api_server/repository/MemberstudyroomRepository.java | 2 +- .../linkode/api_server/repository/StudyroomRepository.java | 1 - .../java/com/linkode/api_server/service/StudyroomService.java | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/linkode/api_server/repository/MemberstudyroomRepository.java b/src/main/java/com/linkode/api_server/repository/MemberstudyroomRepository.java index 36e3d80..1a83578 100644 --- a/src/main/java/com/linkode/api_server/repository/MemberstudyroomRepository.java +++ b/src/main/java/com/linkode/api_server/repository/MemberstudyroomRepository.java @@ -16,7 +16,7 @@ public interface MemberstudyroomRepository extends JpaRepository findRoleByMemberIdAndStudyroomId(long studyroomId, long memberId); - @Transactional + @Modifying @Query("UPDATE MemberStudyroom ms SET ms.status = 'DELETE' WHERE ms.studyroom.studyroomId = :studyroomId") int deleteMemberStudyroom(long studyroomId); diff --git a/src/main/java/com/linkode/api_server/repository/StudyroomRepository.java b/src/main/java/com/linkode/api_server/repository/StudyroomRepository.java index 4aa27f2..d2d0865 100644 --- a/src/main/java/com/linkode/api_server/repository/StudyroomRepository.java +++ b/src/main/java/com/linkode/api_server/repository/StudyroomRepository.java @@ -12,7 +12,6 @@ @Repository @Transactional(readOnly = true) public interface StudyroomRepository extends JpaRepository { - @Transactional @Modifying @Query("UPDATE Studyroom sr SET sr.status = 'DELETE' WHERE sr.studyroomId = :studyroomId") int deleteStudyroom(long studyroomId); diff --git a/src/main/java/com/linkode/api_server/service/StudyroomService.java b/src/main/java/com/linkode/api_server/service/StudyroomService.java index 20a6aac..40f2947 100644 --- a/src/main/java/com/linkode/api_server/service/StudyroomService.java +++ b/src/main/java/com/linkode/api_server/service/StudyroomService.java @@ -29,6 +29,7 @@ public class StudyroomService { @Autowired private MemberRepository memberRepository; + @Transactional public BaseExceptionResponseStatus deleteStudyroom(long studyroomId, long memberId) { @@ -45,8 +46,7 @@ public BaseExceptionResponseStatus deleteStudyroom(long studyroomId, long member MemberRole memberRole = optionalMemberRole.orElseThrow(() -> new IllegalArgumentException("Error because of Invalid Member Id or Invalid StudyRoom Id")); if (memberRole .equals(MemberRole.CAPTAIN)) { - if(studyroomRepository.deleteStudyroom(studyroomId)==1){ - memberstudyroomRepository.deleteMemberStudyroom(studyroomId); + if(studyroomRepository.deleteStudyroom(studyroomId)==1 && memberstudyroomRepository.deleteMemberStudyroom(studyroomId)>0){ log.info("Success delete studyRoom in Service layer"); return BaseExceptionResponseStatus.SUCCESS; }else {