From 64c63b085b66e33476bff440006f5a7cd496d095 Mon Sep 17 00:00:00 2001 From: jenny <88226911+kmjenny@users.noreply.github.com> Date: Wed, 5 Jun 2024 16:14:17 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[chore]=20#58=20Health=20check=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 0a01a45..d6ac2c1 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' - //Database + // Database implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' runtimeOnly 'com.mysql:mysql-connector-j' @@ -51,8 +51,11 @@ dependencies { implementation 'io.jsonwebtoken:jjwt-impl:0.11.5' implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5' - //FCM + // FCM implementation 'com.google.firebase:firebase-admin:9.2.0' + + // Health check + implementation 'org.springframework.boot:spring-boot-starter-actuator' } tasks.named('test') { From e0c5a9567fdcb612c3608a9e00ba9706df357b1b Mon Sep 17 00:00:00 2001 From: jenny <88226911+kmjenny@users.noreply.github.com> Date: Wed, 5 Jun 2024 16:15:02 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[fix]=20#58=20Room=20=EC=9E=85=EC=9E=A5=20?= =?UTF-8?q?=EB=B6=84=EA=B8=B0=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/exception/ForbiddenException.java | 4 ++-- .../server/exception/code/BusinessErrorCode.java | 1 + .../server/exception/code/ForbiddenErrorCode.java | 1 + .../server/repository/ProfileRepository.java | 2 ++ .../server/service/profile/ProfileRetriever.java | 4 ++++ .../telepigeon/server/service/room/RoomService.java | 12 ++++++++++++ 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/telepigeon/server/exception/ForbiddenException.java b/src/main/java/com/telepigeon/server/exception/ForbiddenException.java index 539ba49..71a2743 100644 --- a/src/main/java/com/telepigeon/server/exception/ForbiddenException.java +++ b/src/main/java/com/telepigeon/server/exception/ForbiddenException.java @@ -1,11 +1,11 @@ package com.telepigeon.server.exception; -import com.telepigeon.server.exception.code.NotFoundErrorCode; +import com.telepigeon.server.exception.code.ForbiddenErrorCode; import lombok.Getter; import lombok.RequiredArgsConstructor; @Getter @RequiredArgsConstructor public class ForbiddenException extends RuntimeException { - private final NotFoundErrorCode errorCode; + private final ForbiddenErrorCode errorCode; } diff --git a/src/main/java/com/telepigeon/server/exception/code/BusinessErrorCode.java b/src/main/java/com/telepigeon/server/exception/code/BusinessErrorCode.java index ce53854..e79ac7d 100644 --- a/src/main/java/com/telepigeon/server/exception/code/BusinessErrorCode.java +++ b/src/main/java/com/telepigeon/server/exception/code/BusinessErrorCode.java @@ -16,6 +16,7 @@ public enum BusinessErrorCode implements DefaultErrorCode{ FCM_SERVER_ERROR(HttpStatus.SERVICE_UNAVAILABLE, "external", "FCM 서버 오류"), NAVER_CLOUD_SERVER_ERROR(HttpStatus.SERVICE_UNAVAILABLE, "external", "네이버 클라우드 서버 오류"), OPEN_AI_SERVER_ERROR(HttpStatus.SERVICE_UNAVAILABLE, "external", "OpenAI 서버 오류"), + REENTER_ERROR(HttpStatus.OK, "conflict", "이미 입장하신 방입니다."), ; @JsonIgnore private final HttpStatus httpStatus; diff --git a/src/main/java/com/telepigeon/server/exception/code/ForbiddenErrorCode.java b/src/main/java/com/telepigeon/server/exception/code/ForbiddenErrorCode.java index e8874ad..c9023a0 100644 --- a/src/main/java/com/telepigeon/server/exception/code/ForbiddenErrorCode.java +++ b/src/main/java/com/telepigeon/server/exception/code/ForbiddenErrorCode.java @@ -10,6 +10,7 @@ public enum ForbiddenErrorCode implements DefaultErrorCode{ FORBIDDEN(HttpStatus.FORBIDDEN, "error", "접근 권한이 없습니다."), + ENTER_FORBIDDEN(HttpStatus.FORBIDDEN, "error", "이미 매칭이 완료된 방입니다."), ; @JsonIgnore diff --git a/src/main/java/com/telepigeon/server/repository/ProfileRepository.java b/src/main/java/com/telepigeon/server/repository/ProfileRepository.java index a0624d9..9baec81 100644 --- a/src/main/java/com/telepigeon/server/repository/ProfileRepository.java +++ b/src/main/java/com/telepigeon/server/repository/ProfileRepository.java @@ -13,5 +13,7 @@ public interface ProfileRepository extends JpaRepository { Optional findByUserAndRoom(User user, Room room); Optional findByUserNotAndRoom(User user, Room room); boolean existsByUserNotAndRoom(User user, Room room); + + boolean existsByUserAndRoom(User user, Room room); List findAllByUserId(Long userId); } diff --git a/src/main/java/com/telepigeon/server/service/profile/ProfileRetriever.java b/src/main/java/com/telepigeon/server/service/profile/ProfileRetriever.java index 945c38f..3c1fc89 100644 --- a/src/main/java/com/telepigeon/server/service/profile/ProfileRetriever.java +++ b/src/main/java/com/telepigeon/server/service/profile/ProfileRetriever.java @@ -30,6 +30,10 @@ public Profile findByUserNotAndRoom(final User user, final Room room) { public boolean existsByUserNotAndRoom(final User user, final Room room) { return profileRepository.existsByUserNotAndRoom(user, room); } + + public boolean existsByUserAndRoom(final User user, final Room room) { + return profileRepository.existsByUserAndRoom(user, room); + } public List findByUserId(final long userId) { return profileRepository.findAllByUserId(userId); diff --git a/src/main/java/com/telepigeon/server/service/room/RoomService.java b/src/main/java/com/telepigeon/server/service/room/RoomService.java index 3816b3d..e078de3 100644 --- a/src/main/java/com/telepigeon/server/service/room/RoomService.java +++ b/src/main/java/com/telepigeon/server/service/room/RoomService.java @@ -7,6 +7,10 @@ import com.telepigeon.server.dto.room.response.RoomInfoDto; import com.telepigeon.server.dto.room.response.RoomListDto; import com.telepigeon.server.dto.type.FcmContent; +import com.telepigeon.server.exception.BusinessException; +import com.telepigeon.server.exception.ForbiddenException; +import com.telepigeon.server.exception.code.BusinessErrorCode; +import com.telepigeon.server.exception.code.ForbiddenErrorCode; import com.telepigeon.server.repository.RoomRepository; import com.telepigeon.server.service.answer.AnswerRemover; import com.telepigeon.server.service.answer.AnswerRetriever; @@ -119,6 +123,14 @@ public Profile enterRoom(final RoomEnterDto roomEnterDto, final Long userId) { User user = userRetriever.findById(userId); Room room = roomRetriever.findByCode(roomEnterDto.code()); + if (profileRetriever.existsByUserAndRoom(user, room)) { + throw new BusinessException(BusinessErrorCode.REENTER_ERROR); + } + + if ((profileRetriever.findAll()).size()==2) { + throw new ForbiddenException(ForbiddenErrorCode.ENTER_FORBIDDEN); + } + Profile profile = profileSaver.save(Profile.create(user, room)); Profile receiver = profileRetriever.findByUserNotAndRoom(user, room); sendQuestionFirst(receiver, profile); From 8f370c1625fd2b12ec3dccc32ed1204e359b62bd Mon Sep 17 00:00:00 2001 From: jenny <88226911+kmjenny@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:11:22 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[fix]=20#58=20=EC=9D=B4=EB=AF=B8=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=EB=90=9C=20ROOM=20=EC=9E=85=EC=9E=A5=20?= =?UTF-8?q?=EC=8B=9C=20=EC=B2=98=EB=A6=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/telepigeon/server/exception/code/BusinessErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/telepigeon/server/exception/code/BusinessErrorCode.java b/src/main/java/com/telepigeon/server/exception/code/BusinessErrorCode.java index e79ac7d..2f50a05 100644 --- a/src/main/java/com/telepigeon/server/exception/code/BusinessErrorCode.java +++ b/src/main/java/com/telepigeon/server/exception/code/BusinessErrorCode.java @@ -17,6 +17,7 @@ public enum BusinessErrorCode implements DefaultErrorCode{ NAVER_CLOUD_SERVER_ERROR(HttpStatus.SERVICE_UNAVAILABLE, "external", "네이버 클라우드 서버 오류"), OPEN_AI_SERVER_ERROR(HttpStatus.SERVICE_UNAVAILABLE, "external", "OpenAI 서버 오류"), REENTER_ERROR(HttpStatus.OK, "conflict", "이미 입장하신 방입니다."), + ROOM_FULL_ERROR(HttpStatus.OK, "conflict", "이미 매칭이 완료된 방입니다."), ; @JsonIgnore private final HttpStatus httpStatus; From 4a8f8755ca6366e2eba05581cad07c0452adf1e0 Mon Sep 17 00:00:00 2001 From: jenny <88226911+kmjenny@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:11:48 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[fix]=20#58=20=EC=9D=B4=EB=AF=B8=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=EB=90=9C=20ROOM=20=EC=9E=85=EC=9E=A5=20?= =?UTF-8?q?=EC=8B=9C=20=EC=B2=98=EB=A6=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../telepigeon/server/exception/code/ForbiddenErrorCode.java | 1 - .../java/com/telepigeon/server/service/room/RoomService.java | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/telepigeon/server/exception/code/ForbiddenErrorCode.java b/src/main/java/com/telepigeon/server/exception/code/ForbiddenErrorCode.java index c9023a0..e8874ad 100644 --- a/src/main/java/com/telepigeon/server/exception/code/ForbiddenErrorCode.java +++ b/src/main/java/com/telepigeon/server/exception/code/ForbiddenErrorCode.java @@ -10,7 +10,6 @@ public enum ForbiddenErrorCode implements DefaultErrorCode{ FORBIDDEN(HttpStatus.FORBIDDEN, "error", "접근 권한이 없습니다."), - ENTER_FORBIDDEN(HttpStatus.FORBIDDEN, "error", "이미 매칭이 완료된 방입니다."), ; @JsonIgnore diff --git a/src/main/java/com/telepigeon/server/service/room/RoomService.java b/src/main/java/com/telepigeon/server/service/room/RoomService.java index e078de3..c1711e0 100644 --- a/src/main/java/com/telepigeon/server/service/room/RoomService.java +++ b/src/main/java/com/telepigeon/server/service/room/RoomService.java @@ -8,9 +8,7 @@ import com.telepigeon.server.dto.room.response.RoomListDto; import com.telepigeon.server.dto.type.FcmContent; import com.telepigeon.server.exception.BusinessException; -import com.telepigeon.server.exception.ForbiddenException; import com.telepigeon.server.exception.code.BusinessErrorCode; -import com.telepigeon.server.exception.code.ForbiddenErrorCode; import com.telepigeon.server.repository.RoomRepository; import com.telepigeon.server.service.answer.AnswerRemover; import com.telepigeon.server.service.answer.AnswerRetriever; @@ -128,7 +126,7 @@ public Profile enterRoom(final RoomEnterDto roomEnterDto, final Long userId) { } if ((profileRetriever.findAll()).size()==2) { - throw new ForbiddenException(ForbiddenErrorCode.ENTER_FORBIDDEN); + throw new BusinessException(BusinessErrorCode.ROOM_FULL_ERROR); } Profile profile = profileSaver.save(Profile.create(user, room)); From 4fba848d5617399f1bb2e496a5aa89debccd5fdb Mon Sep 17 00:00:00 2001 From: jenny <88226911+kmjenny@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:42:03 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[fix]=20#58=20=EC=9D=B4=EB=AF=B8=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=EB=90=9C=20ROOM=20=EC=9E=85=EC=9E=A5=20?= =?UTF-8?q?=EC=8B=9C=20=EC=B2=98=EB=A6=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/telepigeon/server/service/profile/ProfileService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/telepigeon/server/service/profile/ProfileService.java b/src/main/java/com/telepigeon/server/service/profile/ProfileService.java index 9973e34..481ae02 100644 --- a/src/main/java/com/telepigeon/server/service/profile/ProfileService.java +++ b/src/main/java/com/telepigeon/server/service/profile/ProfileService.java @@ -40,6 +40,7 @@ public ProfileInfoDto getProfileExtraInfo(final Long roomId, final Long userId) Room room = roomRetriever.findById(roomId); User user = userRetriever.findById(userId); Profile profile = profileRetriever.findByUserAndRoom(user, room); + String gender = profile.getGender()!=null?profile.getGender().getContent():"-"; String ageRange = profile.getAgeRange()!=null?profile.getAgeRange().getContent():"-"; String relation = profile.getRelation()!=null?profile.getRelation().getContent():"-"; @@ -64,7 +65,7 @@ public Profile updateProfileInfo( String keywords = ""; if(profileDto.keywords()!=null) { keywords = String.join(",", profileDto.keywords()); - }; + } profileUpdater.updateProfileInfo( profile, From 6b385551159333af62bde7c319888061ed31d1c6 Mon Sep 17 00:00:00 2001 From: jenny <88226911+kmjenny@users.noreply.github.com> Date: Wed, 5 Jun 2024 23:58:46 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[fix]=20#58=20CD.yml=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CD.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml index bb7c9a0..630a0e1 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/CD.yml @@ -19,10 +19,11 @@ jobs: - name: create-json id: create-json - uses: jsdaniell/create-json@1.1.2 + uses: jsdaniell/create-json@1.2.3 with: - name: "src/main/resources/firebase.json" + name: "firebase.json" json: ${{ secrets.FIREBASE_JSON }} + dir: 'src/main/resources/' - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2.9.1 @@ -54,4 +55,4 @@ jobs: key: ${{ secrets.SERVER_KEY }} script: | cd ~ - ./deploy.sh + ./deploy.sh \ No newline at end of file