From f47ea94c03ab301a99352140b2c9321b7f30a3c6 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Fri, 10 Nov 2023 13:31:47 +0900 Subject: [PATCH 01/14] =?UTF-8?q?hotfix(BE):=20=EC=B6=94=EC=B2=9C=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EC=97=90=EC=84=9C=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=EA=B0=80=20None=EC=9D=B8=20=EA=B2=83=EB=A7=8C=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C=20BUS-209-MVP1-bugfix=20#194?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/api/matching/service/MatchingService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/api/matching/service/MatchingService.java b/src/main/java/com/example/api/matching/service/MatchingService.java index 9bd29ec..722cf42 100644 --- a/src/main/java/com/example/api/matching/service/MatchingService.java +++ b/src/main/java/com/example/api/matching/service/MatchingService.java @@ -4,6 +4,7 @@ import com.example.api.common.type.ApplicationStateEnum; import com.example.api.common.type.ErrorCodeEnum; import com.example.api.common.type.Pair; +import com.example.api.matching.adapter.out.persistence.MatchingApplicationPK; import com.example.api.matching.adapter.out.persistence.MatchingEntity; import com.example.api.matching.adapter.out.persistence.MatchingMapperInterface; import com.example.api.matching.application.port.in.DeleteMatchingUsecase; @@ -99,7 +100,13 @@ public List getRecommendedMatchingList(UUID userId) { for (Pair matchingData: matchingScoreList) { // 유사도가 높은 순서로 정렬한 후 반환 FindMatchingDto findMatchingDto = this.getMatchingById(matchingData.getFirst()); if (findMatchingDto != null) { - sortedMatchingList.add(findMatchingDto); + MatchingApplicationPK matchingApplicationPK = MatchingApplicationPK.builder() + .userId(userId) + .matchingId(findMatchingDto.getMatchingId()) + .build(); + if (matchingApplicationPort.getByMatchingApplicationPK(matchingApplicationPK).isEmpty()) { + sortedMatchingList.add(findMatchingDto); + } } } } catch (Exception e) { From 80e285c7097fb22c024bf1043c0cce8fe7fbcf05 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Fri, 10 Nov 2023 13:54:32 +0900 Subject: [PATCH 02/14] =?UTF-8?q?hotfix(BE):=20=EC=84=A0=ED=98=B8=EB=8F=84?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20Value=20=EB=8C=80=EC=8B=A0?= =?UTF-8?q?=20Key=EA=B0=80=20=EC=A1=B0=ED=9A=8C=EB=90=A8=20BUS-209-MVP1-bu?= =?UTF-8?q?gfix=20#195?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/in/rest/PreferenceController.java | 18 ++++---- .../port/in/ComparePreferenceUsecase.java | 6 --- .../port/in/FindPreferenceUsecase.java | 7 +++- .../preference/service/PreferenceService.java | 42 +++++++++++++++---- .../example/api/user/dto/UpdateUserDto.java | 1 - 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java b/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java index 4d452fb..255d813 100644 --- a/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java +++ b/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java @@ -4,10 +4,7 @@ import com.example.api.common.exception.CustomException; import com.example.api.common.type.ErrorCodeEnum; import com.example.api.common.utils.AuthenticationUtils; -import com.example.api.preference.application.port.in.ComparePreferenceUsecase; -import com.example.api.preference.application.port.in.MatchingPreferenceUsecase; -import com.example.api.preference.application.port.in.SavePreferenceUsecase; -import com.example.api.preference.application.port.in.UserPreferenceUsecase; +import com.example.api.preference.application.port.in.*; import com.example.api.preference.dto.*; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -22,6 +19,7 @@ @Tag(name = "Preference", description = "Preference API") public class PreferenceController { private final SavePreferenceUsecase savePreferenceUsecase; + private final FindPreferenceUsecase findPreferenceUsecase; private final UserPreferenceUsecase userPreferenceUsecase; private final MatchingPreferenceUsecase matchingPreferenceUsecase; private final ComparePreferenceUsecase comparePreferenceUsecase; @@ -61,28 +59,28 @@ public MatchingPreferenceDto createMatchingPreference(@Valid @RequestBody Matchi /** * 사용자 선호도 조회 - * @return user compare-preference data + * @return user preference data */ @Operation(summary = "Get user preference", description = "사용자 선호도를 조회한다.") @GetMapping("/user/preference") - public ComparePreferenceDto getUserPreference() { + public FindPreferenceDto getUserPreference() { SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); if (securityUser == null) { log.error("PreferenceController::getUserPreference: Login is needed"); throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); } - return comparePreferenceUsecase.getUserPreference(securityUser.getUserId()); + return findPreferenceUsecase.getUserPreference(securityUser.getUserId()); } /** * 매칭 선호도 조회 * @param matchingId (ID) - * @return matching compare-preference data + * @return matching preference data */ @Operation(summary = "Get matching preference", description = "매칭 선호도를 조회한다.") @GetMapping("/matching/{matchingId}/preference") - public ComparePreferenceDto findMatchingPreference(@PathVariable Long matchingId) { - return comparePreferenceUsecase.getMatchingPreference(matchingId); + public FindPreferenceDto findMatchingPreference(@PathVariable Long matchingId) { + return findPreferenceUsecase.getMatchingPreference(matchingId); } /** diff --git a/src/main/java/com/example/api/preference/application/port/in/ComparePreferenceUsecase.java b/src/main/java/com/example/api/preference/application/port/in/ComparePreferenceUsecase.java index 5cde0ae..58cab34 100644 --- a/src/main/java/com/example/api/preference/application/port/in/ComparePreferenceUsecase.java +++ b/src/main/java/com/example/api/preference/application/port/in/ComparePreferenceUsecase.java @@ -1,10 +1,4 @@ package com.example.api.preference.application.port.in; -import com.example.api.preference.dto.ComparePreferenceDto; - -import java.util.UUID; - public interface ComparePreferenceUsecase { - ComparePreferenceDto getUserPreference(UUID userId); - ComparePreferenceDto getMatchingPreference(Long matchingId); } \ No newline at end of file diff --git a/src/main/java/com/example/api/preference/application/port/in/FindPreferenceUsecase.java b/src/main/java/com/example/api/preference/application/port/in/FindPreferenceUsecase.java index 9f6879c..0a8100e 100644 --- a/src/main/java/com/example/api/preference/application/port/in/FindPreferenceUsecase.java +++ b/src/main/java/com/example/api/preference/application/port/in/FindPreferenceUsecase.java @@ -1,9 +1,14 @@ package com.example.api.preference.application.port.in; import com.example.api.preference.dto.ComparePreferenceDto; +import com.example.api.preference.dto.FindPreferenceDto; import java.util.Optional; +import java.util.UUID; public interface FindPreferenceUsecase { - Optional getByPreferenceId(Long preferenceId); + Optional getByPreferenceId(Long preferenceId); + Optional getComparePreference(Long preferenceId); + FindPreferenceDto getUserPreference(UUID userId); + FindPreferenceDto getMatchingPreference(Long matchingId); } \ No newline at end of file diff --git a/src/main/java/com/example/api/preference/service/PreferenceService.java b/src/main/java/com/example/api/preference/service/PreferenceService.java index 65e7a2c..c0aea82 100644 --- a/src/main/java/com/example/api/preference/service/PreferenceService.java +++ b/src/main/java/com/example/api/preference/service/PreferenceService.java @@ -12,6 +12,9 @@ import com.example.api.preference.dto.ComparePreferenceDto; import com.example.api.preference.dto.FindPreferenceDto; import com.example.api.preference.dto.SavePreferenceDto; +import com.example.api.preference.type.PreferSmokeEnum; +import com.example.api.preference.type.TasteEnum; +import com.example.api.user.type.UserGenderEnum; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -31,7 +34,24 @@ public class PreferenceService implements SavePreferenceUsecase, FindPreferenceU private final FindPreferencePort findPreferencePort; private final ComparePreferencePort comparePreferencePort; - public ComparePreferenceDto getDefaultPreference() { + public FindPreferenceDto getDefaultPreference() { + return FindPreferenceDto.builder() + .preferenceId(0L) + .alcoholAmount(2) + .mateAllowedAlcohol(2) + .taste(TasteEnum.Spicy) + .allowedMoveTime(60) + .allowedPeople(4) + .preferGender(UserGenderEnum.None) + .smoke(false) + .preferSmoke(PreferSmokeEnum.None) + .slang(2) + .createdAt(LocalDateTime.now()) + .updatedAt(LocalDateTime.now()) + .build(); + } + + public ComparePreferenceDto getDefaultComparePreference() { return ComparePreferenceDto.builder() .preferenceId(0L) .alcoholAmount(2) @@ -58,7 +78,13 @@ public FindPreferenceDto createPreference(SavePreferenceDto preferenceDto) { } @Override - public Optional getByPreferenceId(Long preferenceId) { + public Optional getByPreferenceId(Long preferenceId) { + return findPreferencePort.getByPreferenceId(preferenceId) + .map(preferenceMapper::toDto); + } + + @Override + public Optional getComparePreference(Long preferenceId) { return findPreferencePort.getByPreferenceId(preferenceId) .map(PreferenceEntity::toCompareDto); } @@ -73,14 +99,14 @@ public FindPreferenceDto updatePreference(Long preferenceId, SavePreferenceDto p // ComparePreference @Override - public ComparePreferenceDto getUserPreference(UUID userId) { + public FindPreferenceDto getUserPreference(UUID userId) { Long preferenceId = comparePreferencePort.getUserPreferenceId(userId); if (preferenceId == 0L) { log.warn("PreferenceService::getUserPreference: User preference data not found"); return this.getDefaultPreference(); //throw new CustomException(ErrorCodeEnum.PREFERENCE_NOT_FOUND); } - Optional preferenceDto = this.getByPreferenceId(preferenceId); + Optional preferenceDto = this.getByPreferenceId(preferenceId); if (preferenceDto.isEmpty()) { log.warn("PreferenceService::getUserPreference: User preference data not found"); return this.getDefaultPreference(); @@ -90,14 +116,16 @@ public ComparePreferenceDto getUserPreference(UUID userId) { } @Override - public ComparePreferenceDto getMatchingPreference(Long matchingId) { + public FindPreferenceDto getMatchingPreference(Long matchingId) { Long preferenceId = comparePreferencePort.getMatchingPreferenceId(matchingId); return this.getByPreferenceId(preferenceId).orElse(this.getDefaultPreference()); } public Integer getMatchingScore(UUID userId, Long matchingId) { - ComparePreferenceDto userPreference = this.getUserPreference(userId); - ComparePreferenceDto matchingPreference = this.getMatchingPreference(matchingId); + Long userPreferenceId = comparePreferencePort.getUserPreferenceId(userId); + Long matchingPreferenceId = comparePreferencePort.getMatchingPreferenceId(matchingId); + ComparePreferenceDto userPreference = this.getComparePreference(userPreferenceId).orElse(this.getDefaultComparePreference()); + ComparePreferenceDto matchingPreference = this.getComparePreference(matchingPreferenceId).orElse(this.getDefaultComparePreference()); Integer score = 0; score += Math.abs(userPreference.getAlcoholAmount() - matchingPreference.getAlcoholAmount()); score += Math.abs(userPreference.getMateAllowedAlcohol() - matchingPreference.getMateAllowedAlcohol()); diff --git a/src/main/java/com/example/api/user/dto/UpdateUserDto.java b/src/main/java/com/example/api/user/dto/UpdateUserDto.java index 1c45341..6ab7584 100644 --- a/src/main/java/com/example/api/user/dto/UpdateUserDto.java +++ b/src/main/java/com/example/api/user/dto/UpdateUserDto.java @@ -1,6 +1,5 @@ package com.example.api.user.dto; -import com.example.api.social.adapter.out.persistence.SocialEntity; import com.example.api.user.type.UserGenderEnum; import com.example.api.user.type.UserRoleEnum; import jakarta.validation.constraints.*; From 61c278b07c16c39f9fcea1d8c10e9cf07190b9c3 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Fri, 10 Nov 2023 14:53:07 +0900 Subject: [PATCH 03/14] =?UTF-8?q?hotfix(BE):=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=20=EC=98=A4=EB=A5=98=20BUS-209-MVP1-bugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/matching/adapter/in/rest/MatchingController.java | 2 +- .../adapter/out/persistence/MatchingApplicationEntity.java | 1 + .../out/persistence/MatchingApplicationPersistenceAdapter.java | 2 +- .../example/api/matching/dto/FindMatchingApplicationDto.java | 1 - 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java b/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java index 273b64c..5d4cd7f 100644 --- a/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java +++ b/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java @@ -53,7 +53,7 @@ public FindMatchingDto createMatching(@Valid @RequestBody SaveMatchingDto saveMa log.error("MatchingController::createMatching: Login is needed"); throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); } - FindMatchingDto findMatchingDto = saveMatchingUsecase.createMatching(securityUser.getUserId(), saveMatchingDto); + FindMatchingDto findMatchingDto = saveMatchingUsecase.createMatching(securityUser.getUserId(), saveMatchingDto); SaveMatchingApplicationDto saveMatchingApplicationDto = SaveMatchingApplicationDto.builder() .userId(securityUser.getUserId()) diff --git a/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationEntity.java b/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationEntity.java index 5e9553a..ca94266 100644 --- a/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationEntity.java +++ b/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationEntity.java @@ -26,6 +26,7 @@ public class MatchingApplicationEntity extends BaseEntity { private Long matchingId; @Column(nullable = false) + @Enumerated(EnumType.STRING) private ApplicationStateEnum state; @Column(nullable = false) diff --git a/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationPersistenceAdapter.java b/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationPersistenceAdapter.java index 54676d1..81b4dc0 100644 --- a/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationPersistenceAdapter.java +++ b/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationPersistenceAdapter.java @@ -14,8 +14,8 @@ import java.util.UUID; @Repository -@RequiredArgsConstructor @Slf4j +@RequiredArgsConstructor @ComponentScan public class MatchingApplicationPersistenceAdapter implements MatchingApplicationPort { private final MatchingMapperInterface matchingMapper; diff --git a/src/main/java/com/example/api/matching/dto/FindMatchingApplicationDto.java b/src/main/java/com/example/api/matching/dto/FindMatchingApplicationDto.java index 05faa08..dee5349 100644 --- a/src/main/java/com/example/api/matching/dto/FindMatchingApplicationDto.java +++ b/src/main/java/com/example/api/matching/dto/FindMatchingApplicationDto.java @@ -19,7 +19,6 @@ public class FindMatchingApplicationDto { private UUID userId; @NotNull - @Min(1) private Long matchingId; @NotNull From 7e924a251b6523965489310f504470a4d24b3723 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Fri, 10 Nov 2023 14:58:51 +0900 Subject: [PATCH 04/14] =?UTF-8?q?hotfix(BE):=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=20=EC=98=A4=EB=A5=98=20BUS-209-MVP1-bugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/preference/adapter/in/rest/PreferenceController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java b/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java index 12953d5..32c7a99 100644 --- a/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java +++ b/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java @@ -100,7 +100,7 @@ public FindPreferenceDto findMatchingPreference(@PathVariable Long matchingId) { log.error("PreferenceController::findMatchingPreference: Login is needed"); throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); } - return comparePreferenceUsecase.getMatchingPreference(matchingId); + return findPreferenceUsecase.getMatchingPreference(matchingId); } /** From 16232c5d520c492faa409ea4dc3cb060c7f8d238 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Fri, 10 Nov 2023 15:37:22 +0900 Subject: [PATCH 05/14] =?UTF-8?q?feat(BE):=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=B0=B8=EA=B0=80=EC=9E=90=20=EB=AA=A9=EB=A1=9D=EC=97=90=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=EC=9E=90=20=ED=8F=AC=ED=95=A8=20BUS-218-Appr?= =?UTF-8?q?oved-include-Owner=20#198?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/in/rest/MatchingController.java | 9 ++++-- ...MatchingApplicationPersistenceAdapter.java | 12 ++++++-- .../port/in/MatchingApplicationUsecase.java | 5 ++-- .../port/out/MatchingApplicationPort.java | 5 ++-- .../MatchingApplicationRepository.java | 7 ++--- .../service/MatchingApplicationService.java | 29 ++++++++++++++----- .../api/matching/service/MatchingService.java | 4 +-- .../user/adapter/in/rest/UserController.java | 4 +-- ...ingApplicationPersistenceAdapterTests.java | 6 ++-- .../MatchingApplicationServiceTests.java | 8 ++--- 10 files changed, 57 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java b/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java index d9a360e..8e3ec7e 100644 --- a/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java +++ b/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java @@ -23,6 +23,8 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; @RestController @@ -137,11 +139,11 @@ public List getPendingUserList(@PathVariable Long matchingId) { log.error("MatchingController::getPendingUserList: Login is needed"); throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); } - return matchingApplicationUsecase.getByMatchingIdIsAndStateEquals(matchingId, ApplicationStateEnum.Pending); + return matchingApplicationUsecase.getByMatchingIdAndStateEquals(matchingId, ApplicationStateEnum.Pending); } /** - * ID가 matchingId인 매칭의 참가자 목록 조회 + * ID가 matchingId인 매칭의 작성자 포함 참가자 목록 조회 * @param matchingId (ID) * @return participant list */ @@ -153,7 +155,8 @@ public List getApprovedUserList(@PathVariable Long matchingId) log.error("MatchingController::getApprovedUserList: Login is needed"); throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); } - return matchingApplicationUsecase.getByMatchingIdIsAndStateEquals(matchingId, ApplicationStateEnum.Approved); + List stateList = new ArrayList<>(Arrays.asList(ApplicationStateEnum.Approved, ApplicationStateEnum.Owner)); + return matchingApplicationUsecase.getByMatchingIdAndStateIn(matchingId, stateList); } /** diff --git a/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationPersistenceAdapter.java b/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationPersistenceAdapter.java index 81b4dc0..5a6fecb 100644 --- a/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationPersistenceAdapter.java +++ b/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingApplicationPersistenceAdapter.java @@ -9,6 +9,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.stereotype.Repository; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -33,12 +34,17 @@ public Optional getByMatchingApplicationPK(MatchingAp } @Override - public List getByUserIdIsAndStateEquals(UUID userId, ApplicationStateEnum state) { - return matchingApplicationRepository.getByUserIdIsAndStateEquals(userId, state); + public List getByUserIdAndStateEquals(UUID userId, ApplicationStateEnum state) { + return matchingApplicationRepository.getByUserIdAndStateEquals(userId, state); } @Override - public List getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state) { + public List getByMatchingIdAndStateEquals(Long matchingId, ApplicationStateEnum state) { return matchingApplicationRepository.getByMatchingIdAndStateEquals(matchingId, state); } + + @Override + public List getByMatchingIdAndStateIn(Long matchingId, List stateList) { + return matchingApplicationRepository.getByMatchingIdAndStateIn(matchingId, stateList); + } } \ No newline at end of file diff --git a/src/main/java/com/example/api/matching/application/port/in/MatchingApplicationUsecase.java b/src/main/java/com/example/api/matching/application/port/in/MatchingApplicationUsecase.java index da2339d..8933f58 100644 --- a/src/main/java/com/example/api/matching/application/port/in/MatchingApplicationUsecase.java +++ b/src/main/java/com/example/api/matching/application/port/in/MatchingApplicationUsecase.java @@ -11,8 +11,9 @@ public interface MatchingApplicationUsecase { MatchingApplication createMatchingApplicationData(UUID userId, SaveMatchingApplicationDto matchingApplicationDto); - List getByUserIdIsAndStateEquals(UUID userId, ApplicationStateEnum state); - List getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state); + List getByUserIdAndStateEquals(UUID userId, ApplicationStateEnum state); + List getByMatchingIdAndStateEquals(Long matchingId, ApplicationStateEnum state); + List getByMatchingIdAndStateIn(Long matchingId, List state); String getUserStatus(UUID userId, Long matchingId); void processMatchingApplication(SaveMatchingApplicationDto matchingApplicationDto); } \ No newline at end of file diff --git a/src/main/java/com/example/api/matching/application/port/out/MatchingApplicationPort.java b/src/main/java/com/example/api/matching/application/port/out/MatchingApplicationPort.java index fa58b57..988bd7c 100644 --- a/src/main/java/com/example/api/matching/application/port/out/MatchingApplicationPort.java +++ b/src/main/java/com/example/api/matching/application/port/out/MatchingApplicationPort.java @@ -12,6 +12,7 @@ public interface MatchingApplicationPort { MatchingApplication saveMatchingApplication(MatchingApplication matchingApplication); Optional getByMatchingApplicationPK(MatchingApplicationPK matchingApplicationPK); - List getByUserIdIsAndStateEquals(UUID userId, ApplicationStateEnum state); - List getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state); + List getByUserIdAndStateEquals(UUID userId, ApplicationStateEnum state); + List getByMatchingIdAndStateEquals(Long matchingId, ApplicationStateEnum state); + List getByMatchingIdAndStateIn(Long matchingId, List stateList); } \ No newline at end of file diff --git a/src/main/java/com/example/api/matching/repository/MatchingApplicationRepository.java b/src/main/java/com/example/api/matching/repository/MatchingApplicationRepository.java index c93618c..22d9301 100644 --- a/src/main/java/com/example/api/matching/repository/MatchingApplicationRepository.java +++ b/src/main/java/com/example/api/matching/repository/MatchingApplicationRepository.java @@ -5,12 +5,11 @@ import com.example.api.matching.adapter.out.persistence.MatchingApplicationPK; import org.springframework.data.jpa.repository.JpaRepository; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import java.util.*; public interface MatchingApplicationRepository extends JpaRepository { Optional getByUserIdAndMatchingId(UUID userId, Long matchingId); - List getByUserIdIsAndStateEquals(UUID userId, ApplicationStateEnum state); + List getByUserIdAndStateEquals(UUID userId, ApplicationStateEnum state); List getByMatchingIdAndStateEquals(Long matchingId, ApplicationStateEnum state); + List getByMatchingIdAndStateIn(Long matchingId, List stateList); } \ No newline at end of file diff --git a/src/main/java/com/example/api/matching/service/MatchingApplicationService.java b/src/main/java/com/example/api/matching/service/MatchingApplicationService.java index 1f747de..98026cd 100644 --- a/src/main/java/com/example/api/matching/service/MatchingApplicationService.java +++ b/src/main/java/com/example/api/matching/service/MatchingApplicationService.java @@ -55,16 +55,16 @@ public MatchingApplication createMatchingApplicationData(UUID userId, SaveMatchi } @Override - public List getByUserIdIsAndStateEquals(UUID userId, ApplicationStateEnum state) { - List matchingPairList = matchingApplicationPort.getByUserIdIsAndStateEquals(userId, state); + public List getByUserIdAndStateEquals(UUID userId, ApplicationStateEnum state) { + List matchingPairList = matchingApplicationPort.getByUserIdAndStateEquals(userId, state); List matchingList = new ArrayList<>(); for (MatchingApplicationEntity matchingPair: matchingPairList) { Optional matchingEntity = findMatchingPort.getByMatchingId(matchingPair.getMatchingId()); if (matchingEntity.isEmpty()) { - log.warn("MatchingApplicationService::getByUserIdIsAndStateEquals: Matching with ID {} doesn't exist", matchingPair.getMatchingId()); + log.warn("MatchingApplicationService::getByUserIdAndStateEquals: Matching with ID {} doesn't exist", matchingPair.getMatchingId()); } else { Matching matching = matchingMapper.toDomain(matchingEntity.get()); - matching.setCurrentMember(matchingApplicationPort.getByMatchingIdIsAndStateEquals(matching.getMatchingId(), ApplicationStateEnum.Approved).size() + 1); + matching.setCurrentMember(matchingApplicationPort.getByMatchingIdAndStateEquals(matching.getMatchingId(), ApplicationStateEnum.Approved).size() + 1); matchingList.add(matchingMapper.toDto(matching)); } } @@ -72,13 +72,28 @@ public List getByUserIdIsAndStateEquals(UUID userId, Applicatio } @Override - public List getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state) { - List matchingPairList = matchingApplicationPort.getByMatchingIdIsAndStateEquals(matchingId, state); + public List getByMatchingIdAndStateEquals(Long matchingId, ApplicationStateEnum state) { + List matchingPairList = matchingApplicationPort.getByMatchingIdAndStateEquals(matchingId, state); List userList = new ArrayList<>(); for (MatchingApplicationEntity matchingPair: matchingPairList) { Optional userEntity = findUserPort.getByUserId(matchingPair.getUserId()); if (userEntity.isEmpty()) { - log.warn("MatchingApplicationService::getByMatchingIdIsAndStateEquals: User with ID {} doesn't exist", matchingPair.getUserId()); + log.warn("MatchingApplicationService::getByMatchingIdAndStateEquals: User with ID {} doesn't exist", matchingPair.getUserId()); + } else { + userList.add(userMapper.toInfoDto(userEntity.get())); + } + } + return userList; + } + + @Override + public List getByMatchingIdAndStateIn(Long matchingId, List stateList) { + List matchingPairList = matchingApplicationPort.getByMatchingIdAndStateIn(matchingId, stateList); + List userList = new ArrayList<>(); + for (MatchingApplicationEntity matchingPair: matchingPairList) { + Optional userEntity = findUserPort.getByUserId(matchingPair.getUserId()); + if (userEntity.isEmpty()) { + log.warn("MatchingApplicationService::getByMatchingIdAndStateIn: User with ID {} doesn't exist", matchingPair.getUserId()); } else { userList.add(userMapper.toInfoDto(userEntity.get())); } diff --git a/src/main/java/com/example/api/matching/service/MatchingService.java b/src/main/java/com/example/api/matching/service/MatchingService.java index 722cf42..82ec6d2 100644 --- a/src/main/java/com/example/api/matching/service/MatchingService.java +++ b/src/main/java/com/example/api/matching/service/MatchingService.java @@ -53,7 +53,7 @@ public List setCurrentMember(List matchingEntit List matchingList = new ArrayList<>(); for (MatchingEntity matchingData: matchingEntities) { Matching matching = matchingMapper.toDomain(matchingData); - matching.setCurrentMember(matchingApplicationPort.getByMatchingIdIsAndStateEquals(matchingData.getMatchingId(), ApplicationStateEnum.Approved).size() + 1); + matching.setCurrentMember(matchingApplicationPort.getByMatchingIdAndStateEquals(matchingData.getMatchingId(), ApplicationStateEnum.Approved).size() + 1); matchingList.add(matchingMapper.toDto(matching)); } return matchingList; @@ -71,7 +71,7 @@ public FindMatchingDto getMatchingById(Long matchingId) { return null; } Matching matching = matchingMapper.toDomain(matchingEntity.get()); - matching.setCurrentMember(matchingApplicationPort.getByMatchingIdIsAndStateEquals(matchingId, ApplicationStateEnum.Approved).size() + 1); + matching.setCurrentMember(matchingApplicationPort.getByMatchingIdAndStateEquals(matchingId, ApplicationStateEnum.Approved).size() + 1); return matchingMapper.toDto(matching); } diff --git a/src/main/java/com/example/api/user/adapter/in/rest/UserController.java b/src/main/java/com/example/api/user/adapter/in/rest/UserController.java index d9a87a8..819c188 100644 --- a/src/main/java/com/example/api/user/adapter/in/rest/UserController.java +++ b/src/main/java/com/example/api/user/adapter/in/rest/UserController.java @@ -165,7 +165,7 @@ public List getPendingMatchingList() { log.error("UserController::getPendingMatchingList: Login is needed"); throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); } - return matchingApplicationUsecase.getByUserIdIsAndStateEquals(securityUser.getUserId(), ApplicationStateEnum.Pending); + return matchingApplicationUsecase.getByUserIdAndStateEquals(securityUser.getUserId(), ApplicationStateEnum.Pending); } /** @@ -180,7 +180,7 @@ public List getApprovedMatchingList() { log.error("UserController::getApprovedMatchingList: Login is needed"); throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); } - return matchingApplicationUsecase.getByUserIdIsAndStateEquals(securityUser.getUserId(), ApplicationStateEnum.Approved); + return matchingApplicationUsecase.getByUserIdAndStateEquals(securityUser.getUserId(), ApplicationStateEnum.Approved); } /** diff --git a/src/test/java/com/example/api/matching/MatchingApplicationPersistenceAdapterTests.java b/src/test/java/com/example/api/matching/MatchingApplicationPersistenceAdapterTests.java index e6e2d9c..e20b75c 100644 --- a/src/test/java/com/example/api/matching/MatchingApplicationPersistenceAdapterTests.java +++ b/src/test/java/com/example/api/matching/MatchingApplicationPersistenceAdapterTests.java @@ -50,13 +50,13 @@ void createMatchingApplicationTest() { @Test void getByUserIdIsAndStateEqualsTest() { - matchingApplicationPersistenceAdapter.getByUserIdIsAndStateEquals(userUUID, ApplicationStateEnum.Pending); - verify(matchingApplicationRepository, times(1)).getByUserIdIsAndStateEquals(userUUID, ApplicationStateEnum.Pending); + matchingApplicationPersistenceAdapter.getByUserIdAndStateEquals(userUUID, ApplicationStateEnum.Pending); + verify(matchingApplicationRepository, times(1)).getByUserIdAndStateEquals(userUUID, ApplicationStateEnum.Pending); } @Test void getByMatchingIdIsAndStateEqualsTest() { - matchingApplicationPersistenceAdapter.getByMatchingIdIsAndStateEquals(1L, ApplicationStateEnum.Approved); + matchingApplicationPersistenceAdapter.getByMatchingIdAndStateEquals(1L, ApplicationStateEnum.Approved); verify(matchingApplicationRepository, times(1)).getByMatchingIdAndStateEquals(1L, ApplicationStateEnum.Approved); } } \ No newline at end of file diff --git a/src/test/java/com/example/api/matching/MatchingApplicationServiceTests.java b/src/test/java/com/example/api/matching/MatchingApplicationServiceTests.java index a6d133c..d51df1d 100644 --- a/src/test/java/com/example/api/matching/MatchingApplicationServiceTests.java +++ b/src/test/java/com/example/api/matching/MatchingApplicationServiceTests.java @@ -44,13 +44,13 @@ void saveMatchingApplicationTest() { @Test void getByUserIdIsAndStateEqualsTest() { - matchingApplicationService.getByUserIdIsAndStateEquals(userId, ApplicationStateEnum.Pending); - verify(matchingApplicationPort, times(1)).getByUserIdIsAndStateEquals(userId, ApplicationStateEnum.Pending); + matchingApplicationService.getByUserIdAndStateEquals(userId, ApplicationStateEnum.Pending); + verify(matchingApplicationPort, times(1)).getByUserIdAndStateEquals(userId, ApplicationStateEnum.Pending); } @Test void getByMatchingIdIsAndStateEqualsTest() { - matchingApplicationService.getByMatchingIdIsAndStateEquals(1L, ApplicationStateEnum.Approved); - verify(matchingApplicationPort, times(1)).getByMatchingIdIsAndStateEquals(1L, ApplicationStateEnum.Approved); + matchingApplicationService.getByMatchingIdAndStateEquals(1L, ApplicationStateEnum.Approved); + verify(matchingApplicationPort, times(1)).getByMatchingIdAndStateEquals(1L, ApplicationStateEnum.Approved); } } \ No newline at end of file From a13be9dd9265bd4c7d8226f13aefa46df95b3022 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Mon, 13 Nov 2023 09:07:32 +0900 Subject: [PATCH 06/14] =?UTF-8?q?fix(BE):=20SMS=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EA=B6=8C=ED=95=9C=20=EC=B2=B4=ED=81=AC=20?= =?UTF-8?q?=ED=95=B4=EC=A0=9C=20BUS-203-Authority-check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sms/adapter/in/rest/SmsController.java | 14 ----------- .../example/api/sms/service/SMSService.java | 25 ++++++++----------- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/example/api/sms/adapter/in/rest/SmsController.java b/src/main/java/com/example/api/sms/adapter/in/rest/SmsController.java index f1b35b8..828fa49 100644 --- a/src/main/java/com/example/api/sms/adapter/in/rest/SmsController.java +++ b/src/main/java/com/example/api/sms/adapter/in/rest/SmsController.java @@ -1,9 +1,5 @@ package com.example.api.sms.adapter.in.rest; -import com.example.api.auth.domain.SecurityUser; -import com.example.api.common.exception.CustomException; -import com.example.api.common.type.ErrorCodeEnum; -import com.example.api.common.utils.AuthenticationUtils; import com.example.api.sms.application.port.in.SendCertificationCodeUsecase; import com.example.api.sms.application.port.in.VerifyCodeUsecase; import com.example.api.sms.dto.CheckSMSDto; @@ -27,11 +23,6 @@ public class SmsController { @Operation(summary = "Certificate phone", description = "휴대폰 인증") @GetMapping("/sms/code/{phone}") public void sendCertificationPhone(@PathVariable String phone) { - SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); - if (securityUser == null) { - log.error("SmsController::sendCertificationPhone: Login is needed"); - throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); - } sendCertificationCodeUsecase.send(phone); } @@ -41,11 +32,6 @@ public void sendCertificationPhone(@PathVariable String phone) { */ @PostMapping("/sms/code") public void certificatePhone(@Valid @RequestBody CheckSMSDto checkSMSDto) { - SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); - if (securityUser == null) { - log.error("SmsController::certificatePhone: Login is needed"); - throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); - } verifyCodeUsecase.verifyCertificationCode(checkSMSDto); } } \ No newline at end of file diff --git a/src/main/java/com/example/api/sms/service/SMSService.java b/src/main/java/com/example/api/sms/service/SMSService.java index 7a1e08f..a676bc4 100644 --- a/src/main/java/com/example/api/sms/service/SMSService.java +++ b/src/main/java/com/example/api/sms/service/SMSService.java @@ -25,10 +25,9 @@ import java.util.Map; import java.util.Random; - +@Service @Slf4j @RequiredArgsConstructor -@Service public class SMSService implements SendCertificationCodeUsecase, VerifyCodeUsecase { private final AWSConfig awsConfig; private final CertificationCodePort certificationCodePort; @@ -44,19 +43,17 @@ public void verifyCertificationCode(CheckSMSDto checkSMSDto) { // 이제 그 redis에 저장 => 인증 redis checkVerifiedPhonePort.saveCheckedPhone(phone); }else{ - throw new CustomException(ErrorCodeEnum.CODE_IS_NOT_VALID); // 코드가 일치 하지 않음 + throw new CustomException(ErrorCodeEnum.CODE_IS_NOT_VALID); // 코드가 일치하지 않음 } - } /** * 코드 발급 받고, 전송 - * @param phone - * @return + * @param phone (휴대폰 번호) + * @return PublishResult */ @Override public PublishResult send(String phone) { - PublishResult result = null; StringBuilder koreaPhone = new StringBuilder("+82"); koreaPhone.append(phone); @@ -65,13 +62,13 @@ public PublishResult send(String phone) { String code = generateRandomSixDigitNumber(); StringBuilder newMessage = new StringBuilder(message); newMessage.append(code); - BasicAWSCredentials awsCreds = new BasicAWSCredentials(awsConfig.getAwsAccessKey(), awsConfig.getAwsSecretKey()); + BasicAWSCredentials awsCredentials = new BasicAWSCredentials(awsConfig.getAwsAccessKey(), awsConfig.getAwsSecretKey()); AmazonSNSClientBuilder builder = AmazonSNSClientBuilder.standard(); AmazonSNS sns = builder.withRegion(Regions.AP_NORTHEAST_1) - .withCredentials(new AWSStaticCredentialsProvider(awsCreds)).build(); + .withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).build(); Map smsAttributes = new HashMap<>(); @@ -91,7 +88,6 @@ public PublishResult send(String phone) { smsAttributes); certificationCodePort.saveCode(phone,code); } catch (Exception ex) { - log.error("The sms was not sent."); log.error("Error message: " + ex.getMessage()); throw new AmazonClientException(ex.getMessage(), ex); @@ -100,14 +96,13 @@ public PublishResult send(String phone) { } /** - * 6 랜덤 숫자 리턴 - * - * @return + * 6자리 난수 생성 + * @return random code */ private String generateRandomSixDigitNumber() { Random random = new Random(); - int randomNumber = random.nextInt(1000000); // 0~ 999999 사이 랜덤 숫자 + int randomNumber = random.nextInt(1000000); // 000000 ~ 999999 사이 난수 return String.format("%06d", randomNumber); // newMessage.append(); // return newMessage.toString(); @@ -120,4 +115,4 @@ private PublishResult sendSMSMessage(AmazonSNS sns, String message, String phone .withMessageAttributes(messageAttributeValueMap) ); } -} +} \ No newline at end of file From 0981d131724b40be9fb006654df04346a1279a35 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Mon, 13 Nov 2023 13:11:49 +0900 Subject: [PATCH 07/14] =?UTF-8?q?fix(BE):=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EC=A0=91=EA=B7=BC=20=EC=A0=9C=ED=95=9C=20?= =?UTF-8?q?=ED=95=B4=EC=A0=9C=20BUS-203-Authority-check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/api/user/adapter/in/rest/UserController.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/example/api/user/adapter/in/rest/UserController.java b/src/main/java/com/example/api/user/adapter/in/rest/UserController.java index 819c188..f0eb41f 100644 --- a/src/main/java/com/example/api/user/adapter/in/rest/UserController.java +++ b/src/main/java/com/example/api/user/adapter/in/rest/UserController.java @@ -64,11 +64,6 @@ protected void initBinder(WebDataBinder binder) { @Operation(summary = "Create user", description = "새로운 사용자를 추가한다.") @PostMapping("/user") public void createUser(@Valid @RequestBody CreateUserDto userDto, BindingResult bindingResult) { - SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); - if (securityUser == null) { - log.error("UserController::createUser: Login is needed"); - throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); - } UUID userId = saveUserUsecase.createUser(userDto); profileImageUsecase.initializeProfileImage(userId); } From be653dc7401a0be79131bd4749ca6074caa91e53 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Mon, 13 Nov 2023 14:24:08 +0900 Subject: [PATCH 08/14] =?UTF-8?q?feat(BE):=20=EB=A7=A4=EC=B9=AD=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=8B=9C=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0=20BUS-208-matching-chatroom-connect=20#202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/chatroom/type/ChatRoomEnum.java | 8 ++++-- .../adapter/in/rest/MatchingController.java | 17 +++++++++++ .../out/persistence/MatchingEntity.java | 3 ++ .../example/api/matching/domain/Matching.java | 1 + .../api/matching/dto/FindMatchingDto.java | 3 ++ .../api/matching/dto/SaveMatchingDto.java | 3 ++ .../service/MatchingApplicationService.java | 11 ++++++++ .../adapter/in/rest/MemberController.java | 4 +-- .../persistence/MemberPersistentAdapter.java | 2 +- .../port/in/AddMemberChatRoomUsecase.java | 5 +++- .../port/out/AddMemberChatRoomPort.java | 2 +- .../api/member/service/MemberService.java | 28 +++++++++++++------ 12 files changed, 71 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/example/api/chatroom/type/ChatRoomEnum.java b/src/main/java/com/example/api/chatroom/type/ChatRoomEnum.java index 92d28b0..03c00ff 100644 --- a/src/main/java/com/example/api/chatroom/type/ChatRoomEnum.java +++ b/src/main/java/com/example/api/chatroom/type/ChatRoomEnum.java @@ -8,8 +8,10 @@ @AllArgsConstructor @Getter public enum ChatRoomEnum { - Normal("일반"), - Inquery("상담"); + Normal("일반", 1), + Matching("매칭", 2), + Inquiry("상담", 3); private final String type; -} + private final Integer typeCode; +} \ No newline at end of file diff --git a/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java b/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java index 8e3ec7e..fb2e98a 100644 --- a/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java +++ b/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java @@ -3,6 +3,8 @@ import com.example.api.auth.domain.SecurityUser; import com.example.api.chatroom.application.port.in.CreateChatRoomUsecase; import com.example.api.chatroom.domain.ChatRoom; +import com.example.api.chatroom.dto.CreateChatRoomDto; +import com.example.api.chatroom.type.ChatRoomEnum; import com.example.api.common.exception.CustomException; import com.example.api.common.type.ApplicationStateEnum; import com.example.api.common.type.ErrorCodeEnum; @@ -55,8 +57,22 @@ public FindMatchingDto createMatching(@Valid @RequestBody SaveMatchingDto saveMa log.error("MatchingController::createMatching: Login is needed"); throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); } + + // 매칭 전용 채팅방 생성 + CreateChatRoomDto createChatRoomDto = CreateChatRoomDto.builder() + .masterId(securityUser.getUserId()) + .chatroomName(saveMatchingDto.getTitle()) + .type(ChatRoomEnum.Matching) + .isActive(true) + .build(); + ChatRoom chatRoom = createChatRoomUsecase.createRoom(createChatRoomDto); + addMemberChatRoomUsecase.addMember(chatRoom.getChatroomId(), securityUser.getUserId()); + saveMatchingDto.setChatRoomId(chatRoom.getChatroomId()); + + // 매칭 데이터 저장 FindMatchingDto findMatchingDto = saveMatchingUsecase.createMatching(securityUser.getUserId(), saveMatchingDto); + // Owner 등록 SaveMatchingApplicationDto saveMatchingApplicationDto = SaveMatchingApplicationDto.builder() .userId(securityUser.getUserId()) .matchingId(findMatchingDto.getMatchingId()) @@ -64,6 +80,7 @@ public FindMatchingDto createMatching(@Valid @RequestBody SaveMatchingDto saveMa .isActive(true) .build(); matchingApplicationUsecase.createMatchingApplicationData(securityUser.getUserId(), saveMatchingApplicationDto); + return findMatchingDto; } diff --git a/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingEntity.java b/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingEntity.java index bff8d60..59dcadc 100644 --- a/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingEntity.java +++ b/src/main/java/com/example/api/matching/adapter/out/persistence/MatchingEntity.java @@ -25,6 +25,9 @@ public class MatchingEntity extends BaseEntity { @Column(nullable = false) private UUID writerId; + @Column(nullable = false) + private UUID chatRoomId; + @Column(nullable = false) @Enumerated(EnumType.STRING) private MatchingTypeEnum type; diff --git a/src/main/java/com/example/api/matching/domain/Matching.java b/src/main/java/com/example/api/matching/domain/Matching.java index a438303..1cd09b6 100644 --- a/src/main/java/com/example/api/matching/domain/Matching.java +++ b/src/main/java/com/example/api/matching/domain/Matching.java @@ -14,6 +14,7 @@ public class Matching { private Long matchingId; private UUID writerId; + private UUID chatRoomId; private MatchingTypeEnum type; private String title; private String place; diff --git a/src/main/java/com/example/api/matching/dto/FindMatchingDto.java b/src/main/java/com/example/api/matching/dto/FindMatchingDto.java index b5b0bf5..1944866 100644 --- a/src/main/java/com/example/api/matching/dto/FindMatchingDto.java +++ b/src/main/java/com/example/api/matching/dto/FindMatchingDto.java @@ -21,6 +21,9 @@ public class FindMatchingDto { @NotNull private UUID writerId; + @NotNull + private UUID chatRoomId; + @NotNull private MatchingTypeEnum type; diff --git a/src/main/java/com/example/api/matching/dto/SaveMatchingDto.java b/src/main/java/com/example/api/matching/dto/SaveMatchingDto.java index dd577be..e6a6d61 100644 --- a/src/main/java/com/example/api/matching/dto/SaveMatchingDto.java +++ b/src/main/java/com/example/api/matching/dto/SaveMatchingDto.java @@ -7,6 +7,7 @@ import lombok.*; import java.time.LocalDateTime; +import java.util.UUID; @Getter @Setter @@ -15,6 +16,8 @@ @NoArgsConstructor @AllArgsConstructor public class SaveMatchingDto { + private UUID chatRoomId; + @NotNull private MatchingTypeEnum type; diff --git a/src/main/java/com/example/api/matching/service/MatchingApplicationService.java b/src/main/java/com/example/api/matching/service/MatchingApplicationService.java index 98026cd..ee85f48 100644 --- a/src/main/java/com/example/api/matching/service/MatchingApplicationService.java +++ b/src/main/java/com/example/api/matching/service/MatchingApplicationService.java @@ -16,6 +16,7 @@ import com.example.api.matching.domain.MatchingApplication; import com.example.api.matching.dto.FindMatchingDto; import com.example.api.matching.dto.SaveMatchingApplicationDto; +import com.example.api.member.service.MemberService; import com.example.api.user.adapter.out.persistence.UserEntity; import com.example.api.user.adapter.out.persistence.UserMapperInterface; import com.example.api.user.application.port.out.FindUserPort; @@ -37,6 +38,7 @@ public class MatchingApplicationService implements MatchingApplicationUsecase { private final FindUserPort findUserPort; private final FindMatchingPort findMatchingPort; private final MatchingApplicationPort matchingApplicationPort; + private final MemberService memberService; private final FcmService fcmService; /** @@ -126,9 +128,18 @@ public void processMatchingApplication(SaveMatchingApplicationDto matchingApplic log.error("MatchingApplicationService::processMatchingApplication: Data not found"); throw new CustomException(ErrorCodeEnum.APPLICATION_NOT_FOUND); } + MatchingApplication matchingApplication = matchingMapper.toDomain(matchingApplicationEntity.get()); matchingApplication.setState(state); matchingApplicationPort.saveMatchingApplication(matchingApplication); + + // 신청 수락 시 매칭 채팅방에 멤버 초대 + if (state.equals(ApplicationStateEnum.Approved)) { + MatchingEntity matchingEntity = findMatchingPort.getByMatchingId(matchingApplication.getMatchingId()).get(); + memberService.addMember(matchingEntity.getChatRoomId(), matchingApplication.getUserId()); + } + + // 푸시 알림 전송 FcmDto fcmDto = FcmDto.builder() .userId(matchingApplication.getUserId()) .title(state.equals(ApplicationStateEnum.Approved) ? "신청 수락" : "신청 거절") diff --git a/src/main/java/com/example/api/member/adapter/in/rest/MemberController.java b/src/main/java/com/example/api/member/adapter/in/rest/MemberController.java index 8a36f9f..d971071 100644 --- a/src/main/java/com/example/api/member/adapter/in/rest/MemberController.java +++ b/src/main/java/com/example/api/member/adapter/in/rest/MemberController.java @@ -26,7 +26,7 @@ public class MemberController { * 방 생성 후, 유저들을 초대해 들어오는 경우 * @param addMemberDto (데이터) */ - @Operation(summary = "Add member", description = "채팅방에 사용자를 초대한다.") + @Operation(summary = "Add members", description = "채팅방에 사용자를 초대한다.") @PostMapping("/members") public void addMembers(@Valid @RequestBody AddMemberDto addMemberDto) { SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); @@ -34,6 +34,6 @@ public void addMembers(@Valid @RequestBody AddMemberDto addMemberDto) { log.error("MemberController::addMembers: Login is needed"); throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); } - addMemberChatRoomUsecase.addMember(addMemberDto); + addMemberChatRoomUsecase.addMembers(addMemberDto); } } \ No newline at end of file diff --git a/src/main/java/com/example/api/member/adapter/out/persistence/MemberPersistentAdapter.java b/src/main/java/com/example/api/member/adapter/out/persistence/MemberPersistentAdapter.java index df90f70..59ee0dd 100644 --- a/src/main/java/com/example/api/member/adapter/out/persistence/MemberPersistentAdapter.java +++ b/src/main/java/com/example/api/member/adapter/out/persistence/MemberPersistentAdapter.java @@ -20,7 +20,7 @@ public class MemberPersistentAdapter implements AddMemberChatRoomPort { private final MemberRepository memberRepository; @Override - public void addMember(List members, ChatRoom chatRoom) { + public void addMembers(List members, ChatRoom chatRoom) { memberRepository.saveAll(memberMapper.fromListDomainToEntity(members, chatRoomMapper.toEntity(chatRoom))); } } \ No newline at end of file diff --git a/src/main/java/com/example/api/member/application/port/in/AddMemberChatRoomUsecase.java b/src/main/java/com/example/api/member/application/port/in/AddMemberChatRoomUsecase.java index a46a529..8623e0b 100644 --- a/src/main/java/com/example/api/member/application/port/in/AddMemberChatRoomUsecase.java +++ b/src/main/java/com/example/api/member/application/port/in/AddMemberChatRoomUsecase.java @@ -4,7 +4,10 @@ import com.example.api.matching.domain.MatchingApplication; import com.example.api.member.dto.AddMemberDto; +import java.util.UUID; + public interface AddMemberChatRoomUsecase { - void addMember(AddMemberDto addMemberDto); + void addMember(UUID chatRoomId, UUID userId); + void addMembers(AddMemberDto addMemberDto); ChatRoom setupMatchingChatRoom(MatchingApplication matchingApplication, ChatRoom chatRoom); } \ No newline at end of file diff --git a/src/main/java/com/example/api/member/application/port/out/AddMemberChatRoomPort.java b/src/main/java/com/example/api/member/application/port/out/AddMemberChatRoomPort.java index 918d585..d68acbc 100644 --- a/src/main/java/com/example/api/member/application/port/out/AddMemberChatRoomPort.java +++ b/src/main/java/com/example/api/member/application/port/out/AddMemberChatRoomPort.java @@ -6,5 +6,5 @@ import java.util.List; public interface AddMemberChatRoomPort { - void addMember(List members, ChatRoom chatRoom); + void addMembers(List members, ChatRoom chatRoom); } \ No newline at end of file diff --git a/src/main/java/com/example/api/member/service/MemberService.java b/src/main/java/com/example/api/member/service/MemberService.java index 6162d0f..174b302 100644 --- a/src/main/java/com/example/api/member/service/MemberService.java +++ b/src/main/java/com/example/api/member/service/MemberService.java @@ -13,10 +13,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.UUID; +import java.util.*; @Service @Slf4j @@ -26,14 +23,29 @@ public class MemberService implements AddMemberChatRoomUsecase { private final FindMatchingPort findMatchingPort; private final AddMemberChatRoomPort addMemberChatRoomPort; private final RetrieveChatRoomPort retrieveChatRoomPort; + + /** + * 채팅방의 한 명의 멤버 추가 + * @param chatRoomId (채팅방 ID) + * @param userId (사용자 ID) + */ + @Override + @Transactional + public void addMember(UUID chatRoomId, UUID userId) { + AddMemberDto addMemberDto = AddMemberDto.builder() + .chatroomId(chatRoomId) + .memberIds(new ArrayList<>(Collections.singletonList(userId))) + .build(); + this.addMembers(addMemberDto); + } /** - * 채팅방에 멤버 추가 + * 채팅방에 여러 명의 멤버 추가 * @param addMemberDto (데이터) */ @Override @Transactional - public void addMember(AddMemberDto addMemberDto) { + public void addMembers(AddMemberDto addMemberDto) { List members = new ArrayList<>(); ChatRoom chatRoom = retrieveChatRoomPort.retrieveChatRoom(addMemberDto.getChatroomId()); for (UUID userId: addMemberDto.getMemberIds()) { @@ -44,7 +56,7 @@ public void addMember(AddMemberDto addMemberDto) { .build(); members.add(member); } - addMemberChatRoomPort.addMember(members, chatRoom); + addMemberChatRoomPort.addMembers(members, chatRoom); } /** @@ -66,7 +78,7 @@ public ChatRoom setupMatchingChatRoom(MatchingApplication matchingApplication, C .chatroomId(chatRoom.getChatroomId()) .memberIds(memberIds) .build(); - this.addMember(addMemberDto); + this.addMembers(addMemberDto); chatRoom.setMembers(memberIds); return chatRoom; From c6985d9ed6e830de6c308cfb2813c53b2d9b43b1 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Mon, 13 Nov 2023 20:11:27 +0900 Subject: [PATCH 09/14] =?UTF-8?q?fix(BE):=20=EC=B1=84=ED=8C=85=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=A0=84=EC=86=A1=20=EC=8B=A4=ED=8C=A8=20?= =?UTF-8?q?BUS-209-MVP1-bugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/api/chat/adapter/in/rest/ChatController.java | 6 ++++++ .../api/chat/adapter/out/persistence/ChatMapper.java | 4 ++-- src/main/java/com/example/api/chat/dto/AddChatDto.java | 1 - .../java/com/example/api/common/type/ErrorCodeEnum.java | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java b/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java index 55785ab..6ce8ed6 100644 --- a/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java +++ b/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java @@ -50,8 +50,14 @@ public void sendMessage(@DestinationVariable String roomId, AddChatDto message, log.error("ChatController::sendMessage: Login is needed"); throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); } + message.setSenderId(securityUser.getUserId()); log.info("roomId : {}", roomId); + if (contentType.equals("image")) { + if (file.isEmpty()) { + log.error("ChatController:sendMessage: cannot find a image"); + throw new CustomException(ErrorCodeEnum.IMAGE_NOT_FOUND); + } message.setContent(uploadFileUsecase.uploadFile(file)); } sendChatUsecase.send(roomId, message); diff --git a/src/main/java/com/example/api/chat/adapter/out/persistence/ChatMapper.java b/src/main/java/com/example/api/chat/adapter/out/persistence/ChatMapper.java index a559843..7bcadfb 100644 --- a/src/main/java/com/example/api/chat/adapter/out/persistence/ChatMapper.java +++ b/src/main/java/com/example/api/chat/adapter/out/persistence/ChatMapper.java @@ -25,6 +25,6 @@ public interface ChatMapper { // @Mapping(source = "senderId.userId.userId", target = "senderId.userId") Chat toDomain(ChatEntity chatEntity); - @Mapping(source = "senderId",target = "senderId.userId") + @Mapping(source = "senderId", target = "senderId.userId") Chat toDomain(AddChatDto addChatDto); -} +} \ No newline at end of file diff --git a/src/main/java/com/example/api/chat/dto/AddChatDto.java b/src/main/java/com/example/api/chat/dto/AddChatDto.java index e7d2ae9..3b5ce9c 100644 --- a/src/main/java/com/example/api/chat/dto/AddChatDto.java +++ b/src/main/java/com/example/api/chat/dto/AddChatDto.java @@ -12,7 +12,6 @@ public class AddChatDto { @NotNull private UUID roomId; - @NotNull private UUID senderId; @NotBlank diff --git a/src/main/java/com/example/api/common/type/ErrorCodeEnum.java b/src/main/java/com/example/api/common/type/ErrorCodeEnum.java index 6dbf3e3..7233118 100644 --- a/src/main/java/com/example/api/common/type/ErrorCodeEnum.java +++ b/src/main/java/com/example/api/common/type/ErrorCodeEnum.java @@ -20,6 +20,7 @@ public enum ErrorCodeEnum { PREFERENCE_NOT_FOUND(HttpStatus.BAD_REQUEST, "선호도 정보가 없습니다"), APPLICATION_NOT_FOUND(HttpStatus.BAD_REQUEST, "신청 정보가 없습니다"), FILE_NOT_FOUND(HttpStatus.BAD_REQUEST, "파일이 없습니다"), + IMAGE_NOT_FOUND(HttpStatus.BAD_REQUEST, "사진이 없습니다"), INVALID_DATATYPE(HttpStatus.BAD_REQUEST, "유효하지 않은 데이터입니다"), // 401 Unauthorized LOGIN_IS_NOT_DONE(HttpStatus.UNAUTHORIZED, "로그인 정보가 없습니다"), From 087bc05fd0020b7fa5a27ef708efda8ea33e12d2 Mon Sep 17 00:00:00 2001 From: namhyo01 Date: Tue, 14 Nov 2023 03:37:16 +0900 Subject: [PATCH 10/14] =?UTF-8?q?FIX(BE):=20stomp=EC=97=90=EB=8F=84=20?= =?UTF-8?q?=EC=BF=A0=ED=82=A4=20=EB=8B=B4=EA=B8=B4=20jwt=20=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D=20=EC=B2=98=EB=A6=AC=20=EC=99=84=EB=A3=8C=20#205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/adapter/in/rest/ChatController.java | 39 +++++++++------- .../api/chat/config/StompConfiguration.java | 45 ++++++++++++++++++- .../com/example/api/chat/dto/AddChatDto.java | 2 +- .../api/chat/handler/StompHandler.java | 41 ++++++++++++++++- 4 files changed, 108 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java b/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java index 55785ab..4b51195 100644 --- a/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java +++ b/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java @@ -18,6 +18,7 @@ import org.springframework.data.domain.Sort; import org.springframework.data.web.PageableDefault; import org.springframework.messaging.handler.annotation.DestinationVariable; +import org.springframework.messaging.handler.annotation.Header; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -42,21 +43,29 @@ public class ChatController { * @param roomId (ID) * @param message (데이터) */ +// @Operation(summary = "Send message", description = "채팅방에 메시지를 보낸다.") +// @MessageMapping("/chat/{roomId}") +// public void sendMessage(@DestinationVariable String roomId, AddChatDto message, String contentType, @RequestParam("file") MultipartFile file) { +// SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); +// if (securityUser == null) { +// log.error("ChatController::sendMessage: Login is needed"); +// throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); +// } +// message.setSenderId(securityUser.getUserId()); +// if (contentType.equals("image")) { +// message.setContent(uploadFileUsecase.uploadFile(file)); +// } +// sendChatUsecase.send(roomId, message); +// } + @Operation(summary = "Send message", description = "채팅방에 메시지를 보낸다.") @MessageMapping("/chat/{roomId}") - public void sendMessage(@DestinationVariable String roomId, AddChatDto message, String contentType, @RequestParam("file") MultipartFile file) { - SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); - if (securityUser == null) { - log.error("ChatController::sendMessage: Login is needed"); - throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); - } - log.info("roomId : {}", roomId); - if (contentType.equals("image")) { - message.setContent(uploadFileUsecase.uploadFile(file)); - } + public void sendMessage(@DestinationVariable String roomId, AddChatDto message, @Header("userId") UUID userId) { + message.setSenderId(userId); sendChatUsecase.send(roomId, message); } + /** * 구독을 시작할 때 클라이언트가 사용 * 컨슈머가 없을 시 등록 + 추후에 유저 추가 알림 같은 것을 전달 가능해 보임 @@ -65,11 +74,11 @@ public void sendMessage(@DestinationVariable String roomId, AddChatDto message, @Operation(summary = "Enter chatroom", description = "채팅방에 입장한다.") @MessageMapping("/subscribe/{roomId}") public void subscribe(@DestinationVariable String roomId) { - SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); - if (securityUser == null) { - log.error("ChatController::subscribe: Login is needed"); - throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); - } +// SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); +// if (securityUser == null) { +// log.error("ChatController::subscribe: Login is needed"); +// throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); +// } subscribeRoomUsecase.subscribe(roomId); } diff --git a/src/main/java/com/example/api/chat/config/StompConfiguration.java b/src/main/java/com/example/api/chat/config/StompConfiguration.java index a7e3319..9d35f0a 100644 --- a/src/main/java/com/example/api/chat/config/StompConfiguration.java +++ b/src/main/java/com/example/api/chat/config/StompConfiguration.java @@ -1,11 +1,25 @@ package com.example.api.chat.config; import com.example.api.chat.handler.StompHandler; +import com.example.api.common.exception.CustomException; +import com.example.api.common.type.ErrorCodeEnum; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.server.ServerHttpRequest; +import org.springframework.http.server.ServerHttpResponse; +import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.messaging.simp.config.ChannelRegistration; import org.springframework.messaging.simp.config.MessageBrokerRegistry; +import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.config.annotation.*; +import org.springframework.web.socket.server.HandshakeInterceptor; +import org.springframework.web.util.WebUtils; + +import java.util.Map; @Configuration @EnableWebSocketMessageBroker // STOMP 사용 용도 @@ -19,11 +33,13 @@ public class StompConfiguration implements WebSocketMessageBrokerConfigurer { public void registerStompEndpoints(StompEndpointRegistry registry) { registry.addEndpoint("/ws/chat") .setAllowedOriginPatterns("*") - .withSockJS(); + .withSockJS() + .setInterceptors(httpSessHandshakeInterceptor()) + ; } // TODO - // 추후 jwt 인증시 필요 - 인증 절차 + // 추후 jwt 인증시 필요 - 인증 절차m @Override public void configureClientInboundChannel(ChannelRegistration registration) { registration.interceptors(stompHandler); @@ -41,6 +57,31 @@ public void configureMessageBroker(MessageBrokerRegistry registry) { registry.setApplicationDestinationPrefixes("/pub"); } + @Bean + public HandshakeInterceptor httpSessHandshakeInterceptor() { + return new HandshakeInterceptor() { + @Override + public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map attributes) throws Exception { + if (request instanceof ServletServerHttpRequest){ + ServletServerHttpRequest servletServerRequest = (ServletServerHttpRequest) request; + HttpServletRequest servletRequest = servletServerRequest.getServletRequest(); + Cookie token = WebUtils.getCookie(servletRequest, "access_token"); + if (token != null){ + attributes.put("token", token.getValue()); + } else{ + throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); + } + } + return true; + } + + @Override + public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) { + + } + }; + } + // 64 KB 이상의 데이터 전송을 위해 사용 @Override public void configureWebSocketTransport(WebSocketTransportRegistration registry) { diff --git a/src/main/java/com/example/api/chat/dto/AddChatDto.java b/src/main/java/com/example/api/chat/dto/AddChatDto.java index e7d2ae9..b428994 100644 --- a/src/main/java/com/example/api/chat/dto/AddChatDto.java +++ b/src/main/java/com/example/api/chat/dto/AddChatDto.java @@ -12,7 +12,7 @@ public class AddChatDto { @NotNull private UUID roomId; - @NotNull +// @NotNull private UUID senderId; @NotBlank diff --git a/src/main/java/com/example/api/chat/handler/StompHandler.java b/src/main/java/com/example/api/chat/handler/StompHandler.java index e359418..fd7bf40 100644 --- a/src/main/java/com/example/api/chat/handler/StompHandler.java +++ b/src/main/java/com/example/api/chat/handler/StompHandler.java @@ -1,6 +1,15 @@ package com.example.api.chat.handler; +import com.example.api.auth.domain.SecurityUser; +import com.example.api.auth.service.JwtUtilService; +import com.example.api.chat.exception.JwtException; +import com.example.api.common.exception.CustomException; +import com.example.api.common.type.ErrorCodeEnum; +import com.example.api.common.utils.AuthenticationUtils; +import com.example.api.user.service.UserService; +import jakarta.servlet.http.Cookie; import lombok.NonNull; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -9,13 +18,43 @@ import org.springframework.messaging.simp.stomp.StompHeaderAccessor; import org.springframework.messaging.support.ChannelInterceptor; import org.springframework.messaging.support.MessageHeaderAccessor; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; -import java.util.Objects; +import java.util.*; @Slf4j +@RequiredArgsConstructor @Component public class StompHandler implements ChannelInterceptor{ + private final JwtUtilService jwtUtilService; + private final UserService userService; + /** + * 메시지를 보내기전에 jwt 인증 검사 + * @param message + * @param channel + * @return + */ + @Override + public Message preSend(Message message, MessageChannel channel) { + StompHeaderAccessor accessor = StompHeaderAccessor.getAccessor(message, StompHeaderAccessor.class); + + Map sessionAttributes = accessor.getSessionAttributes(); + String token = (String) sessionAttributes.get("token"); + + if (!jwtUtilService.verifyToken(token)) { + log.info("JWT 이슈 발생"); + throw new JwtException("Access Token 만료"); + } else { + // Security Context에 등록할 user 객체 생성 + SecurityUser userinfo = userService.findSocialUser(jwtUtilService.getId(token), jwtUtilService.getProvider(token)); + accessor.setHeader("userId", userinfo.getUserId()); + } + return message; + } + @Override public void postSend(@NonNull Message message,@NonNull MessageChannel channel, boolean sent) { StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message); From b94b4402f42bebbc53ad8880d4c128d91df32e26 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Tue, 14 Nov 2023 10:11:13 +0900 Subject: [PATCH 11/14] =?UTF-8?q?fix(BE):=20=EC=B1=84=ED=8C=85=20=EC=A0=84?= =?UTF-8?q?=EC=86=A1=20=EC=8B=A4=ED=8C=A8=20BUS-208-matching-chatroom-conn?= =?UTF-8?q?ect=20#205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/adapter/in/rest/ChatController.java | 52 ++++++++----------- .../com/example/api/chat/dto/AddChatDto.java | 1 - .../api/chatroom/type/ChatRoomEnum.java | 4 +- .../api/common/type/ApplicationStateEnum.java | 4 +- .../api/common/type/ErrorCodeEnum.java | 1 + .../api/matching/type/MatchingTypeEnum.java | 4 +- .../type/NotificationTypeEnum.java | 2 +- .../api/preference/type/PreferSmokeEnum.java | 4 +- .../api/preference/type/TasteEnum.java | 2 +- .../example/api/user/type/UserGenderEnum.java | 4 +- .../example/api/user/type/UserRoleEnum.java | 4 +- 11 files changed, 37 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java b/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java index 4b51195..1ffc5b8 100644 --- a/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java +++ b/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java @@ -9,7 +9,7 @@ import com.example.api.common.exception.CustomException; import com.example.api.common.type.ErrorCodeEnum; import com.example.api.common.utils.AuthenticationUtils; -import com.example.api.multipart.application.port.in.UploadFileUsecase; +import com.example.api.s3.application.port.in.FileUploadUsecase; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; @@ -20,52 +20,49 @@ import org.springframework.messaging.handler.annotation.DestinationVariable; import org.springframework.messaging.handler.annotation.Header; import org.springframework.messaging.handler.annotation.MessageMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.util.List; import java.util.UUID; @RestController -@Slf4j @RequiredArgsConstructor +@Slf4j @Tag(name = "Chat", description = "Chat API") public class ChatController { private final SendChatUsecase sendChatUsecase; private final SubscribeRoomUsecase subscribeRoomUsecase; private final GetChatListUsecase getChatListUsecase; - private final UploadFileUsecase uploadFileUsecase; + private final FileUploadUsecase fileUploadUsecase; /** * 추후에 jwt 인증을 통해 유저 데이터를 불러와 message에 추가할 예정 * @param roomId (ID) - * @param message (데이터) + * @param message (메시지) */ -// @Operation(summary = "Send message", description = "채팅방에 메시지를 보낸다.") -// @MessageMapping("/chat/{roomId}") -// public void sendMessage(@DestinationVariable String roomId, AddChatDto message, String contentType, @RequestParam("file") MultipartFile file) { -// SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); -// if (securityUser == null) { -// log.error("ChatController::sendMessage: Login is needed"); -// throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); -// } -// message.setSenderId(securityUser.getUserId()); -// if (contentType.equals("image")) { -// message.setContent(uploadFileUsecase.uploadFile(file)); -// } -// sendChatUsecase.send(roomId, message); -// } - @Operation(summary = "Send message", description = "채팅방에 메시지를 보낸다.") - @MessageMapping("/chat/{roomId}") - public void sendMessage(@DestinationVariable String roomId, AddChatDto message, @Header("userId") UUID userId) { + @MessageMapping(value = "/chat/{roomId}") + public void sendMessage(@DestinationVariable String roomId, @Header("userId") UUID userId, AddChatDto message) { message.setSenderId(userId); sendChatUsecase.send(roomId, message); } - + /** + * 채팅 이미지 업로드 + * @param file (이미지) + * @return filename + */ + @Operation(summary = "Upload chat image", description = "채팅 이미지를 업로드한다.") + @PostMapping("/chat/image") + public String upload(@RequestBody MultipartFile file) { + if (file == null) { + log.error("ChatController::sendMessage: image is not found"); + throw new CustomException(ErrorCodeEnum.IMAGE_NOT_FOUND); + } + return fileUploadUsecase.upload(file); + } + /** * 구독을 시작할 때 클라이언트가 사용 * 컨슈머가 없을 시 등록 + 추후에 유저 추가 알림 같은 것을 전달 가능해 보임 @@ -74,11 +71,6 @@ public void sendMessage(@DestinationVariable String roomId, AddChatDto message, @Operation(summary = "Enter chatroom", description = "채팅방에 입장한다.") @MessageMapping("/subscribe/{roomId}") public void subscribe(@DestinationVariable String roomId) { -// SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); -// if (securityUser == null) { -// log.error("ChatController::subscribe: Login is needed"); -// throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); -// } subscribeRoomUsecase.subscribe(roomId); } diff --git a/src/main/java/com/example/api/chat/dto/AddChatDto.java b/src/main/java/com/example/api/chat/dto/AddChatDto.java index b428994..3b5ce9c 100644 --- a/src/main/java/com/example/api/chat/dto/AddChatDto.java +++ b/src/main/java/com/example/api/chat/dto/AddChatDto.java @@ -12,7 +12,6 @@ public class AddChatDto { @NotNull private UUID roomId; -// @NotNull private UUID senderId; @NotBlank diff --git a/src/main/java/com/example/api/chatroom/type/ChatRoomEnum.java b/src/main/java/com/example/api/chatroom/type/ChatRoomEnum.java index 03c00ff..552e6c0 100644 --- a/src/main/java/com/example/api/chatroom/type/ChatRoomEnum.java +++ b/src/main/java/com/example/api/chatroom/type/ChatRoomEnum.java @@ -4,9 +4,9 @@ import lombok.Getter; import lombok.ToString; -@ToString -@AllArgsConstructor @Getter +@AllArgsConstructor +@ToString public enum ChatRoomEnum { Normal("일반", 1), Matching("매칭", 2), diff --git a/src/main/java/com/example/api/common/type/ApplicationStateEnum.java b/src/main/java/com/example/api/common/type/ApplicationStateEnum.java index 0d52d65..1df28c6 100644 --- a/src/main/java/com/example/api/common/type/ApplicationStateEnum.java +++ b/src/main/java/com/example/api/common/type/ApplicationStateEnum.java @@ -4,9 +4,9 @@ import lombok.Getter; import lombok.ToString; -@ToString -@AllArgsConstructor @Getter +@AllArgsConstructor +@ToString public enum ApplicationStateEnum { Pending("대기", 0), Canceled("취소", 1), diff --git a/src/main/java/com/example/api/common/type/ErrorCodeEnum.java b/src/main/java/com/example/api/common/type/ErrorCodeEnum.java index 6dbf3e3..e16bc3f 100644 --- a/src/main/java/com/example/api/common/type/ErrorCodeEnum.java +++ b/src/main/java/com/example/api/common/type/ErrorCodeEnum.java @@ -19,6 +19,7 @@ public enum ErrorCodeEnum { MATCHING_NOT_FOUND(HttpStatus.BAD_REQUEST, "매칭 정보가 없습니다"), PREFERENCE_NOT_FOUND(HttpStatus.BAD_REQUEST, "선호도 정보가 없습니다"), APPLICATION_NOT_FOUND(HttpStatus.BAD_REQUEST, "신청 정보가 없습니다"), + IMAGE_NOT_FOUND(HttpStatus.BAD_REQUEST, "사진이 없습니다"), FILE_NOT_FOUND(HttpStatus.BAD_REQUEST, "파일이 없습니다"), INVALID_DATATYPE(HttpStatus.BAD_REQUEST, "유효하지 않은 데이터입니다"), // 401 Unauthorized diff --git a/src/main/java/com/example/api/matching/type/MatchingTypeEnum.java b/src/main/java/com/example/api/matching/type/MatchingTypeEnum.java index 223299f..3f594da 100644 --- a/src/main/java/com/example/api/matching/type/MatchingTypeEnum.java +++ b/src/main/java/com/example/api/matching/type/MatchingTypeEnum.java @@ -4,9 +4,9 @@ import lombok.Getter; import lombok.ToString; -@ToString -@AllArgsConstructor @Getter +@AllArgsConstructor +@ToString public enum MatchingTypeEnum { TravelMate("여행객 매칭"), Dining("식사 매칭"), diff --git a/src/main/java/com/example/api/notification/type/NotificationTypeEnum.java b/src/main/java/com/example/api/notification/type/NotificationTypeEnum.java index c62d131..af9f3f3 100644 --- a/src/main/java/com/example/api/notification/type/NotificationTypeEnum.java +++ b/src/main/java/com/example/api/notification/type/NotificationTypeEnum.java @@ -5,8 +5,8 @@ import lombok.ToString; @Getter -@ToString @AllArgsConstructor +@ToString public enum NotificationTypeEnum { NewApplication("새로운 매칭 신청", 0), ApplicationApproved("매칭 신청 수락", 1), diff --git a/src/main/java/com/example/api/preference/type/PreferSmokeEnum.java b/src/main/java/com/example/api/preference/type/PreferSmokeEnum.java index 87e84da..5cf28f3 100644 --- a/src/main/java/com/example/api/preference/type/PreferSmokeEnum.java +++ b/src/main/java/com/example/api/preference/type/PreferSmokeEnum.java @@ -4,9 +4,9 @@ import lombok.Getter; import lombok.ToString; -@ToString -@AllArgsConstructor @Getter +@AllArgsConstructor +@ToString public enum PreferSmokeEnum { None("선호 없음", 0), Nonsmoke("비흡연", 1), diff --git a/src/main/java/com/example/api/preference/type/TasteEnum.java b/src/main/java/com/example/api/preference/type/TasteEnum.java index 9444599..cbe6b1b 100644 --- a/src/main/java/com/example/api/preference/type/TasteEnum.java +++ b/src/main/java/com/example/api/preference/type/TasteEnum.java @@ -5,8 +5,8 @@ import lombok.ToString; @Getter -@ToString @AllArgsConstructor +@ToString public enum TasteEnum { Cold("찬 음식", 1), Hot("뜨거운 음식", 2), diff --git a/src/main/java/com/example/api/user/type/UserGenderEnum.java b/src/main/java/com/example/api/user/type/UserGenderEnum.java index e41983d..c92b53d 100644 --- a/src/main/java/com/example/api/user/type/UserGenderEnum.java +++ b/src/main/java/com/example/api/user/type/UserGenderEnum.java @@ -4,9 +4,9 @@ import lombok.Getter; import lombok.ToString; -@ToString -@AllArgsConstructor @Getter +@AllArgsConstructor +@ToString public enum UserGenderEnum { None("없음", 0), Female("여자", 1), diff --git a/src/main/java/com/example/api/user/type/UserRoleEnum.java b/src/main/java/com/example/api/user/type/UserRoleEnum.java index 68d7de4..c925c94 100644 --- a/src/main/java/com/example/api/user/type/UserRoleEnum.java +++ b/src/main/java/com/example/api/user/type/UserRoleEnum.java @@ -4,9 +4,9 @@ import lombok.Getter; import lombok.ToString; -@ToString -@AllArgsConstructor @Getter +@AllArgsConstructor +@ToString public enum UserRoleEnum { Admin("관리자", 1), User("일반 사용자", 2); From 9f7cac16d0f8e8db8c43139c12b393dabaa66ee4 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Tue, 14 Nov 2023 13:13:00 +0900 Subject: [PATCH 12/14] =?UTF-8?q?fix(BE):=20Enum=20=EC=A4=91=EB=B3=B5=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20BUS-209-MVP1-bugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/api/common/type/ErrorCodeEnum.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/example/api/common/type/ErrorCodeEnum.java b/src/main/java/com/example/api/common/type/ErrorCodeEnum.java index ffd0e1c..e16bc3f 100644 --- a/src/main/java/com/example/api/common/type/ErrorCodeEnum.java +++ b/src/main/java/com/example/api/common/type/ErrorCodeEnum.java @@ -21,7 +21,6 @@ public enum ErrorCodeEnum { APPLICATION_NOT_FOUND(HttpStatus.BAD_REQUEST, "신청 정보가 없습니다"), IMAGE_NOT_FOUND(HttpStatus.BAD_REQUEST, "사진이 없습니다"), FILE_NOT_FOUND(HttpStatus.BAD_REQUEST, "파일이 없습니다"), - IMAGE_NOT_FOUND(HttpStatus.BAD_REQUEST, "사진이 없습니다"), INVALID_DATATYPE(HttpStatus.BAD_REQUEST, "유효하지 않은 데이터입니다"), // 401 Unauthorized LOGIN_IS_NOT_DONE(HttpStatus.UNAUTHORIZED, "로그인 정보가 없습니다"), From 72b95c983b9d092036fffc2777f37304162074cd Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Tue, 14 Nov 2023 14:21:55 +0900 Subject: [PATCH 13/14] =?UTF-8?q?feat(BE):=20=EA=B0=9C=EB=B3=84=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20ID=20=EC=A1=B0=ED=9A=8C/ID?= =?UTF-8?q?=EB=A1=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?BUS-209-MVP1-bugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/adapter/in/rest/ChatController.java | 4 +-- .../adapter/out/persistence/SocialMapper.java | 3 +- .../user/adapter/in/rest/UserController.java | 31 +++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java b/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java index 1ffc5b8..3e815e9 100644 --- a/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java +++ b/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java @@ -42,7 +42,7 @@ public class ChatController { * @param message (메시지) */ @Operation(summary = "Send message", description = "채팅방에 메시지를 보낸다.") - @MessageMapping(value = "/chat/{roomId}") + @MessageMapping("/chat/{roomId}") public void sendMessage(@DestinationVariable String roomId, @Header("userId") UUID userId, AddChatDto message) { message.setSenderId(userId); sendChatUsecase.send(roomId, message); @@ -57,7 +57,7 @@ public void sendMessage(@DestinationVariable String roomId, @Header("userId") UU @PostMapping("/chat/image") public String upload(@RequestBody MultipartFile file) { if (file == null) { - log.error("ChatController::sendMessage: image is not found"); + log.error("ChatController::upload: image is not found"); throw new CustomException(ErrorCodeEnum.IMAGE_NOT_FOUND); } return fileUploadUsecase.upload(file); diff --git a/src/main/java/com/example/api/social/adapter/out/persistence/SocialMapper.java b/src/main/java/com/example/api/social/adapter/out/persistence/SocialMapper.java index 63c98d0..c09707f 100644 --- a/src/main/java/com/example/api/social/adapter/out/persistence/SocialMapper.java +++ b/src/main/java/com/example/api/social/adapter/out/persistence/SocialMapper.java @@ -1,6 +1,5 @@ package com.example.api.social.adapter.out.persistence; - import com.example.api.social.dto.AddSocialDto; import org.mapstruct.InjectionStrategy; import org.mapstruct.Mapper; @@ -46,4 +45,4 @@ public interface SocialMapper { @Mapping(target = "appleId", constant = "''") @Mapping(target = "googleId", constant = "''") SocialEntity toEntityNaver(AddSocialDto addSocialDto); -} +} \ No newline at end of file diff --git a/src/main/java/com/example/api/user/adapter/in/rest/UserController.java b/src/main/java/com/example/api/user/adapter/in/rest/UserController.java index f0eb41f..a4166a9 100644 --- a/src/main/java/com/example/api/user/adapter/in/rest/UserController.java +++ b/src/main/java/com/example/api/user/adapter/in/rest/UserController.java @@ -24,6 +24,7 @@ import org.springframework.core.io.InputStreamResource; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.messaging.handler.annotation.DestinationVariable; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.WebDataBinder; @@ -103,6 +104,21 @@ public List getAll() { return findUserUsecase.getAll(); } + /** + * 로그인한 사용자 ID 조회 + * @return user ID + */ + @Operation(summary = "Get userId", description = "사용자 ID를 조회한다.") + @GetMapping("/user/id") + public UUID getUserId() { + SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); + if (securityUser == null) { + log.error("UserController::getUserId: Login is needed"); + throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); + } + return securityUser.getUserId(); + } + /** * 개별 사용자 조회 * @return User data @@ -118,6 +134,21 @@ public FindUserDto getUser() { return findUserUsecase.getUser(securityUser.getUserId()); } + /** + * ID로 사용자 조회 + * @return User data + */ + @Operation(summary = "Get user by userId", description = "ID가 userId인 사용자를 조회한다.") + @GetMapping("/user/{userId}") + public FindUserDto getUserByUserId(@PathVariable UUID userId) { + SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); + if (securityUser == null) { + log.error("UserController::getUserByUserId: Login is needed"); + throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); + } + return findUserUsecase.getUser(userId); + } + /** * ID가 userId인 사용자의 추천 매칭 목록 조회 * @return Recommended matching list From b1345cb9c44d5efa24c3c0d00addef0bdfcaf1e3 Mon Sep 17 00:00:00 2001 From: Lemonade255 Date: Tue, 14 Nov 2023 18:48:46 +0900 Subject: [PATCH 14/14] =?UTF-8?q?fix(BE):=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EC=A0=88=EC=B0=A8=20=EC=83=9D=EB=9E=B5=20?= =?UTF-8?q?BUS-209-MVP1-bugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/api/auth/adapter/in/AuthController.java | 3 +-- .../api/chatroom/adapter/in/rest/ChatRoomController.java | 2 +- .../api/matching/adapter/in/rest/MatchingController.java | 7 +++---- .../api/member/adapter/in/rest/MemberController.java | 2 +- .../preference/adapter/in/rest/PreferenceController.java | 1 - .../com/example/api/sms/adapter/in/rest/SmsController.java | 2 +- .../example/api/user/adapter/in/rest/UserController.java | 1 - .../java/com/example/api/user/service/UserService.java | 2 +- 8 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/example/api/auth/adapter/in/AuthController.java b/src/main/java/com/example/api/auth/adapter/in/AuthController.java index a142c55..b93b5f6 100644 --- a/src/main/java/com/example/api/auth/adapter/in/AuthController.java +++ b/src/main/java/com/example/api/auth/adapter/in/AuthController.java @@ -8,15 +8,14 @@ import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.Optional; @RestController -@Slf4j @RequiredArgsConstructor +@Slf4j public class AuthController { private final JwtUtilService jwtUtilService; private final FindRefreshUsecase findRefreshUsecase; diff --git a/src/main/java/com/example/api/chatroom/adapter/in/rest/ChatRoomController.java b/src/main/java/com/example/api/chatroom/adapter/in/rest/ChatRoomController.java index 6fe7035..82c0346 100644 --- a/src/main/java/com/example/api/chatroom/adapter/in/rest/ChatRoomController.java +++ b/src/main/java/com/example/api/chatroom/adapter/in/rest/ChatRoomController.java @@ -22,8 +22,8 @@ import java.util.UUID; @RestController -@Slf4j @RequiredArgsConstructor +@Slf4j @Tag(name = "ChatRoom", description = "ChatRoom API") public class ChatRoomController { private final CreateChatRoomUsecase createChatRoomUsecase; diff --git a/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java b/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java index fb2e98a..c845bff 100644 --- a/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java +++ b/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java @@ -87,11 +87,10 @@ public FindMatchingDto createMatching(@Valid @RequestBody SaveMatchingDto saveMa /** * 새 매칭 신청 생성 * @param matchingApplicationDto (데이터) - * @return chatroom */ @Operation(summary = "Create matching application", description = "새로운 매칭 신청을 생성한다.") @PostMapping("/matching/application") - public ChatRoom createMatchingApplication(@Valid @RequestBody SaveMatchingApplicationDto matchingApplicationDto) { + public void createMatchingApplication(@Valid @RequestBody SaveMatchingApplicationDto matchingApplicationDto) { SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); if (securityUser == null) { log.error("MatchingController::createMatchingApplication: Login is needed"); @@ -108,8 +107,8 @@ public ChatRoom createMatchingApplication(@Valid @RequestBody SaveMatchingApplic } MatchingApplication matchingApplication = matchingApplicationUsecase.createMatchingApplicationData(securityUser.getUserId(), matchingApplicationDto); - ChatRoom chatRoom = createChatRoomUsecase.createMatchingChatRoom(matchingApplication); - return addMemberChatRoomUsecase.setupMatchingChatRoom(matchingApplication, chatRoom); + //ChatRoom chatRoom = createChatRoomUsecase.createMatchingChatRoom(matchingApplication); + //return addMemberChatRoomUsecase.setupMatchingChatRoom(matchingApplication, chatRoom); } /** diff --git a/src/main/java/com/example/api/member/adapter/in/rest/MemberController.java b/src/main/java/com/example/api/member/adapter/in/rest/MemberController.java index d971071..b4140f9 100644 --- a/src/main/java/com/example/api/member/adapter/in/rest/MemberController.java +++ b/src/main/java/com/example/api/member/adapter/in/rest/MemberController.java @@ -16,8 +16,8 @@ import org.springframework.web.bind.annotation.RestController; @RestController -@Slf4j @RequiredArgsConstructor +@Slf4j @Tag(name = "Member", description = "Member API") public class MemberController { private final AddMemberChatRoomUsecase addMemberChatRoomUsecase; diff --git a/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java b/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java index 32c7a99..0767ed5 100644 --- a/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java +++ b/src/main/java/com/example/api/preference/adapter/in/rest/PreferenceController.java @@ -22,7 +22,6 @@ public class PreferenceController { private final FindPreferenceUsecase findPreferenceUsecase; private final UserPreferenceUsecase userPreferenceUsecase; private final MatchingPreferenceUsecase matchingPreferenceUsecase; - private final ComparePreferenceUsecase comparePreferenceUsecase; /** * 선호도 데이터 생성 diff --git a/src/main/java/com/example/api/sms/adapter/in/rest/SmsController.java b/src/main/java/com/example/api/sms/adapter/in/rest/SmsController.java index 828fa49..c46bacf 100644 --- a/src/main/java/com/example/api/sms/adapter/in/rest/SmsController.java +++ b/src/main/java/com/example/api/sms/adapter/in/rest/SmsController.java @@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.*; @RestController -@Slf4j @RequiredArgsConstructor +@Slf4j public class SmsController { private final SendCertificationCodeUsecase sendCertificationCodeUsecase; private final VerifyCodeUsecase verifyCodeUsecase; diff --git a/src/main/java/com/example/api/user/adapter/in/rest/UserController.java b/src/main/java/com/example/api/user/adapter/in/rest/UserController.java index a4166a9..b8be059 100644 --- a/src/main/java/com/example/api/user/adapter/in/rest/UserController.java +++ b/src/main/java/com/example/api/user/adapter/in/rest/UserController.java @@ -24,7 +24,6 @@ import org.springframework.core.io.InputStreamResource; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.messaging.handler.annotation.DestinationVariable; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.WebDataBinder; diff --git a/src/main/java/com/example/api/user/service/UserService.java b/src/main/java/com/example/api/user/service/UserService.java index 5dfa67e..146a134 100644 --- a/src/main/java/com/example/api/user/service/UserService.java +++ b/src/main/java/com/example/api/user/service/UserService.java @@ -144,7 +144,7 @@ public void saveProfileImage(UUID userId, String filename) { ProfileImage profileImage = ProfileImage.builder() .userId(userId) .profileImage(filename) - .state(ApplicationStateEnum.Pending) + .state(ApplicationStateEnum.Approved) .updatedAt(LocalDateTime.now()) .build(); profileImagePort.saveProfileImage(profileImage);