-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: jsonProperty 설정 * feat: hibernate 공간 데이터 의존성 추가 * feat: Location 의 필드를 공간데이터 타입 Point 로 수정 * feat: querydsl 의존성 추가 * feat: querydsl 의존성 제거 * feat: 주차장 목록 조회 쿼리 파라미터 전용 argument resolver 구현 * feat: 반경 내 주차장 조회 쿼리 작성 * feat: argument resolver 등록 * feat: 반경 내 주차장 조회 controller, service(정렬, 필터링) 구현 * feat: builder 추가 * feat: 필터 기능하는 ParkingDomainService 추가 * feat: 사용하지 않는 코드 제거 * feat: 사용하지 않는 repository 삭제 * feat: 요금 계산 bean 추가 * feat: 주차장 목록 조회 시 사용자 조회 조건 필터링 구현 * feat: 메서드 분리 * feat: 주차장 도보 예상 시간 로직 테스트 작성 * refactor: 주석 제거 * feat: 주차장 목록 조회 시 조회 조건 엔티티로 대체 가능한 query param 제거 * feat: 주차장 검색 조건 request 생성 * feat: 검색 조건 변환 기능 구현 * feat: 반경조회 비회원 조회 구현 * feat: memberId 아규먼트 리졸버 구현 * feat: feeType 타입 변경 * feat: enum 의 value list 변환 로직 SearchConditionAvailable 로 이동 * feat: String 과 일치하는 enum List 변환 로직 SearchConditionAvailable 로 이동 * feat: find 메서드 구현 * feat: 무료인지 확인하는 메서드 구현 * feat: 검색조건 유.무료에 맞는 필터링 기능 구현 * refactor: ParkingDomainService -> ParkingApplicationService 네이밍 변경 * test: 유.무료 필터링 테스트 * refactor: 네이밍 수정 * feat: 비회원 기능 회원 인증 시 sessionId null 반환하도록 수정 * feat: 불필요한 메서드 제거 * feat: 충돌 해결 * feat: swagger 추가 * refactor: 서비스 계층에서 String <-> SearchConditionAvailable Enum 변환 로직 개선 * fix: 잘못 사용되고 있는 값 객체 제거 * feat: 응답 dto 변환 로직 이동 * refactor: 네이밍 수정 * feat: 현재 시간 변수 생성 위치 수정 --------- Co-authored-by: This2sho <zx00018@naver.com>
- Loading branch information
Showing
43 changed files
with
1,066 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/example/parking/api/parking/ParkingController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.example.parking.api.parking; | ||
|
||
import com.example.parking.application.parking.ParkingService; | ||
import com.example.parking.application.parking.dto.ParkingLotsResponse; | ||
import com.example.parking.application.parking.dto.ParkingQueryRequest; | ||
import com.example.parking.application.parking.dto.ParkingSearchConditionRequest; | ||
import com.example.parking.config.argumentresolver.MemberAuth; | ||
import com.example.parking.config.argumentresolver.parking.ParkingQuery; | ||
import com.example.parking.config.argumentresolver.parking.ParkingSearchCondition; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "주차장 컨트롤러") | ||
@RequiredArgsConstructor | ||
@RestController | ||
public class ParkingController { | ||
|
||
private final ParkingService parkingService; | ||
|
||
@Operation(summary = "주차장 반경 조회", description = "주차장 반경 조회") | ||
@GetMapping("/parkings") | ||
public ResponseEntity<ParkingLotsResponse> find( | ||
@ParkingQuery ParkingQueryRequest parkingQueryRequest, | ||
@ParkingSearchCondition ParkingSearchConditionRequest parkingSearchConditionRequest, | ||
@Parameter(hidden = true) @MemberAuth(nullable = true) Long parkingMemberId | ||
) { | ||
ParkingLotsResponse parkingLots = parkingService.findParkingLots(parkingQueryRequest, | ||
parkingSearchConditionRequest, parkingMemberId); | ||
return ResponseEntity.ok(parkingLots); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/example/parking/application/SearchConditionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.example.parking.application; | ||
|
||
import com.example.parking.domain.searchcondition.SearchConditionAvailable; | ||
import com.example.parking.support.exception.ClientException; | ||
import com.example.parking.support.exception.ExceptionInformation; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class SearchConditionMapper { | ||
|
||
public <E extends Enum<E> & SearchConditionAvailable> List<E> toEnums(Class<E> searchConditionAvailableClass, | ||
List<String> descriptions) { | ||
return descriptions.stream() | ||
.map(description -> toEnum(searchConditionAvailableClass, description)) | ||
.toList(); | ||
} | ||
|
||
public <E extends Enum<E> & SearchConditionAvailable> E toEnum(Class<E> searchConditionAvailableClass, | ||
String description) { | ||
E[] conditions = searchConditionAvailableClass.getEnumConstants(); | ||
|
||
return Arrays.stream(conditions) | ||
.filter(condition -> description.startsWith(condition.getDescription())) | ||
.findAny() | ||
.orElseThrow(() -> new ClientException(ExceptionInformation.INVALID_DESCRIPTION)); | ||
} | ||
|
||
public <E extends Enum<E> & SearchConditionAvailable> List<String> getValues( | ||
Class<E> searchConditionAvailableClass) { | ||
E[] conditions = searchConditionAvailableClass.getEnumConstants(); | ||
|
||
return Arrays.stream(conditions) | ||
.filter(condition -> condition != condition.getDefault()) | ||
.map(SearchConditionAvailable::getDescription) | ||
.toList(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/example/parking/application/parking/ParkingFilteringService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.example.parking.application.parking; | ||
|
||
import com.example.parking.domain.parking.Parking; | ||
import com.example.parking.domain.parking.ParkingFeeCalculator; | ||
import com.example.parking.domain.parking.SearchingCondition; | ||
import com.example.parking.domain.searchcondition.FeeType; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class ParkingFilteringService { | ||
|
||
private final ParkingFeeCalculator parkingFeeCalculator; | ||
|
||
public List<Parking> filterByCondition(List<Parking> parkingLots, SearchingCondition searchingCondition, | ||
LocalDateTime now) { | ||
return parkingLots.stream() | ||
.filter(parking -> checkFeeTypeIsPaid(searchingCondition) || checkFeeTypeAndFeeFree(searchingCondition, | ||
now, parking)) | ||
.filter(parking -> parking.containsOperationType(searchingCondition.getOperationTypes())) | ||
.filter(parking -> parking.containsParkingType(searchingCondition.getParkingTypes())) | ||
.filter(parking -> parking.containsPayType(searchingCondition.getPayTypes())) | ||
.toList(); | ||
} | ||
|
||
private boolean checkFeeTypeIsPaid(SearchingCondition searchingCondition) { | ||
return searchingCondition.getFeeType() == FeeType.PAID; | ||
} | ||
|
||
private boolean checkFeeTypeAndFeeFree(SearchingCondition searchingCondition, LocalDateTime now, Parking parking) { | ||
return searchingCondition.getFeeType() == FeeType.FREE && parkingFeeCalculator.calculateParkingFee(parking, now, | ||
now.plusHours(searchingCondition.getHours())).isFree(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/example/parking/application/parking/dto/ParkingLotsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.example.parking.application.parking.dto; | ||
|
||
import java.util.List; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ParkingLotsResponse { | ||
|
||
private List<ParkingResponse> parkingLots; | ||
|
||
private ParkingLotsResponse() { | ||
} | ||
|
||
public ParkingLotsResponse(List<ParkingResponse> parkingLots) { | ||
this.parkingLots = parkingLots; | ||
} | ||
|
||
@Getter | ||
public static class ParkingResponse { | ||
private Long parkingId; | ||
private String parkingName; | ||
private Integer estimatedFee; | ||
private Integer estimatedWalkingTime; | ||
private String parkingType; | ||
private Boolean isFavorite; | ||
private Double latitude; | ||
private Double longitude; | ||
|
||
private ParkingResponse() { | ||
} | ||
|
||
public ParkingResponse(Long parkingId, String parkingName, Integer estimatedFee, Integer estimatedWalkingTime, | ||
String parkingType, Boolean isFavorite, Double latitude, Double longitude) { | ||
this.parkingId = parkingId; | ||
this.parkingName = parkingName; | ||
this.estimatedFee = estimatedFee; | ||
this.estimatedWalkingTime = estimatedWalkingTime; | ||
this.parkingType = parkingType; | ||
this.isFavorite = isFavorite; | ||
this.latitude = latitude; | ||
this.longitude = longitude; | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/example/parking/application/parking/dto/ParkingQueryRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.example.parking.application.parking.dto; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ParkingQueryRequest { | ||
|
||
private final Double latitude; | ||
private final Double longitude; | ||
private final Integer radius; | ||
|
||
public ParkingQueryRequest(Double latitude, Double longitude, Integer radius) { | ||
this.latitude = latitude; | ||
this.longitude = longitude; | ||
this.radius = radius; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/example/parking/application/parking/dto/ParkingSearchConditionRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example.parking.application.parking.dto; | ||
|
||
import java.util.List; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ParkingSearchConditionRequest { | ||
|
||
private final List<String> operationTypes; | ||
private final List<String> parkingTypes; | ||
private final String feeType; | ||
private final List<String> payTypes; | ||
private final Integer hours; | ||
private final String priority; | ||
|
||
public ParkingSearchConditionRequest(List<String> operationTypes, List<String> parkingTypes, String feeType, | ||
List<String> payTypes, int hours, String priority) { | ||
this.operationTypes = operationTypes; | ||
this.parkingTypes = parkingTypes; | ||
this.feeType = feeType; | ||
this.payTypes = payTypes; | ||
this.hours = hours; | ||
this.priority = priority; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.