From 4f4c09b7d5eeb14fc6d909dad78b6dfb336b189c Mon Sep 17 00:00:00 2001 From: YoungJun-L Date: Tue, 21 Nov 2023 10:42:34 +0900 Subject: [PATCH] [LH-199] Fix matching api --- build.gradle | 1 + .../lingoswap/auth/config/LoggingFilter.java | 15 +-------------- .../lingoswap/auth/config/SecurityConfig.java | 2 +- .../match/presentation/MatchController.java | 6 +++--- .../member/application/MemberManager.java | 2 +- .../repository/PreferredCountryRepository.java | 8 ++++++-- src/main/resources/security | 2 +- .../PreferredCountryRepositoryTest.java | 2 +- 8 files changed, 15 insertions(+), 23 deletions(-) diff --git a/build.gradle b/build.gradle index 5ec02e0..b15b269 100755 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-webflux' implementation 'org.springframework.boot:spring-boot-starter-batch' implementation 'io.netty:netty-resolver-dns-native-macos:4.1.72.Final:osx-aarch_64' + implementation 'io.micrometer:micrometer-registry-prometheus' implementation('com.amazonaws:aws-java-sdk-s3:1.12.527') { exclude group: 'commons-logging', module: 'commons-logging' diff --git a/src/main/java/com/lighthouse/lingoswap/auth/config/LoggingFilter.java b/src/main/java/com/lighthouse/lingoswap/auth/config/LoggingFilter.java index d2232d6..d143d78 100644 --- a/src/main/java/com/lighthouse/lingoswap/auth/config/LoggingFilter.java +++ b/src/main/java/com/lighthouse/lingoswap/auth/config/LoggingFilter.java @@ -17,20 +17,7 @@ @RequiredArgsConstructor @Component public class LoggingFilter extends OncePerRequestFilter { - - /** - * servletPath:/api/v1/user/form/interests - *

- * After request [GET /api/v1/user/form/country, client=0:0:0:0:0:0:0:1, headers=[user-agent:"PostmanRuntime/7.35.0", accept:"*{@literal /}*", host:"localhost:8080", accept-encoding:"gzip, deflate, br", connection:"keep-alive"]] - *

- * pathInfo:null - *

- * headers: - *

- * user-agent: PostmanRuntime/7.35.0 - *

- * host - */ + @Override protected void doFilterInternal(@NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response, diff --git a/src/main/java/com/lighthouse/lingoswap/auth/config/SecurityConfig.java b/src/main/java/com/lighthouse/lingoswap/auth/config/SecurityConfig.java index 10a4a48..faa3ef2 100644 --- a/src/main/java/com/lighthouse/lingoswap/auth/config/SecurityConfig.java +++ b/src/main/java/com/lighthouse/lingoswap/auth/config/SecurityConfig.java @@ -31,7 +31,7 @@ SecurityFilterChain securityFilterChain(final HttpSecurity http) throws Exceptio .authorizeHttpRequests() .requestMatchers("/api/v1/admin/**").hasAuthority("ADMIN") .requestMatchers(HttpMethod.POST, "/api/v1/auth/**", "/api/v1/user/upload/**").permitAll() - .requestMatchers(HttpMethod.GET, "/api/v1/user/form/**", "/actuator/health").permitAll() + .requestMatchers(HttpMethod.GET, "/api/v1/user/form/**", "/actuator/**").permitAll() .requestMatchers(HttpMethod.GET, "/.well-known/**").permitAll() .requestMatchers("/swagger-ui/**", "/v3/api-docs/**").permitAll() .anyRequest().authenticated() diff --git a/src/main/java/com/lighthouse/lingoswap/match/presentation/MatchController.java b/src/main/java/com/lighthouse/lingoswap/match/presentation/MatchController.java index 911e970..be89e14 100644 --- a/src/main/java/com/lighthouse/lingoswap/match/presentation/MatchController.java +++ b/src/main/java/com/lighthouse/lingoswap/match/presentation/MatchController.java @@ -16,12 +16,12 @@ public class MatchController { @GetMapping("/{uuid}/matches") public ResponseEntity> get(@PathVariable final String uuid, - @RequestParam(required = false) final Long nextId, + @RequestParam(required = false) final Long next, @RequestParam(defaultValue = "10") final int pageSize) { - if (nextId == null) { + if (next == null) { matchManager.replaceWithNewMatchedMember(uuid); } - return ResponseEntity.ok(ResponseDto.success(matchManager.read(uuid, nextId, pageSize))); + return ResponseEntity.ok(ResponseDto.success(matchManager.read(uuid, next, pageSize))); } } diff --git a/src/main/java/com/lighthouse/lingoswap/member/application/MemberManager.java b/src/main/java/com/lighthouse/lingoswap/member/application/MemberManager.java index f853e87..dea54f1 100644 --- a/src/main/java/com/lighthouse/lingoswap/member/application/MemberManager.java +++ b/src/main/java/com/lighthouse/lingoswap/member/application/MemberManager.java @@ -117,7 +117,7 @@ private void updatePreferredCountries(final Member member, final List pr } if (!deletedCountryCodes.isEmpty()) { - preferredCountryRepository.deleteAllByCountryIn(countryRepository.findAllByCodeIn(deletedCountryCodes)); + preferredCountryRepository.deleteAllByCountryIn(member, countryRepository.findAllByCodeIn(deletedCountryCodes)); } } diff --git a/src/main/java/com/lighthouse/lingoswap/preferredcountry/domain/repository/PreferredCountryRepository.java b/src/main/java/com/lighthouse/lingoswap/preferredcountry/domain/repository/PreferredCountryRepository.java index e2999c6..95f3a00 100644 --- a/src/main/java/com/lighthouse/lingoswap/preferredcountry/domain/repository/PreferredCountryRepository.java +++ b/src/main/java/com/lighthouse/lingoswap/preferredcountry/domain/repository/PreferredCountryRepository.java @@ -18,7 +18,11 @@ public interface PreferredCountryRepository extends JpaRepository countries); + @Query("DELETE FROM PreferredCountry p WHERE p.member.member = :member AND p.country.country IN :countries") + void deleteAllByCountryIn(@Param("member") final Member member, @Param("countries") final List countries); + + @Modifying + @Query("DELETE FROM PreferredCountry p WHERE p.member.member = :member") + void deleteAllByMember(@Param("member") final Member member); } diff --git a/src/main/resources/security b/src/main/resources/security index 3cca23c..9afb210 160000 --- a/src/main/resources/security +++ b/src/main/resources/security @@ -1 +1 @@ -Subproject commit 3cca23c47f0b03fed23f7e9fec0c49211efb799e +Subproject commit 9afb210eaa084915f4bf51f76b75303ff5fc497d diff --git a/src/test/java/com/lighthouse/lingoswap/preferredcountry/domain/repository/PreferredCountryRepositoryTest.java b/src/test/java/com/lighthouse/lingoswap/preferredcountry/domain/repository/PreferredCountryRepositoryTest.java index 856d5df..2c71e6a 100644 --- a/src/test/java/com/lighthouse/lingoswap/preferredcountry/domain/repository/PreferredCountryRepositoryTest.java +++ b/src/test/java/com/lighthouse/lingoswap/preferredcountry/domain/repository/PreferredCountryRepositoryTest.java @@ -72,7 +72,7 @@ void deleteAllByCountryIn() { preferredCountryRepository.saveAll(List.of(preferredKorea, preferredUs)); // when - preferredCountryRepository.deleteAllByCountryIn(List.of(korea, us)); + preferredCountryRepository.deleteAllByCountryIn(member, List.of(korea, us)); // then List actual = preferredCountryRepository.findAllByMember(member);