Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

반경 내 주차장 조회 기능 구현 #13

Merged
merged 44 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f44658b
feat: jsonProperty 설정
youngh0 Feb 3, 2024
43ca5c9
feat: hibernate 공간 데이터 의존성 추가
youngh0 Feb 3, 2024
85f7423
feat: Location 의 필드를 공간데이터 타입 Point 로 수정
youngh0 Feb 3, 2024
7674fc9
feat: querydsl 의존성 추가
youngh0 Feb 5, 2024
c1fa2c3
feat: querydsl 의존성 제거
youngh0 Feb 6, 2024
ba3c449
feat: 주차장 목록 조회 쿼리 파라미터 전용 argument resolver 구현
youngh0 Feb 6, 2024
97ce588
feat: 반경 내 주차장 조회 쿼리 작성
youngh0 Feb 6, 2024
c4fad88
feat: argument resolver 등록
youngh0 Feb 6, 2024
0372e0d
feat: 반경 내 주차장 조회 controller, service(정렬, 필터링) 구현
youngh0 Feb 6, 2024
d399ab5
feat: builder 추가
youngh0 Feb 6, 2024
3469889
feat: 필터 기능하는 ParkingDomainService 추가
youngh0 Feb 6, 2024
7f49f6d
feat: 사용하지 않는 코드 제거
youngh0 Feb 6, 2024
6288499
feat: conflict 해결
youngh0 Mar 12, 2024
35a5747
Merge remote-tracking branch 'origin/main' into feat/10-find-parkingLots
youngh0 Mar 13, 2024
2d059a8
feat: 사용하지 않는 repository 삭제
youngh0 Mar 13, 2024
592b1c7
feat: 요금 계산 bean 추가
youngh0 Mar 13, 2024
f8b4dbd
feat: 주차장 목록 조회 시 사용자 조회 조건 필터링 구현
youngh0 Mar 13, 2024
d33ee40
feat: 메서드 분리
youngh0 Mar 13, 2024
44ae717
feat: 주차장 도보 예상 시간 로직 테스트 작성
youngh0 Mar 13, 2024
28ce548
refactor: 주석 제거
youngh0 Mar 13, 2024
6b7459f
feat: 주차장 목록 조회 시 조회 조건 엔티티로 대체 가능한 query param 제거
youngh0 Mar 13, 2024
d5ca66d
feat: 주차장 검색 조건 request 생성
youngh0 Mar 21, 2024
4c780fc
feat: 검색 조건 변환 기능 구현
youngh0 Mar 21, 2024
5f608cc
feat: 반경조회 비회원 조회 구현
youngh0 Mar 22, 2024
d008f2e
feat: memberId 아규먼트 리졸버 구현
youngh0 Mar 22, 2024
0035310
feat: feeType 타입 변경
youngh0 Mar 22, 2024
227cf26
feat: enum 의 value list 변환 로직 SearchConditionAvailable 로 이동
youngh0 Mar 27, 2024
a4dc6a1
feat: String 과 일치하는 enum List 변환 로직 SearchConditionAvailable 로 이동
youngh0 Mar 27, 2024
84b1100
feat: find 메서드 구현
youngh0 Mar 27, 2024
2973615
feat: 무료인지 확인하는 메서드 구현
youngh0 Mar 27, 2024
9d03477
feat: 검색조건 유.무료에 맞는 필터링 기능 구현
youngh0 Mar 27, 2024
1f31077
refactor: ParkingDomainService -> ParkingApplicationService 네이밍 변경
youngh0 Mar 27, 2024
6c04212
test: 유.무료 필터링 테스트
youngh0 Mar 27, 2024
b35c425
refactor: 네이밍 수정
youngh0 Mar 27, 2024
f1fa25b
feat: 비회원 기능 회원 인증 시 sessionId null 반환하도록 수정
youngh0 Mar 28, 2024
3b9d046
feat: 불필요한 메서드 제거
youngh0 Mar 28, 2024
9d5693e
Merge remote-tracking branch 'origin/main' into feat/10-find-parkingLots
youngh0 Mar 29, 2024
dfac844
feat: 충돌 해결
youngh0 Mar 29, 2024
4528710
feat: swagger 추가
youngh0 Mar 29, 2024
5362f5d
refactor: 서비스 계층에서 String <-> SearchConditionAvailable Enum 변환 로직 개선
This2sho Apr 1, 2024
03dcdd3
fix: 잘못 사용되고 있는 값 객체 제거
This2sho Apr 1, 2024
fc15e7e
feat: 응답 dto 변환 로직 이동
youngh0 Apr 1, 2024
7b48ca1
refactor: 네이밍 수정
youngh0 Apr 1, 2024
4fe6e61
feat: 현재 시간 변수 생성 위치 수정
youngh0 Apr 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
@Getter
public class ParkingQueryRequest {

private final String priority;
private final Double latitude;
private final Double longitude;
private final Integer radius;

public ParkingQueryRequest(String priority, Double latitude, Double longitude, Integer radius) {
this.priority = priority;
public ParkingQueryRequest(Double latitude, Double longitude, Integer radius) {
this.latitude = latitude;
this.longitude = longitude;
this.radius = radius;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.example.parking.application.parking.dto;

import com.example.parking.domain.parking.OperationType;
import com.example.parking.domain.parking.ParkingType;
import com.example.parking.domain.parking.PayType;
import com.example.parking.domain.searchcondition.FeeType;
import java.util.List;

public class ParkingSearchConditionRequest {

private static final ParkingSearchConditionRequest BASE = new ParkingSearchConditionRequest(
OperationType.getAllValues(),
ParkingType.getAllValues(),
FeeType.getAllValues(),
PayType.getAllValues(),
1
);

private final List<String> operationTypes;
private final List<String> parkingTypes;
private final List<String> feeTypes;
private final List<String> payTypes;
private final int hours;

public ParkingSearchConditionRequest(List<String> operationTypes, List<String> parkingTypes, List<String> feeTypes,
List<String> payTypes, int hours) {
this.operationTypes = operationTypes;
this.parkingTypes = parkingTypes;
this.feeTypes = feeTypes;
this.payTypes = payTypes;
this.hours = hours;
}

public static ParkingSearchConditionRequest base() {
return BASE;
}
}
6 changes: 5 additions & 1 deletion src/main/java/com/example/parking/config/WebMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.example.parking.config.argumentresolver.AuthArgumentResolver;
import com.example.parking.config.argumentresolver.parking.ParkingQueryArgumentResolver;
import com.example.parking.config.argumentresolver.parking.ParkingSearchConditionArgumentResolver;
import com.example.parking.external.config.interceptor.AuthInterceptor;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand All @@ -17,20 +18,23 @@ public class WebMvcConfig implements WebMvcConfigurer {
private final AuthInterceptor authInterceptor;
private final AuthArgumentResolver authArgumentResolver;
private final ParkingQueryArgumentResolver parkingQueryArgumentResolver;
private final ParkingSearchConditionArgumentResolver parkingSearchConditionArgumentResolver;

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(authInterceptor)
.addPathPatterns("/**")
.excludePathPatterns(List.of(
"/users",
"/login"
"/login",
"/parkings"
));
}

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(authArgumentResolver);
resolvers.add(parkingQueryArgumentResolver);
resolvers.add(parkingSearchConditionArgumentResolver);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public boolean supportsParameter(MethodParameter parameter) {
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {
return new ParkingQueryRequest(
webRequest.getParameter("priority"),
Double.valueOf(webRequest.getParameter("latitude")),
Double.valueOf(webRequest.getParameter("longitude")),
Integer.parseInt(webRequest.getParameter("radius"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.parking.config.argumentresolver.parking;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface ParkingSearchCondition {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.example.parking.config.argumentresolver.parking;

import com.example.parking.application.parking.dto.ParkingSearchConditionRequest;
import java.util.Arrays;
import java.util.List;
import org.springframework.core.MethodParameter;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

@Component
public class ParkingSearchConditionArgumentResolver implements HandlerMethodArgumentResolver {

@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.hasParameterAnnotation(ParkingSearchCondition.class);
}

@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) {

String[] operationTypes = webRequest.getParameterValues("operationTypes");
String[] parkingTypes = webRequest.getParameterValues("parkingTypes");
String[] feeTypes = webRequest.getParameterValues("feeTypes");
String[] payTypes = webRequest.getParameterValues("payTypes");
Integer hours = Integer.parseInt(webRequest.getParameter("hours"));

if (containsNull(operationTypes, parkingTypes, feeTypes, payTypes, hours)) {
return ParkingSearchConditionRequest.base();
}

return new ParkingSearchConditionRequest(
toCollection(operationTypes),
toCollection(parkingTypes),
toCollection(feeTypes),
toCollection(payTypes),
hours
);
}

private boolean containsNull(String[] operationTypes, String[] parkingTypes, String[] feeTypes,
String[] payTypes, Integer hours) {
if (operationTypes == null || parkingTypes == null || feeTypes == null || payTypes == null || hours == null) {
return true;
}
return false;
}

private List<String> toCollection(String[] parameters) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toList()는 어때요 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고민했었는데 toList로 바꿀게여 ㅋㅋㅋㅋ

return Arrays.stream(parameters)
.toList();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.example.parking.domain.parking;

import com.example.parking.domain.searchcondition.SearchConditionAvailable;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;

@Getter
Expand All @@ -16,6 +18,13 @@ public enum OperationType implements SearchConditionAvailable {
this.description = description;
}

public static List<String> getAllValues() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

중복 메서드 SearchConditionAvailable에 아래 메서드 만들어서 쓰는게 나을거 같아여

static <E extends SearchConditionAvailable> List<String> getAllValues(E... values) {
        return Arrays.stream(values)
                .filter(e -> e != e.getDefault())
                .map(E::getDescription)
                .toList();
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어떤식으로 가능할지를 몰라서 못했는데 감사합니다~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

적용했습니다~

return Arrays.stream(OperationType.values())
.filter(operationType -> operationType != OperationType.NO_INFO)
.map(operationType -> operationType.description)
.toList();
}

@Override
public OperationType getDefault() {
return NO_INFO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.example.parking.domain.searchcondition.SearchConditionAvailable;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;

@Getter
Expand All @@ -17,6 +18,13 @@ public enum ParkingType implements SearchConditionAvailable {
this.description = description;
}

public static List<String> getAllValues() {
return Arrays.stream(ParkingType.values())
.filter(parkingType -> parkingType != ParkingType.NO_INFO)
.map(parkingType -> parkingType.description)
.toList();
}

@Override
public ParkingType getDefault() {
return NO_INFO;
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/example/parking/domain/parking/PayType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.example.parking.domain.parking;

import com.example.parking.domain.searchcondition.SearchConditionAvailable;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;

@Getter
Expand All @@ -13,10 +15,17 @@ public enum PayType implements SearchConditionAvailable {

private final String description;

PayType(final String description) {
PayType(String description) {
this.description = description;
}

public static List<String> getAllValues() {
return Arrays.stream(PayType.values())
.filter(payType -> payType != PayType.NO_INFO)
.map(payType -> payType.description)
.toList();
}

@Override
public PayType getDefault() {
return NO_INFO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.example.parking.domain.searchcondition;

import java.util.Arrays;
import java.util.List;
import lombok.Getter;

@Getter
Expand All @@ -13,6 +15,13 @@ public enum FeeType implements SearchConditionAvailable {
this.description = description;
}

public static List<String> getAllValues() {
return Arrays.stream(FeeType.values())
.filter(feeType -> feeType != FeeType.NO_INFO)
.map(feeType -> feeType.description)
.toList();
}

@Override
public FeeType getDefault() {
return NO_INFO;
Expand Down