From 0d263f0d3d9ccd331af99fbb19cfcf498fc35420 Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Thu, 14 Aug 2025 11:47:09 +0900 Subject: [PATCH 01/14] =?UTF-8?q?feat:=20=EC=A7=80=EC=97=AD=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EC=9A=94=EC=B2=AD=20DTO=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../siteuser/dto/LocationUpdateRequest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/example/solidconnection/siteuser/dto/LocationUpdateRequest.java diff --git a/src/main/java/com/example/solidconnection/siteuser/dto/LocationUpdateRequest.java b/src/main/java/com/example/solidconnection/siteuser/dto/LocationUpdateRequest.java new file mode 100644 index 000000000..2bb38e9cc --- /dev/null +++ b/src/main/java/com/example/solidconnection/siteuser/dto/LocationUpdateRequest.java @@ -0,0 +1,10 @@ +package com.example.solidconnection.siteuser.dto; + +import java.util.List; + +public record LocationUpdateRequest( + List interestedRegions, + List interestedCountries +) { + +} From 9ee993aba35a633d54382e244df893f0f5b2e9b3 Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Thu, 14 Aug 2025 12:02:45 +0900 Subject: [PATCH 02/14] =?UTF-8?q?feat:=20=EA=B4=80=EC=8B=AC=20=EC=A7=80?= =?UTF-8?q?=EC=97=AD=20=EB=B3=80=EA=B2=BD=20=EC=84=9C=EB=B9=84=EC=8A=A4=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/InterestedCountryRepository.java | 5 +++++ .../country/service/InterestedCountryService.java | 11 +++++++++++ .../region/repository/InterestedRegionRepository.java | 5 +++++ .../region/service/InterestedRegionService.java | 11 +++++++++++ 4 files changed, 32 insertions(+) diff --git a/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java b/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java index 0d555b7bb..edd694b0e 100644 --- a/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java +++ b/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java @@ -1,10 +1,15 @@ package com.example.solidconnection.location.country.repository; import com.example.solidconnection.location.country.domain.InterestedCountry; +import com.example.solidconnection.siteuser.domain.SiteUser; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; public interface InterestedCountryRepository extends JpaRepository { List findAllBySiteUserId(long siteUserId); + + @Modifying + void deleteBySiteUser(SiteUser siteUser); } diff --git a/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java b/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java index 8166de968..b8db8d874 100644 --- a/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java +++ b/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java @@ -24,4 +24,15 @@ public void saveInterestedCountry(SiteUser siteUser, List koreanNames) { .toList(); interestedCountryRepository.saveAll(interestedCountries); } + + @Transactional + public void updateInterestedCountry(SiteUser siteUser, List koreanNames) { + interestedCountryRepository.deleteBySiteUser(siteUser); + + List interestedCountries = countryRepository.findAllByKoreanNameIn(koreanNames) + .stream() + .map(country -> new InterestedCountry(siteUser, country)) + .toList(); + interestedCountryRepository.saveAll(interestedCountries); + } } diff --git a/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java b/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java index 335218c08..b2bb5a1ed 100644 --- a/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java +++ b/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java @@ -1,10 +1,15 @@ package com.example.solidconnection.location.region.repository; import com.example.solidconnection.location.region.domain.InterestedRegion; +import com.example.solidconnection.siteuser.domain.SiteUser; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; public interface InterestedRegionRepository extends JpaRepository { List findAllBySiteUserId(long siteUserId); + + @Modifying + void deleteBySiteUser(SiteUser siteUser); } diff --git a/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java b/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java index 6dc71263e..086f844c1 100644 --- a/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java +++ b/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java @@ -24,4 +24,15 @@ public void saveInterestedRegion(SiteUser siteUser, List koreanNames) { .toList(); interestedRegionRepository.saveAll(interestedRegions); } + + @Transactional + public void updateInterestedRegion(SiteUser siteUser, List koreanNames) { + interestedRegionRepository.deleteBySiteUser(siteUser); + + List interestedRegions = regionRepository.findAllByKoreanNameIn(koreanNames) + .stream() + .map(region -> new InterestedRegion(siteUser, region)) + .toList(); + interestedRegionRepository.saveAll(interestedRegions); + } } From 40d8d5ee26709cb846ae6634ce46dda5de6561a5 Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Thu, 14 Aug 2025 12:56:18 +0900 Subject: [PATCH 03/14] =?UTF-8?q?feat:=20=EA=B4=80=EC=8B=AC=20=EC=A7=80?= =?UTF-8?q?=EC=97=AD=20=EB=B3=80=EA=B2=BD=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../siteuser/controller/MyPageController.java | 10 ++++++++++ .../siteuser/service/MyPageService.java | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java b/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java index 534b6c361..bf1375821 100644 --- a/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java +++ b/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java @@ -2,6 +2,7 @@ import com.example.solidconnection.common.resolver.AuthorizedUser; +import com.example.solidconnection.siteuser.dto.LocationUpdateRequest; import com.example.solidconnection.siteuser.dto.MyPageResponse; import com.example.solidconnection.siteuser.dto.PasswordUpdateRequest; import com.example.solidconnection.siteuser.service.MyPageService; @@ -49,4 +50,13 @@ public ResponseEntity updatePassword( myPageService.updatePassword(siteUserId, request); return ResponseEntity.ok().build(); } + + @PatchMapping("/location") + public ResponseEntity updateLocation( + @AuthorizedUser long siteUserId, + @RequestBody LocationUpdateRequest request + ) { + myPageService.updateLocation(siteUserId, request); + return ResponseEntity.ok().build(); + } } diff --git a/src/main/java/com/example/solidconnection/siteuser/service/MyPageService.java b/src/main/java/com/example/solidconnection/siteuser/service/MyPageService.java index 1800df32b..695b6129f 100644 --- a/src/main/java/com/example/solidconnection/siteuser/service/MyPageService.java +++ b/src/main/java/com/example/solidconnection/siteuser/service/MyPageService.java @@ -6,10 +6,13 @@ import static com.example.solidconnection.common.exception.ErrorCode.USER_NOT_FOUND; import com.example.solidconnection.common.exception.CustomException; +import com.example.solidconnection.location.country.service.InterestedCountryService; +import com.example.solidconnection.location.region.service.InterestedRegionService; import com.example.solidconnection.s3.domain.ImgType; import com.example.solidconnection.s3.dto.UploadedFileUrlResponse; import com.example.solidconnection.s3.service.S3Service; import com.example.solidconnection.siteuser.domain.SiteUser; +import com.example.solidconnection.siteuser.dto.LocationUpdateRequest; import com.example.solidconnection.siteuser.dto.MyPageResponse; import com.example.solidconnection.siteuser.dto.PasswordUpdateRequest; import com.example.solidconnection.siteuser.repository.SiteUserRepository; @@ -33,6 +36,8 @@ public class MyPageService { private final SiteUserRepository siteUserRepository; private final LikedUnivApplyInfoRepository likedUnivApplyInfoRepository; private final S3Service s3Service; + private final InterestedCountryService interestedCountryService; + private final InterestedRegionService interestedRegionService; /* * 마이페이지 정보를 조회한다. @@ -108,4 +113,13 @@ private void validatePasswordMatch(String currentPassword, String userPassword) throw new CustomException(PASSWORD_MISMATCH); } } + + @Transactional + public void updateLocation(long siteUserId, LocationUpdateRequest request) { + SiteUser siteUser = siteUserRepository.findById(siteUserId) + .orElseThrow(() -> new CustomException(USER_NOT_FOUND)); + + interestedCountryService.updateInterestedCountry(siteUser, request.interestedCountries()); + interestedRegionService.updateInterestedRegion(siteUser, request.interestedRegions()); + } } From 51b462b20b53c0d76148843dc947cc2c75c0a507 Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Thu, 14 Aug 2025 13:26:10 +0900 Subject: [PATCH 04/14] =?UTF-8?q?fix:=20siteUser=EA=B0=80=20=EC=95=84?= =?UTF-8?q?=EB=8B=88=EB=9D=BC=20siteUserId=EB=A1=9C=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../country/repository/InterestedCountryRepository.java | 3 +-- .../location/country/service/InterestedCountryService.java | 2 +- .../location/region/repository/InterestedRegionRepository.java | 3 +-- .../location/region/service/InterestedRegionService.java | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java b/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java index edd694b0e..b8c6d4f0d 100644 --- a/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java +++ b/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java @@ -1,7 +1,6 @@ package com.example.solidconnection.location.country.repository; import com.example.solidconnection.location.country.domain.InterestedCountry; -import com.example.solidconnection.siteuser.domain.SiteUser; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; @@ -11,5 +10,5 @@ public interface InterestedCountryRepository extends JpaRepository findAllBySiteUserId(long siteUserId); @Modifying - void deleteBySiteUser(SiteUser siteUser); + void deleteBySiteUserId(long siteUserId); } diff --git a/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java b/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java index b8db8d874..f1abc0f99 100644 --- a/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java +++ b/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java @@ -27,7 +27,7 @@ public void saveInterestedCountry(SiteUser siteUser, List koreanNames) { @Transactional public void updateInterestedCountry(SiteUser siteUser, List koreanNames) { - interestedCountryRepository.deleteBySiteUser(siteUser); + interestedCountryRepository.deleteBySiteUserId(siteUser.getId()); List interestedCountries = countryRepository.findAllByKoreanNameIn(koreanNames) .stream() diff --git a/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java b/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java index b2bb5a1ed..419097214 100644 --- a/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java +++ b/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java @@ -1,7 +1,6 @@ package com.example.solidconnection.location.region.repository; import com.example.solidconnection.location.region.domain.InterestedRegion; -import com.example.solidconnection.siteuser.domain.SiteUser; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; @@ -11,5 +10,5 @@ public interface InterestedRegionRepository extends JpaRepository findAllBySiteUserId(long siteUserId); @Modifying - void deleteBySiteUser(SiteUser siteUser); + void deleteBySiteUserId(long siteUserId); } diff --git a/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java b/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java index 086f844c1..7b6b86e35 100644 --- a/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java +++ b/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java @@ -27,7 +27,7 @@ public void saveInterestedRegion(SiteUser siteUser, List koreanNames) { @Transactional public void updateInterestedRegion(SiteUser siteUser, List koreanNames) { - interestedRegionRepository.deleteBySiteUser(siteUser); + interestedRegionRepository.deleteBySiteUserId(siteUser.getId()); List interestedRegions = regionRepository.findAllByKoreanNameIn(koreanNames) .stream() From 81a0b5db68e45e4cdd46f20aac4213cb52c3a7fd Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Thu, 14 Aug 2025 14:18:45 +0900 Subject: [PATCH 05/14] =?UTF-8?q?test:=20=EA=B4=80=EC=8B=AC=20=EC=A7=80?= =?UTF-8?q?=EC=97=AD=20=EB=B0=8F=20=EA=B5=AD=EA=B0=80=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../siteuser/service/MyPageServiceTest.java | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java b/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java index f470e9cfc..e21b750ab 100644 --- a/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java +++ b/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java @@ -15,12 +15,23 @@ import static org.mockito.BDDMockito.then; import com.example.solidconnection.common.exception.CustomException; +import com.example.solidconnection.location.country.domain.Country; +import com.example.solidconnection.location.country.domain.InterestedCountry; +import com.example.solidconnection.location.country.fixture.CountryFixture; +import com.example.solidconnection.location.country.repository.CountryRepository; +import com.example.solidconnection.location.country.repository.InterestedCountryRepository; +import com.example.solidconnection.location.region.domain.InterestedRegion; +import com.example.solidconnection.location.region.domain.Region; +import com.example.solidconnection.location.region.fixture.RegionFixture; +import com.example.solidconnection.location.region.repository.InterestedRegionRepository; +import com.example.solidconnection.location.region.repository.RegionRepository; import com.example.solidconnection.s3.domain.ImgType; import com.example.solidconnection.s3.dto.UploadedFileUrlResponse; import com.example.solidconnection.s3.service.S3Service; import com.example.solidconnection.siteuser.domain.AuthType; import com.example.solidconnection.siteuser.domain.Role; import com.example.solidconnection.siteuser.domain.SiteUser; +import com.example.solidconnection.siteuser.dto.LocationUpdateRequest; import com.example.solidconnection.siteuser.dto.MyPageResponse; import com.example.solidconnection.siteuser.dto.PasswordUpdateRequest; import com.example.solidconnection.siteuser.fixture.SiteUserFixture; @@ -31,6 +42,7 @@ import com.example.solidconnection.university.fixture.UnivApplyInfoFixture; import com.example.solidconnection.university.repository.LikedUnivApplyInfoRepository; import java.time.LocalDateTime; +import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -56,12 +68,30 @@ class MyPageServiceTest { @Autowired private LikedUnivApplyInfoRepository likedUnivApplyInfoRepository; + @Autowired + private InterestedCountryRepository interestedCountryRepository; + + @Autowired + private InterestedRegionRepository interestedRegionRepository; + + @Autowired + private CountryRepository countryRepository; + + @Autowired + private RegionRepository regionRepository; + @Autowired private SiteUserFixture siteUserFixture; @Autowired private UnivApplyInfoFixture univApplyInfoFixture; + @Autowired + private CountryFixture countryFixture; + + @Autowired + private RegionFixture regionFixture; + @Autowired private SiteUserFixtureBuilder siteUserFixtureBuilder; @@ -227,6 +257,100 @@ void setUp() { } } + @Nested + class 관심_지역_및_국가_변경_테스트 { + + private Country 미국; + private Country 캐나다; + private Country 일본; + private Region 영미권; + private Region 아시아; + + @BeforeEach + void setUp() { + 미국 = countryFixture.미국(); + 캐나다 = countryFixture.캐나다(); + 일본 = countryFixture.일본(); + 영미권 = regionFixture.영미권(); + 아시아 = regionFixture.아시아(); + + countryRepository.saveAll(List.of(미국, 캐나다, 일본)); + regionRepository.saveAll(List.of(영미권, 아시아)); + } + + @Test + void 관심_지역과_국가를_성공적으로_수정한다() { + // given + interestedCountryRepository.save(new InterestedCountry(user, 미국)); + interestedRegionRepository.save(new InterestedRegion(user, 영미권)); + + List newCountries = List.of(캐나다.getKoreanName(), 일본.getKoreanName()); + List newRegions = List.of(아시아.getKoreanName()); + LocationUpdateRequest request = new LocationUpdateRequest(newCountries, newRegions); + + // when + myPageService.updateLocation(user.getId(), request); + + // then + List updatedCountries = interestedCountryRepository.findAllBySiteUserId(user.getId()); + List updatedRegions = interestedRegionRepository.findAllBySiteUserId(user.getId()); + + assertAll( + () -> assertThat(updatedCountries).hasSize(2) + .extracting(InterestedCountry::getCountryCode) + .containsExactlyInAnyOrder(캐나다.getCode(), 일본.getCode()), + () -> assertThat(updatedRegions).hasSize(1) + .extracting(InterestedRegion::getRegionCode) + .containsExactly(아시아.getCode()) + ); + } + + @Test + void 기존에_관심_지역과_국가가_없어도_성공적으로_추가된다() { + // given + List newCountries = List.of(미국.getKoreanName()); + List newRegions = List.of(영미권.getKoreanName()); + LocationUpdateRequest request = new LocationUpdateRequest(newCountries, newRegions); + + // when + myPageService.updateLocation(user.getId(), request); + + // then + List updatedCountries = interestedCountryRepository.findAllBySiteUserId(user.getId()); + List updatedRegions = interestedRegionRepository.findAllBySiteUserId(user.getId()); + + assertAll( + () -> assertThat(updatedCountries).hasSize(1) + .extracting(InterestedCountry::getCountryCode) + .containsExactly(미국.getCode()), + () -> assertThat(updatedRegions).hasSize(1) + .extracting(InterestedRegion::getRegionCode) + .containsExactly(영미권.getCode()) + ); + } + + @Test + void 빈_리스트를_전달하면_모든_관심_지역과_국가가_삭제된다() { + // given + interestedCountryRepository.save(new InterestedCountry(user, 미국)); + interestedRegionRepository.save(new InterestedRegion(user, 영미권)); + + LocationUpdateRequest request = new LocationUpdateRequest(List.of(), List.of()); + + // when + myPageService.updateLocation(user.getId(), request); + + // then + List updatedCountries = interestedCountryRepository.findAllBySiteUserId(user.getId()); + List updatedRegions = interestedRegionRepository.findAllBySiteUserId(user.getId()); + + assertAll( + () -> assertThat(updatedCountries).isEmpty(), + () -> assertThat(updatedRegions).isEmpty() + ); + } + } + private int createLikedUnivApplyInfos(SiteUser testUser) { LikedUnivApplyInfo likedUnivApplyInfo1 = new LikedUnivApplyInfo(null, univApplyInfoFixture.괌대학_A_지원_정보().getId(), testUser.getId()); LikedUnivApplyInfo likedUnivApplyInfo2 = new LikedUnivApplyInfo(null, univApplyInfoFixture.메이지대학_지원_정보().getId(), testUser.getId()); From cda48f1d03f276219fea48a8887a58dd44241edd Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Thu, 14 Aug 2025 14:30:06 +0900 Subject: [PATCH 06/14] =?UTF-8?q?fix:=20clearAutomatically,=20flushAutomat?= =?UTF-8?q?ically=20=EC=98=B5=EC=85=98=EC=9D=84=20=ED=86=B5=ED=95=B4=20DB?= =?UTF-8?q?=EC=99=80=20=EC=98=81=EC=86=8D=EC=84=B1=20=EC=BB=A8=ED=85=8D?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EA=B0=84=20=EB=B6=88=EC=9D=BC=EC=B9=98=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../country/repository/InterestedCountryRepository.java | 2 +- .../location/region/repository/InterestedRegionRepository.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java b/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java index b8c6d4f0d..d6b900fa4 100644 --- a/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java +++ b/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java @@ -9,6 +9,6 @@ public interface InterestedCountryRepository extends JpaRepository findAllBySiteUserId(long siteUserId); - @Modifying + @Modifying(clearAutomatically = true, flushAutomatically = true) void deleteBySiteUserId(long siteUserId); } diff --git a/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java b/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java index 419097214..c2c477566 100644 --- a/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java +++ b/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java @@ -9,6 +9,6 @@ public interface InterestedRegionRepository extends JpaRepository findAllBySiteUserId(long siteUserId); - @Modifying + @Modifying(clearAutomatically = true, flushAutomatically = true) void deleteBySiteUserId(long siteUserId); } From acc0a0a7bd09eff5773b45835393cc01ba58067a Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Thu, 14 Aug 2025 19:07:38 +0900 Subject: [PATCH 07/14] =?UTF-8?q?fix:=20=ED=8C=8C=EB=9D=BC=EB=AF=B8?= =?UTF-8?q?=ED=84=B0=20=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solidconnection/siteuser/service/MyPageServiceTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java b/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java index e21b750ab..fbc52620f 100644 --- a/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java +++ b/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java @@ -286,7 +286,7 @@ void setUp() { List newCountries = List.of(캐나다.getKoreanName(), 일본.getKoreanName()); List newRegions = List.of(아시아.getKoreanName()); - LocationUpdateRequest request = new LocationUpdateRequest(newCountries, newRegions); + LocationUpdateRequest request = new LocationUpdateRequest(newRegions, newCountries); // when myPageService.updateLocation(user.getId(), request); @@ -310,7 +310,7 @@ void setUp() { // given List newCountries = List.of(미국.getKoreanName()); List newRegions = List.of(영미권.getKoreanName()); - LocationUpdateRequest request = new LocationUpdateRequest(newCountries, newRegions); + LocationUpdateRequest request = new LocationUpdateRequest(newRegions, newCountries); // when myPageService.updateLocation(user.getId(), request); From 1c18a5d2991c9570870e12762596649c72ad7209 Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Thu, 14 Aug 2025 22:54:05 +0900 Subject: [PATCH 08/14] =?UTF-8?q?chore:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20Modifying=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EC=85=98=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../country/repository/InterestedCountryRepository.java | 2 -- .../location/region/repository/InterestedRegionRepository.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java b/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java index d6b900fa4..95e0a4fd4 100644 --- a/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java +++ b/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java @@ -3,12 +3,10 @@ import com.example.solidconnection.location.country.domain.InterestedCountry; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; public interface InterestedCountryRepository extends JpaRepository { List findAllBySiteUserId(long siteUserId); - @Modifying(clearAutomatically = true, flushAutomatically = true) void deleteBySiteUserId(long siteUserId); } diff --git a/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java b/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java index c2c477566..a35fc2b13 100644 --- a/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java +++ b/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java @@ -3,12 +3,10 @@ import com.example.solidconnection.location.region.domain.InterestedRegion; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; public interface InterestedRegionRepository extends JpaRepository { List findAllBySiteUserId(long siteUserId); - @Modifying(clearAutomatically = true, flushAutomatically = true) void deleteBySiteUserId(long siteUserId); } From 21aac65d637c9be7fbd9088aee47f354e2895f4b Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Fri, 15 Aug 2025 16:45:35 +0900 Subject: [PATCH 09/14] =?UTF-8?q?chore:=20=EB=8B=A4=EA=B1=B4=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=EB=8A=94=20deleteBy=20=EB=8C=80=EC=8B=A0=20deleteAllB?= =?UTF-8?q?y=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../country/repository/InterestedCountryRepository.java | 2 +- .../location/country/service/InterestedCountryService.java | 2 +- .../location/region/repository/InterestedRegionRepository.java | 2 +- .../location/region/service/InterestedRegionService.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java b/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java index 95e0a4fd4..b7e12a285 100644 --- a/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java +++ b/src/main/java/com/example/solidconnection/location/country/repository/InterestedCountryRepository.java @@ -8,5 +8,5 @@ public interface InterestedCountryRepository extends JpaRepository findAllBySiteUserId(long siteUserId); - void deleteBySiteUserId(long siteUserId); + void deleteAllBySiteUserId(long siteUserId); } diff --git a/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java b/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java index f1abc0f99..9e2fa4060 100644 --- a/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java +++ b/src/main/java/com/example/solidconnection/location/country/service/InterestedCountryService.java @@ -27,7 +27,7 @@ public void saveInterestedCountry(SiteUser siteUser, List koreanNames) { @Transactional public void updateInterestedCountry(SiteUser siteUser, List koreanNames) { - interestedCountryRepository.deleteBySiteUserId(siteUser.getId()); + interestedCountryRepository.deleteAllBySiteUserId(siteUser.getId()); List interestedCountries = countryRepository.findAllByKoreanNameIn(koreanNames) .stream() diff --git a/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java b/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java index a35fc2b13..367eb2164 100644 --- a/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java +++ b/src/main/java/com/example/solidconnection/location/region/repository/InterestedRegionRepository.java @@ -8,5 +8,5 @@ public interface InterestedRegionRepository extends JpaRepository findAllBySiteUserId(long siteUserId); - void deleteBySiteUserId(long siteUserId); + void deleteAllBySiteUserId(long siteUserId); } diff --git a/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java b/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java index 7b6b86e35..2c8c592cd 100644 --- a/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java +++ b/src/main/java/com/example/solidconnection/location/region/service/InterestedRegionService.java @@ -27,7 +27,7 @@ public void saveInterestedRegion(SiteUser siteUser, List koreanNames) { @Transactional public void updateInterestedRegion(SiteUser siteUser, List koreanNames) { - interestedRegionRepository.deleteBySiteUserId(siteUser.getId()); + interestedRegionRepository.deleteAllBySiteUserId(siteUser.getId()); List interestedRegions = regionRepository.findAllByKoreanNameIn(koreanNames) .stream() From 5ed701f783ca6624126634bbed714ebefbfd0111 Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Fri, 15 Aug 2025 16:46:54 +0900 Subject: [PATCH 10/14] =?UTF-8?q?chore:=20DTO=EC=97=90=20Valid=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solidconnection/siteuser/controller/MyPageController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java b/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java index bf1375821..17ad89cf6 100644 --- a/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java +++ b/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java @@ -54,7 +54,7 @@ public ResponseEntity updatePassword( @PatchMapping("/location") public ResponseEntity updateLocation( @AuthorizedUser long siteUserId, - @RequestBody LocationUpdateRequest request + @RequestBody @Valid LocationUpdateRequest request ) { myPageService.updateLocation(siteUserId, request); return ResponseEntity.ok().build(); From 91d99bdf6acf293bd3dfc5644ecc7bf240357766 Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Fri, 15 Aug 2025 17:01:35 +0900 Subject: [PATCH 11/14] =?UTF-8?q?chore:=20=ED=81=AC=EA=B8=B0=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EB=AF=B8=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20repository=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../siteuser/service/MyPageServiceTest.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java b/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java index fbc52620f..f484686ac 100644 --- a/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java +++ b/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java @@ -18,13 +18,11 @@ import com.example.solidconnection.location.country.domain.Country; import com.example.solidconnection.location.country.domain.InterestedCountry; import com.example.solidconnection.location.country.fixture.CountryFixture; -import com.example.solidconnection.location.country.repository.CountryRepository; import com.example.solidconnection.location.country.repository.InterestedCountryRepository; import com.example.solidconnection.location.region.domain.InterestedRegion; import com.example.solidconnection.location.region.domain.Region; import com.example.solidconnection.location.region.fixture.RegionFixture; import com.example.solidconnection.location.region.repository.InterestedRegionRepository; -import com.example.solidconnection.location.region.repository.RegionRepository; import com.example.solidconnection.s3.domain.ImgType; import com.example.solidconnection.s3.dto.UploadedFileUrlResponse; import com.example.solidconnection.s3.service.S3Service; @@ -74,12 +72,6 @@ class MyPageServiceTest { @Autowired private InterestedRegionRepository interestedRegionRepository; - @Autowired - private CountryRepository countryRepository; - - @Autowired - private RegionRepository regionRepository; - @Autowired private SiteUserFixture siteUserFixture; @@ -273,9 +265,6 @@ void setUp() { 일본 = countryFixture.일본(); 영미권 = regionFixture.영미권(); 아시아 = regionFixture.아시아(); - - countryRepository.saveAll(List.of(미국, 캐나다, 일본)); - regionRepository.saveAll(List.of(영미권, 아시아)); } @Test @@ -296,10 +285,10 @@ void setUp() { List updatedRegions = interestedRegionRepository.findAllBySiteUserId(user.getId()); assertAll( - () -> assertThat(updatedCountries).hasSize(2) + () -> assertThat(updatedCountries) .extracting(InterestedCountry::getCountryCode) .containsExactlyInAnyOrder(캐나다.getCode(), 일본.getCode()), - () -> assertThat(updatedRegions).hasSize(1) + () -> assertThat(updatedRegions) .extracting(InterestedRegion::getRegionCode) .containsExactly(아시아.getCode()) ); @@ -320,10 +309,10 @@ void setUp() { List updatedRegions = interestedRegionRepository.findAllBySiteUserId(user.getId()); assertAll( - () -> assertThat(updatedCountries).hasSize(1) + () -> assertThat(updatedCountries) .extracting(InterestedCountry::getCountryCode) .containsExactly(미국.getCode()), - () -> assertThat(updatedRegions).hasSize(1) + () -> assertThat(updatedRegions) .extracting(InterestedRegion::getRegionCode) .containsExactly(영미권.getCode()) ); From 90272f90ff09790a0a6519423e5ca94576a8c969 Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Fri, 15 Aug 2025 17:02:34 +0900 Subject: [PATCH 12/14] =?UTF-8?q?chore:=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8F=AC=EB=A7=A4=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solidconnection/siteuser/controller/MyPageController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java b/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java index 17ad89cf6..4c2024b65 100644 --- a/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java +++ b/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java @@ -55,7 +55,7 @@ public ResponseEntity updatePassword( public ResponseEntity updateLocation( @AuthorizedUser long siteUserId, @RequestBody @Valid LocationUpdateRequest request - ) { + ) { myPageService.updateLocation(siteUserId, request); return ResponseEntity.ok().build(); } From 6abb108cd351f7951e5decbe5a72eccd4fd6988a Mon Sep 17 00:00:00 2001 From: seonghyeok cho <65901319+whqtker@users.noreply.github.com> Date: Mon, 18 Aug 2025 21:11:11 +0900 Subject: [PATCH 13/14] =?UTF-8?q?fix:=20conflict=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../siteuser/service/MyPageServiceTest.java | 51 +++---------------- 1 file changed, 6 insertions(+), 45 deletions(-) diff --git a/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java b/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java index a819258d2..d8e5c950f 100644 --- a/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java +++ b/src/test/java/com/example/solidconnection/siteuser/service/MyPageServiceTest.java @@ -1,10 +1,13 @@ package com.example.solidconnection.siteuser.service; import static com.example.solidconnection.common.exception.ErrorCode.CAN_NOT_CHANGE_NICKNAME_YET; +import static com.example.solidconnection.common.exception.ErrorCode.PASSWORD_MISMATCH; import static com.example.solidconnection.siteuser.service.MyPageService.MIN_DAYS_BETWEEN_NICKNAME_CHANGES; import static com.example.solidconnection.siteuser.service.MyPageService.NICKNAME_LAST_CHANGE_DATE_FORMAT; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode; +import static org.junit.jupiter.api.Assertions.assertAll; import static org.mockito.BDDMockito.any; import static org.mockito.BDDMockito.eq; import static org.mockito.BDDMockito.given; @@ -29,6 +32,7 @@ import com.example.solidconnection.siteuser.domain.SiteUser; import com.example.solidconnection.siteuser.dto.LocationUpdateRequest; import com.example.solidconnection.siteuser.dto.MyPageResponse; +import com.example.solidconnection.siteuser.dto.PasswordUpdateRequest; import com.example.solidconnection.siteuser.fixture.SiteUserFixture; import com.example.solidconnection.siteuser.fixture.SiteUserFixtureBuilder; import com.example.solidconnection.siteuser.repository.SiteUserRepository; @@ -39,7 +43,6 @@ import com.example.solidconnection.university.repository.LikedUnivApplyInfoRepository; import java.time.LocalDateTime; import java.util.List; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -83,9 +86,6 @@ class MyPageServiceTest { @Autowired private UnivApplyInfoFixture univApplyInfoFixture; - @Autowired - private CountryFixture countryFixture; - @Autowired private RegionFixture regionFixture; @@ -114,7 +114,7 @@ void setUp() { MyPageResponse response = myPageService.getMyPageInfo(user.getId()); // then - Assertions.assertAll( + assertAll( () -> assertThat(response.nickname()).isEqualTo(user.getNickname()), () -> assertThat(response.profileImageUrl()).isEqualTo(user.getProfileImageUrl()), () -> assertThat(response.role()).isEqualTo(user.getRole()), @@ -139,7 +139,7 @@ void setUp() { MyPageResponse response = myPageService.getMyPageInfo(mentorUser.getId()); // then - Assertions.assertAll( + assertAll( () -> assertThat(response.nickname()).isEqualTo(mentorUser.getNickname()), () -> assertThat(response.profileImageUrl()).isEqualTo(mentorUser.getProfileImageUrl()), () -> assertThat(response.role()).isEqualTo(mentorUser.getRole()), @@ -413,43 +413,4 @@ void setUp() { ); } } - - private int createLikedUnivApplyInfos(SiteUser testUser) { - LikedUnivApplyInfo likedUnivApplyInfo1 = new LikedUnivApplyInfo(null, univApplyInfoFixture.괌대학_A_지원_정보().getId(), testUser.getId()); - LikedUnivApplyInfo likedUnivApplyInfo2 = new LikedUnivApplyInfo(null, univApplyInfoFixture.메이지대학_지원_정보().getId(), testUser.getId()); - LikedUnivApplyInfo likedUnivApplyInfo3 = new LikedUnivApplyInfo(null, univApplyInfoFixture.코펜하겐IT대학_지원_정보().getId(), testUser.getId()); - - likedUnivApplyInfoRepository.save(likedUnivApplyInfo1); - likedUnivApplyInfoRepository.save(likedUnivApplyInfo2); - likedUnivApplyInfoRepository.save(likedUnivApplyInfo3); - return likedUnivApplyInfoRepository.countBySiteUserId(testUser.getId()); - } - - private MockMultipartFile createValidImageFile() { - return new MockMultipartFile( - "image", - "test.jpg", - "image/jpeg", - "test image content".getBytes() - ); - } - - private String createExpectedErrorMessage(LocalDateTime modifiedAt) { - String formatLastModifiedAt = String.format( - "(마지막 수정 시간 : %s)", - NICKNAME_LAST_CHANGE_DATE_FORMAT.format(modifiedAt) - ); - return CAN_NOT_CHANGE_NICKNAME_YET.getMessage() + " : " + formatLastModifiedAt; - } - - private SiteUser createSiteUserWithCustomProfile() { - return siteUserFixtureBuilder.siteUser() - .email("customProfile@example.com") - .authType(AuthType.EMAIL) - .nickname("커스텀프로필") - .profileImageUrl("profile/profileImageUrl") - .role(Role.MENTEE) - .password("customPassword123") - .create(); - } } From 2d2510ea52ad0ba5b6ba06362d19cdc9394c85ff Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Mon, 18 Aug 2025 21:24:10 +0900 Subject: [PATCH 14/14] =?UTF-8?q?refactor:=20=EB=B6=84=EB=AA=85=ED=95=9C?= =?UTF-8?q?=20=EC=9D=98=EB=AF=B8=EB=A5=BC=20=EA=B0=80=EC=A7=84=20=EC=97=94?= =?UTF-8?q?=EB=93=9C=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /location -> /interested-location --- .../solidconnection/siteuser/controller/MyPageController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java b/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java index 4c2024b65..00c3077e3 100644 --- a/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java +++ b/src/main/java/com/example/solidconnection/siteuser/controller/MyPageController.java @@ -51,7 +51,7 @@ public ResponseEntity updatePassword( return ResponseEntity.ok().build(); } - @PatchMapping("/location") + @PatchMapping("/interested-location") public ResponseEntity updateLocation( @AuthorizedUser long siteUserId, @RequestBody @Valid LocationUpdateRequest request