From 96457c3d2be65dbe165e43a24091cefcf71c13e0 Mon Sep 17 00:00:00 2001 From: JIN-076 <57834671+JIN-076@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:22:12 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[BUG]=20=EC=97=85=EC=A0=81=20=EB=8B=AC?= =?UTF-8?q?=EC=84=B1=20=EA=B4=80=EB=A0=A8=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95,=20=EB=B9=84=ED=9A=8C=EC=9B=90=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=95=84=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=EB=84=A4=EC=9D=B4=EC=85=98=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#349)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [BUG] 비회원용 프로필 카드에 대한 페이지네이션 cursorId 로직 수정 * [BUG] 업적 달성 조건 검증 로직에서 오류 수정 --- .../common/aop/AchievementEventAspect.java | 17 +++++++++++++---- .../ProfileCardRepositoryCustomImpl.java | 12 +++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/oeid/mogakgo/common/aop/AchievementEventAspect.java b/src/main/java/io/oeid/mogakgo/common/aop/AchievementEventAspect.java index f2876c92..6a46e901 100644 --- a/src/main/java/io/oeid/mogakgo/common/aop/AchievementEventAspect.java +++ b/src/main/java/io/oeid/mogakgo/common/aop/AchievementEventAspect.java @@ -1,12 +1,15 @@ package io.oeid.mogakgo.common.aop; import static io.oeid.mogakgo.exception.code.ErrorCode404.PROJECT_JOIN_REQUEST_NOT_FOUND; +import static io.oeid.mogakgo.exception.code.ErrorCode404.PROJECT_NOT_FOUND; import io.oeid.mogakgo.domain.achievement.application.AchievementEventService; import io.oeid.mogakgo.domain.achievement.application.AchievementProgressService; import io.oeid.mogakgo.domain.achievement.domain.entity.enums.ActivityType; import io.oeid.mogakgo.domain.matching.application.MatchingService; import io.oeid.mogakgo.domain.profile.presentation.dto.req.UserProfileLikeCreateAPIReq; +import io.oeid.mogakgo.domain.project.domain.entity.Project; +import io.oeid.mogakgo.domain.project.exception.ProjectException; import io.oeid.mogakgo.domain.project.infrastructure.ProjectJpaRepository; import io.oeid.mogakgo.domain.project.presentation.dto.req.ProjectCreateReq; import io.oeid.mogakgo.domain.project_join_req.application.dto.req.ProjectJoinCreateReq; @@ -62,9 +65,9 @@ public void createLikeExecution() {} public void publishCompletedEvent(JoinPoint joinPoint, Long userId, ReviewCreateReq request) { // -- '리뷰' 잔디력이 업데이트되는 사용자에 대한 업적 이벤트 발행 - User user = userCommonService.getUserById(userId); - achievementEventService.publishCompletedEventWithVerify(userId, - ActivityType.FRESH_DEVELOPER, user.getJandiRate()); + User receiver = userCommonService.getUserById(request.getReceiverId()); + achievementEventService.publishCompletedEventWithVerify(receiver.getId(), + ActivityType.FRESH_DEVELOPER, receiver.getJandiRate()); } @Transactional(propagation = Propagation.REQUIRES_NEW) @@ -88,9 +91,10 @@ public void publishSequenceEvent(JoinPoint joinPoint, Long userId, ProjectCreate public void publishAccumulateEvent(JoinPoint joinPoint, Long userId, ProjectJoinCreateReq request) { // -- '생성자' 매칭 요청을 수신한 사용자에 대한 업적 이벤트 발행 + Project project = getProject(request.getProjectId()); achievementEventService.publishAccumulateEventWithVerify( userId, ActivityType.CATCH_ME_IF_YOU_CAN, - getAccumulatedProgressCount(userId, ActivityType.CATCH_ME_IF_YOU_CAN) + getAccumulatedProgressCount(project.getCreator().getId(), ActivityType.CATCH_ME_IF_YOU_CAN) ); } @@ -146,6 +150,11 @@ public void publishEventAboutLike(JoinPoint joinPoint, Long userId, UserProfileL ); } + private Project getProject(Long projectId) { + return projectRepository.findById(projectId) + .orElseThrow(() -> new ProjectException(PROJECT_NOT_FOUND)); + } + private Integer checkCreatedProjectCountByRegion(Long userId) { Integer progressCount = projectRepository.getRegionCountByUserId(userId); return progressCount.equals(MAX_SERVICE_AREA) ? 1 : 0; diff --git a/src/main/java/io/oeid/mogakgo/domain/profile/infrastructure/ProfileCardRepositoryCustomImpl.java b/src/main/java/io/oeid/mogakgo/domain/profile/infrastructure/ProfileCardRepositoryCustomImpl.java index c128458a..312b27d4 100644 --- a/src/main/java/io/oeid/mogakgo/domain/profile/infrastructure/ProfileCardRepositoryCustomImpl.java +++ b/src/main/java/io/oeid/mogakgo/domain/profile/infrastructure/ProfileCardRepositoryCustomImpl.java @@ -58,10 +58,16 @@ public CursorPaginationResult findByConditionWithPaginati public List findByConditionWithPaginationPublic(@NonNull Region region, Long cursorId, @NonNull Integer pageSize) { - return jpaQueryFactory.selectFrom(profileCard).innerJoin(profileCard.user, user) + return jpaQueryFactory.selectFrom(profileCard) + .innerJoin(profileCard.user, user) .on(profileCard.user.id.eq(user.id)) - .where(cursorIdCondition(cursorId), regionEq(region), deletedProfileCardEq()) - .orderBy(profileCard.id.desc()).limit(pageSize + 1L).fetch(); + .where( + cursorIdCondition(cursorId), + regionEq(region), + deletedProfileCardEq() + ) + .orderBy(user.id.desc()) + .limit(pageSize + 1L).fetch(); } private Boolean validateProfileCardLikeBySenderId(Long receiverId, Long userId) { From 2c84dfcd2ece29a8fc133c85b5dd34afe844ad10 Mon Sep 17 00:00:00 2001 From: KyungMin Lee Date: Fri, 29 Mar 2024 21:24:23 +0900 Subject: [PATCH 2/4] Fix/#351 signup bug (#352) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FEAT] 회원 가입 검증 로직 추가 * [TEST] 회원 가입 검증 로직 테스트 --- .../io/oeid/mogakgo/domain/user/domain/User.java | 3 +++ .../mogakgo/exception/code/ErrorCode400.java | 1 + .../domain/user/application/UserServiceTest.java | 16 ++++++++++++++++ .../domain/user/domain/UserDomainTest.java | 12 ++++++++++++ 4 files changed, 32 insertions(+) diff --git a/src/main/java/io/oeid/mogakgo/domain/user/domain/User.java b/src/main/java/io/oeid/mogakgo/domain/user/domain/User.java index a1b8425c..43f0281a 100644 --- a/src/main/java/io/oeid/mogakgo/domain/user/domain/User.java +++ b/src/main/java/io/oeid/mogakgo/domain/user/domain/User.java @@ -188,6 +188,9 @@ public void deleteAllDevelopLanguageTags() { } public void signUpComplete() { + if (Boolean.TRUE.equals(signupYn)) { + throw new UserException(ErrorCode400.USER_ALREADY_SIGNUP); + } this.signupYn = true; } diff --git a/src/main/java/io/oeid/mogakgo/exception/code/ErrorCode400.java b/src/main/java/io/oeid/mogakgo/exception/code/ErrorCode400.java index b9ffb769..8adbfbcb 100644 --- a/src/main/java/io/oeid/mogakgo/exception/code/ErrorCode400.java +++ b/src/main/java/io/oeid/mogakgo/exception/code/ErrorCode400.java @@ -38,6 +38,7 @@ public enum ErrorCode400 implements ErrorCode { USER_AVAILABLE_LIKE_COUNT_IS_ZERO("E020107", "취소할 수 있는 찔러보기 요청이 존재하지 않습니다."), USER_ID_NOT_NULL("E020001", "유저 아이디는 필수값입니다."), USER_AVATAR_URL_NOT_NULL("E020109", "유저 프로필 이미지는 필수값입니다."), + USER_ALREADY_SIGNUP("E020110", "이미 회원가입한 유저입니다."), PROFILE_CARD_LIKE_ALREADY_EXIST("E040102", "이미 찔러보기 요청을 전송한 프로필 카드에 찔러보기 요청을 전송할 수 없습니다."), INVALID_PROFILE_CARD_LIKE_RECEIVER_INFO("E040103", "찔러보기 요청의 사용자가 존재하지 않습니다."), diff --git a/src/test/java/io/oeid/mogakgo/domain/user/application/UserServiceTest.java b/src/test/java/io/oeid/mogakgo/domain/user/application/UserServiceTest.java index 650f7f8f..28a38b92 100644 --- a/src/test/java/io/oeid/mogakgo/domain/user/application/UserServiceTest.java +++ b/src/test/java/io/oeid/mogakgo/domain/user/application/UserServiceTest.java @@ -99,6 +99,22 @@ void init() { // Assert } + @Test + void 유저_회원가입_실패_이미_회원가입이_완료된_계정() { + // Arrange + user.signUpComplete(); + var expectedUserId = 1L; + var expectedUsername = "tidavid1"; + var expectedWantedJobs = List.of(WantedJob.BACKEND, WantedJob.DEVOPS); + var userSignUpRequest = new UserSignUpRequest(expectedUserId, expectedUsername, + expectedWantedJobs); + when(userCommonService.getUserById(expectedUserId)).thenReturn(user); + // Act & Assert + assertThatThrownBy(() -> userService.userSignUp(userSignUpRequest)) + .isInstanceOf(UserException.class) + .hasFieldOrPropertyWithValue("errorCode", ErrorCode400.USER_ALREADY_SIGNUP); + } + @Test void 유저_삭제_성공() { // Arrange diff --git a/src/test/java/io/oeid/mogakgo/domain/user/domain/UserDomainTest.java b/src/test/java/io/oeid/mogakgo/domain/user/domain/UserDomainTest.java index b08f9eda..dfa4612e 100644 --- a/src/test/java/io/oeid/mogakgo/domain/user/domain/UserDomainTest.java +++ b/src/test/java/io/oeid/mogakgo/domain/user/domain/UserDomainTest.java @@ -148,6 +148,18 @@ void init() { .hasFieldOrPropertyWithValue("signupYn", true); } + @Test + void 유저_회원_가입_실패_이미_유저가_회원가입을_완료한_경우() { + // Arrange + user.signUpComplete(); + // Act + assertThatThrownBy(() -> user.signUpComplete()) + .isInstanceOf(UserException.class) + .hasFieldOrPropertyWithValue( + "errorCode", ErrorCode400.USER_ALREADY_SIGNUP + ); + } + @Test void 유저_정보_업데이트_성공() { // Arrange From a2d895c37804b75ee9662aac62d3afd142d87c48 Mon Sep 17 00:00:00 2001 From: KyungMin Lee Date: Fri, 29 Mar 2024 21:24:48 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[FEAT]=20=ED=94=84=EB=A1=9C=EC=A0=9D?= =?UTF-8?q?=ED=8A=B8=20=EC=A2=85=EB=A3=8C=EC=8B=9C=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=EB=B0=A9=20=EC=A2=85=EB=A3=8C=20=EC=8A=A4=EC=BC=80=EC=A5=B4?= =?UTF-8?q?=EB=A7=81=20=EC=B6=94=EA=B0=80=20(#353)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oeid/mogakgo/scheduler/FinishedProjectScheduler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/io/oeid/mogakgo/scheduler/FinishedProjectScheduler.java b/src/main/java/io/oeid/mogakgo/scheduler/FinishedProjectScheduler.java index 1eb4d762..aa70b383 100644 --- a/src/main/java/io/oeid/mogakgo/scheduler/FinishedProjectScheduler.java +++ b/src/main/java/io/oeid/mogakgo/scheduler/FinishedProjectScheduler.java @@ -42,6 +42,7 @@ public void executeSqlFile() { String sql = loadSqlFromFile(statement); jdbcTemplate.execute(sql); } + closeChatRoom(); sendReviewNotification(); sendMatchFailNotification(); } @@ -82,4 +83,10 @@ private void sendMatchFailNotification() { ); } + private void closeChatRoom() { + jdbcTemplate.execute( + "UPDATE chat_room_tb SET status = 'CLOSE' WHERE project_id IN (SELECT pt.id FROM project_tb pt WHERE pt.project_status = 'FINISHED')" + ); + } + } From e6fda0f5d5b7e58e3ce1b360d2086580311d0ee2 Mon Sep 17 00:00:00 2001 From: JIN-076 <57834671+JIN-076@users.noreply.github.com> Date: Fri, 29 Mar 2024 22:00:33 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[REFACT]=20=EC=82=AC=EC=9A=A9=EC=9E=90?= =?UTF-8?q?=EC=9D=98=20=EC=97=85=EC=A0=81=20=EC=83=81=EC=84=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=8B=9C,=20=EC=97=85=EC=A0=81=EC=9D=98=20progress?= =?UTF-8?q?Level=20=ED=95=84=EB=93=9C=EB=8F=84=20=EA=B0=99=EC=9D=B4=20?= =?UTF-8?q?=EC=A0=84=EB=8B=AC=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(#355)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../achievement/application/AchievementService.java | 1 + .../application/dto/res/UserAchievementInfoRes.java | 7 +++++-- .../UserAchievementRepositoryCustomImpl.java | 12 ++++++++---- .../presentation/dto/res/AchievementInfoAPIRes.java | 4 ++++ .../dto/res/UserAchievementDetailAPIRes.java | 4 ++++ 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/application/AchievementService.java b/src/main/java/io/oeid/mogakgo/domain/achievement/application/AchievementService.java index 963c9f3a..55961b23 100644 --- a/src/main/java/io/oeid/mogakgo/domain/achievement/application/AchievementService.java +++ b/src/main/java/io/oeid/mogakgo/domain/achievement/application/AchievementService.java @@ -80,6 +80,7 @@ private List getSequenceAchievementInfoAboutUser(Long us .title(achievement.getTitle()) .imgUrl(achievement.getImgUrl()) .description(achievement.getDescription()) + .progressLevel(achievement.getProgressLevel()) .requirementType(achievement.getRequirementType()) .requirementValue(achievement.getRequirementValue()) .progressCount(map.get(achievement.getActivityType())) diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/application/dto/res/UserAchievementInfoRes.java b/src/main/java/io/oeid/mogakgo/domain/achievement/application/dto/res/UserAchievementInfoRes.java index 790fd3eb..9b8a8930 100644 --- a/src/main/java/io/oeid/mogakgo/domain/achievement/application/dto/res/UserAchievementInfoRes.java +++ b/src/main/java/io/oeid/mogakgo/domain/achievement/application/dto/res/UserAchievementInfoRes.java @@ -13,6 +13,7 @@ public class UserAchievementInfoRes { private final String title; private final String imgUrl; private final String description; + private final Integer progressLevel; private final RequirementType requirementType; private final Integer requirementValue; private final Integer progressCount; @@ -20,13 +21,14 @@ public class UserAchievementInfoRes { @Builder private UserAchievementInfoRes(Long userId, Long achievementId, String title, String imgUrl, - String description, RequirementType requirementType, Integer requirementValue, - Integer progressCount, Boolean completed) { + String description, Integer progressLevel, RequirementType requirementType, + Integer requirementValue, Integer progressCount, Boolean completed) { this.userId = userId; this.achievementId = achievementId; this.title = title; this.imgUrl = imgUrl; this.description = description; + this.progressLevel = progressLevel; this.requirementType = requirementType; this.requirementValue = requirementValue; this.progressCount = progressCount; @@ -40,6 +42,7 @@ public static UserAchievementInfoRes of(UserAchievement userAchievement, Integer userAchievement.getAchievement().getTitle(), userAchievement.getAchievement().getImgUrl(), userAchievement.getAchievement().getDescription(), + userAchievement.getAchievement().getProgressLevel(), userAchievement.getAchievement().getRequirementType(), userAchievement.getAchievement().getRequirementValue(), progressCount, diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/infrastructure/UserAchievementRepositoryCustomImpl.java b/src/main/java/io/oeid/mogakgo/domain/achievement/infrastructure/UserAchievementRepositoryCustomImpl.java index ce34ec79..dac31ac4 100644 --- a/src/main/java/io/oeid/mogakgo/domain/achievement/infrastructure/UserAchievementRepositoryCustomImpl.java +++ b/src/main/java/io/oeid/mogakgo/domain/achievement/infrastructure/UserAchievementRepositoryCustomImpl.java @@ -41,6 +41,7 @@ public List getAchievementInfoAboutUser(Long userId) { achievement.title, achievement.imgUrl, achievement.description, + achievement.progressLevel, achievement.requirementType, achievement.requirementValue, Expressions.numberPath(Long.class, String.valueOf(0)), @@ -66,6 +67,7 @@ public List getAchievementInfoAboutUser(Long userId) { userAchievement.achievement.title, userAchievement.achievement.imgUrl, userAchievement.achievement.description, + userAchievement.achievement.progressLevel, userAchievement.achievement.requirementType, userAchievement.achievement.requirementValue, Expressions.numberPath(Long.class, String.valueOf(userActivity.createdAt.count())), @@ -94,6 +96,7 @@ public List getAchievementInfoAboutUser(Long userId) { userAchievement.achievement.title, userAchievement.achievement.imgUrl, userAchievement.achievement.description, + userAchievement.achievement.progressLevel, userAchievement.achievement.requirementType, userAchievement.achievement.requirementValue, userAchievement.completed @@ -116,10 +119,11 @@ public List getAchievementInfoAboutUser(Long userId) { .title(tuple.get(2, String.class)) .imgUrl(tuple.get(3, String.class)) .description(tuple.get(4, String.class)) - .requirementType(tuple.get(5, RequirementType.class)) - .requirementValue(tuple.get(6, Integer.class)) - .progressCount(Integer.valueOf(String.valueOf(tuple.get(7, Long.class)))) - .completed(tuple.get(8, Boolean.class)) + .progressLevel(tuple.get(5, Integer.class)) + .requirementType(tuple.get(6, RequirementType.class)) + .requirementValue(tuple.get(7, Integer.class)) + .progressCount(Integer.valueOf(String.valueOf(tuple.get(8, Long.class)))) + .completed(tuple.get(9, Boolean.class)) .build() ).toList(); } diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/presentation/dto/res/AchievementInfoAPIRes.java b/src/main/java/io/oeid/mogakgo/domain/achievement/presentation/dto/res/AchievementInfoAPIRes.java index 4e2f4381..e8090370 100644 --- a/src/main/java/io/oeid/mogakgo/domain/achievement/presentation/dto/res/AchievementInfoAPIRes.java +++ b/src/main/java/io/oeid/mogakgo/domain/achievement/presentation/dto/res/AchievementInfoAPIRes.java @@ -24,6 +24,9 @@ public class AchievementInfoAPIRes { @Schema(description = "조회할 업적 상세 설명") private final String description; + @Schema(description = "조회할 업적 단계") + private final Integer progressLevel; + @Schema(description = "조회할 업적 타입") private final RequirementType requirementType; @@ -36,6 +39,7 @@ public static AchievementInfoAPIRes from(Achievement achievement) { achievement.getTitle(), achievement.getImgUrl(), achievement.getDescription(), + achievement.getProgressLevel(), achievement.getRequirementType(), achievement.getRequirementValue() ); diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/presentation/dto/res/UserAchievementDetailAPIRes.java b/src/main/java/io/oeid/mogakgo/domain/achievement/presentation/dto/res/UserAchievementDetailAPIRes.java index 9d6af59b..8f3b9407 100644 --- a/src/main/java/io/oeid/mogakgo/domain/achievement/presentation/dto/res/UserAchievementDetailAPIRes.java +++ b/src/main/java/io/oeid/mogakgo/domain/achievement/presentation/dto/res/UserAchievementDetailAPIRes.java @@ -27,6 +27,9 @@ public class UserAchievementDetailAPIRes { @Schema(description = "조회할 업적 상세 설명") private final String description; + @Schema(description = "조회할 업적 단계") + private final Integer progressLevel; + @Schema(description = "조회할 업적 타입") private final RequirementType requirementType; @@ -46,6 +49,7 @@ public static UserAchievementDetailAPIRes from(UserAchievementInfoRes response) response.getTitle(), response.getImgUrl(), response.getDescription(), + response.getProgressLevel(), response.getRequirementType(), response.getRequirementValue(), response.getProgressCount(),