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

[Academy 전반] 스케줄 중복 여부 확인 로직 수정 및 학원 데이터 무한스크롤 방식으로 수정 #102

Merged
merged 24 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
84d45d3
Refactor : 스케줄 중복 여부 확인하는 로직 수정
byeolhaha Dec 1, 2023
2bad956
Refactor : 스케줄 중복 예외 포맷 수정
byeolhaha Dec 1, 2023
4690738
Feat : 아이가 해당 기간 내에 생성된 스케줄이 있는지 조회하는 쿼리 구현
byeolhaha Dec 1, 2023
a16bf99
Refactor : 스케줄 중복 여부 확인하는 여부 수정으로 인한 서비스 로직 변경
byeolhaha Dec 1, 2023
a63f839
Test : 중복된 스케줄 생성시 예외를 던지는지 확인하는 테스트 구현
byeolhaha Dec 1, 2023
0eed379
Refactor : 스케줄을 통해 대시보드 아이디를 얻는 메서드 구현
byeolhaha Dec 1, 2023
b2fbed8
Style : 코드 리포매팅
byeolhaha Dec 1, 2023
e11b837
Style : 쿼리문 괄호로 하드코딩된 부분 수정
byeolhaha Dec 1, 2023
b3b9150
Refactor : 대각선 구하는 로직 서비스에서 분리
byeolhaha Dec 1, 2023
c031a65
Feat : 무한스크롤 방식으로 위치 기반 학원 데이터 조회하는 쿼리 구현
byeolhaha Dec 1, 2023
bd79ab7
Feat : 무한스크롤 방식으로 위치 기반하여 학원 데이터 조회하는 서비스 구현 및 대각선 구하는 로직 분리하여 정리
byeolhaha Dec 1, 2023
f07be95
Feat : 무한스크롤 위치기반 학원 데이터 서비스 dto 구현
byeolhaha Dec 1, 2023
126a38c
Feat : 무한스크롤 위치 기반 학원 데이터 조회 퍼사드 구현
byeolhaha Dec 1, 2023
77d646e
Feat : 무한스크롤 위치 기반 학원 데이터 조회 컨트롤러 구현
byeolhaha Dec 1, 2023
9f9ff57
Style : 파일 이동
byeolhaha Dec 1, 2023
364c1f7
Style : 파일 삭제 및 파일명 변경
byeolhaha Dec 2, 2023
cfa1f87
Feat :. 무한스크롤 방식 필터 조회 쿼리 구현 및 조건 쿼리 메서드 분리 리팩토링
byeolhaha Dec 2, 2023
9b55b11
Feat : 무한스크롤 필터 조회 서비스 구현
byeolhaha Dec 2, 2023
265bf2b
Feat : 무한스크롤 필터 조회 컨트롤러 구현
byeolhaha Dec 2, 2023
c7cca23
Style : 불필요한 코드 제거 및 리포매팅
byeolhaha Dec 2, 2023
5ef6806
Fix : import문 정리
byeolhaha Dec 2, 2023
4045f5d
Fix : hashMap 오류로 인한 수정
byeolhaha Dec 2, 2023
91cac9b
Test : 중심 위치 기반 무한스크롤 방식 학원 조회 테스트 구현
byeolhaha Dec 2, 2023
4398a5b
Test : 학원 필터 조회 무한스크롤 기능 테스트 구현
byeolhaha Dec 2, 2023
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
@@ -1,18 +1,14 @@
package org.guzzing.studayserver.domain.academy.controller;

import jakarta.validation.Valid;
import org.guzzing.studayserver.domain.academy.controller.dto.request.AcademiesByLocationRequest;
import org.guzzing.studayserver.domain.academy.controller.dto.request.AcademiesByNameRequest;
import org.guzzing.studayserver.domain.academy.controller.dto.request.AcademyFilterRequest;
import org.guzzing.studayserver.domain.academy.controller.dto.response.AcademiesByLocationResponses;
import org.guzzing.studayserver.domain.academy.controller.dto.response.AcademiesByNameResponses;
import org.guzzing.studayserver.domain.academy.controller.dto.response.AcademyFilterResponses;
import org.guzzing.studayserver.domain.academy.controller.dto.response.AcademyGetResponse;
import org.guzzing.studayserver.domain.academy.controller.dto.response.LessonInfoToCreateDashboardResponses;
import org.guzzing.studayserver.domain.academy.controller.dto.request.*;
import org.guzzing.studayserver.domain.academy.controller.dto.response.*;
import org.guzzing.studayserver.domain.academy.facade.AcademyFacade;
import org.guzzing.studayserver.domain.academy.facade.dto.AcademiesByLocationFacadeResult;
import org.guzzing.studayserver.domain.academy.facade.dto.AcademiesByLocationWithScrollFacadeResult;
import org.guzzing.studayserver.domain.academy.service.AcademyService;
import org.guzzing.studayserver.domain.academy.service.dto.result.AcademiesByNameResults;
import org.guzzing.studayserver.domain.academy.service.dto.result.AcademiesFilterWithScrollResults;
import org.guzzing.studayserver.domain.academy.service.dto.result.AcademyFilterResults;
import org.guzzing.studayserver.domain.academy.service.dto.result.LessonInfoToCreateDashboardResults;
import org.guzzing.studayserver.domain.auth.memberId.MemberId;
Expand Down Expand Up @@ -62,6 +58,20 @@ public ResponseEntity<AcademiesByLocationResponses> findByLocation(
.body(AcademiesByLocationResponses.from(response));
}

@GetMapping(
path = "/complexes-scroll",
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<AcademiesByLocationWithScrollResponses> findByLocationWithScroll(
@ModelAttribute @Valid AcademyByLocationWithScrollRequest request,
@MemberId Long memberId
) {
AcademiesByLocationWithScrollFacadeResult response = academyFacade.findByLocationWithScroll(
AcademyByLocationWithScrollRequest.to(request, memberId));

return ResponseEntity.status(HttpStatus.OK)
.body(AcademiesByLocationWithScrollResponses.from(response));
}

@GetMapping(
path = "/search",
produces = MediaType.APPLICATION_JSON_VALUE)
Expand Down Expand Up @@ -89,6 +99,20 @@ public ResponseEntity<AcademyFilterResponses> filterAcademies(
.body(AcademyFilterResponses.from(academyFilterResults));
}

@GetMapping(
path = "/filter-scroll",
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<AcademiesFilterWithScrollResponses> filterAcademies(
@ModelAttribute @Valid AcademyFilterWithScrollRequest request,
@MemberId Long memberId
) {
AcademiesFilterWithScrollResults academiesFilterWithScrollResults = academyService.filterAcademies(
AcademyFilterWithScrollRequest.to(request), memberId);

return ResponseEntity.status(HttpStatus.OK)
.body(AcademiesFilterWithScrollResponses.from(academiesFilterWithScrollResults));
}

@GetMapping(
path = "/{academyId}/lessons",
produces = MediaType.APPLICATION_JSON_VALUE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.guzzing.studayserver.domain.academy.controller.dto.request;

import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PositiveOrZero;
import org.guzzing.studayserver.domain.academy.facade.dto.AcademiesByLocationWithScrollFacadeParam;

public record AcademyByLocationWithScrollRequest(
@NotNull(message = "Latitude cannot be null")
@DecimalMin(value = "-90", message = "Invalid latitude")
Double lat,

@NotNull(message = "Longitude cannot be null")
@DecimalMin(value = "-180", message = "Invalid longitude")
Double lng,

@PositiveOrZero
int pageNumber
) {

public static AcademiesByLocationWithScrollFacadeParam to(AcademyByLocationWithScrollRequest request, Long memberId) {
return new AcademiesByLocationWithScrollFacadeParam(
request.lat,
request.lng,
memberId,
request.pageNumber
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package org.guzzing.studayserver.domain.academy.controller.dto.request;

import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotNull;
import org.guzzing.studayserver.domain.academy.controller.dto.validation.ValidCategoryName;
import org.guzzing.studayserver.domain.academy.service.dto.param.AcademyFilterWithScrollParam;

import java.util.List;

public record AcademyFilterWithScrollRequest(
@NotNull(message = "Latitude cannot be null")
@DecimalMin(value = "33.0", message = "Invalid latitude")
@DecimalMax(value = "38.0", message = "Invalid latitude")
Double lat,

@NotNull(message = "Longitude cannot be null")
@DecimalMin(value = "125.0", message = "Invalid longitude")
@DecimalMax(value = "130.0", message = "Invalid longitude")
Double lng,

@ValidCategoryName
List<String> categories,

Long desiredMinAmount,

Long desiredMaxAmount,

int pageNumber
) {

@AssertTrue(message = "최소 희망 금액이 최대 희망 금액보다 클 수 없습니다.")
private boolean isValidDesiredAmount() {
if (desiredMinAmount != null && desiredMaxAmount != null) {
return isPositiveAmount() && isBiggerThanMinAmount();
}
return true;
}

private boolean isPositiveAmount() {
return desiredMinAmount >= 0 && desiredMaxAmount >= 0;
}

private boolean isBiggerThanMinAmount() {
return desiredMaxAmount >= desiredMinAmount;
}

@AssertTrue(message = "pageNumber는 0보타 커야 합니다.")
private boolean isValidPageNumber() {
return pageNumber >= 0;
}

public static AcademyFilterWithScrollParam to(AcademyFilterWithScrollRequest request) {
return new AcademyFilterWithScrollParam(
request.lat,
request.lng,
request.categories(),
request.desiredMinAmount,
request.desiredMaxAmount,
request.pageNumber
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.guzzing.studayserver.domain.academy.controller.dto.response;

import org.guzzing.studayserver.domain.academy.facade.dto.AcademiesByLocationWithScrollFacadeResult;

import java.util.List;

public record AcademiesByLocationWithScrollResponses (
List<AcademyByLocationWithScrollResponse> academiesByLocationResponse,
String sido,
String sigungu,
String upmyeondong,
boolean hasNext
) {

public static AcademiesByLocationWithScrollResponses from(AcademiesByLocationWithScrollFacadeResult academiesByLocationResult) {
return new AcademiesByLocationWithScrollResponses(
academiesByLocationResult.academiesByLocationResults()
.stream()
.map(academiesByLocationFacadeResult ->
AcademyByLocationWithScrollResponse.from(
academiesByLocationFacadeResult))
.toList(),
academiesByLocationResult.sido(),
academiesByLocationResult.sigungu(),
academiesByLocationResult.upmyeondong(),
academiesByLocationResult.hasNext()
);
}

public record AcademyByLocationWithScrollResponse(
Long academyId,
String academyName,
String address,
String contact,
List<String> categories,
Double latitude,
Double longitude,
String shuttleAvailable,
boolean isLiked
) {

public static AcademyByLocationWithScrollResponse from(
AcademiesByLocationWithScrollFacadeResult.AcademyByLocationWithScrollFacadeResult result) {
return new AcademyByLocationWithScrollResponse(
result.academyId(),
result.academyName(),
result.address(),
result.contact(),
result.categories(),
result.latitude(),
result.longitude(),
result.shuttleAvailable(),
result.isLiked()
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.guzzing.studayserver.domain.academy.controller.dto.response;

import org.guzzing.studayserver.domain.academy.service.dto.result.AcademiesFilterWithScrollResults;


import java.util.List;

public record AcademiesFilterWithScrollResponses (
List<AcademyFilterWithScrollResponse> AcademiesFilterWithScrollResponses,
boolean hasNext
){
public static AcademiesFilterWithScrollResponses from (AcademiesFilterWithScrollResults academiesFilterWithScrollResults) {
return new AcademiesFilterWithScrollResponses(
academiesFilterWithScrollResults.academiesFilterWithScrollResults()
.stream()
.map(academyFilterWithScrollResult -> AcademyFilterWithScrollResponse.from(academyFilterWithScrollResult))
.toList(),
academiesFilterWithScrollResults.hasNext()
);
}

public record AcademyFilterWithScrollResponse(
Long academyId,
String academyName,
String address,
String contact,
List<String> categories,
Double latitude,
Double longitude,
String shuttleAvailable,
boolean isLiked
) {

public static AcademyFilterWithScrollResponse from(AcademiesFilterWithScrollResults.AcademyFilterWithScrollResult academyFilterWithScrollResult) {
return new AcademyFilterWithScrollResponse(
academyFilterWithScrollResult.academyId(),
academyFilterWithScrollResult.academyName(),
academyFilterWithScrollResult.fullAddress(),
academyFilterWithScrollResult.contact(),
academyFilterWithScrollResult.categories(),
academyFilterWithScrollResult.latitude(),
academyFilterWithScrollResult.longitude(),
academyFilterWithScrollResult.shuttleAvailable(),
academyFilterWithScrollResult.isLiked()
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import org.guzzing.studayserver.domain.academy.facade.dto.AcademiesByLocationFacadeParam;
import org.guzzing.studayserver.domain.academy.facade.dto.AcademiesByLocationFacadeResult;
import org.guzzing.studayserver.domain.academy.facade.dto.AcademiesByLocationWithScrollFacadeParam;
import org.guzzing.studayserver.domain.academy.facade.dto.AcademiesByLocationWithScrollFacadeResult;
import org.guzzing.studayserver.domain.academy.service.AcademyService;
import org.guzzing.studayserver.domain.academy.service.dto.result.AcademiesByLocationResults;
import org.guzzing.studayserver.domain.academy.service.dto.result.AcademiesByLocationWithScrollResults;
import org.guzzing.studayserver.domain.academy.util.GeometryUtil;
import org.guzzing.studayserver.domain.region.service.RegionService;
import org.guzzing.studayserver.domain.region.service.dto.location.RegionResult;
Expand Down Expand Up @@ -32,4 +35,17 @@ public AcademiesByLocationFacadeResult findByLocation(AcademiesByLocationFacadeP
return AcademiesByLocationFacadeResult.from(academiesByLocation, regionContainingPoint);
}


public AcademiesByLocationWithScrollFacadeResult findByLocationWithScroll(AcademiesByLocationWithScrollFacadeParam param) {
AcademiesByLocationWithScrollResults academiesByLocationWithScroll = academyService.findAcademiesByLocationWithScroll(
AcademiesByLocationWithScrollFacadeParam.to(param));

RegionResult regionContainingPoint = regionService.findRegionContainingPoint(
GeometryUtil.createPoint(
param.lat(),
param.lng()));

return AcademiesByLocationWithScrollFacadeResult.from(academiesByLocationWithScroll, regionContainingPoint);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.guzzing.studayserver.domain.academy.facade.dto;

import org.guzzing.studayserver.domain.academy.service.dto.param.AcademiesByLocationWithScrollParam;

public record AcademiesByLocationWithScrollFacadeParam(
Double lat,
Double lng,
Long memberId,
int pageNumber

) {

public static AcademiesByLocationWithScrollParam to(AcademiesByLocationWithScrollFacadeParam param) {
return new AcademiesByLocationWithScrollParam(
param.lat,
param.lng,
param.memberId,
param.pageNumber
);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.guzzing.studayserver.domain.academy.facade.dto;

import org.guzzing.studayserver.domain.academy.service.dto.result.AcademiesByLocationWithScrollResults;
import org.guzzing.studayserver.domain.region.service.dto.location.RegionResult;
import java.util.List;

public record AcademiesByLocationWithScrollFacadeResult(
List<AcademyByLocationWithScrollFacadeResult> academiesByLocationResults,
String sido,
String sigungu,
String upmyeondong,
boolean hasNext
) {

public static AcademiesByLocationWithScrollFacadeResult from(
AcademiesByLocationWithScrollResults academiesByLocationResults,
RegionResult regionResult) {
return new AcademiesByLocationWithScrollFacadeResult(
academiesByLocationResults
.academiesByLocationResults()
.stream()
.map(academyByLocationResult ->
AcademyByLocationWithScrollFacadeResult.from(academyByLocationResult))
.toList(),
regionResult.sido(),
regionResult.sigungu(),
regionResult.upmyeondong(),
academiesByLocationResults.hasNext()
);
}

public record AcademyByLocationWithScrollFacadeResult(
Long academyId,
String academyName,
String address,
String contact,
List<String> categories,
Double latitude,
Double longitude,
String shuttleAvailable,
boolean isLiked
) {

public static AcademyByLocationWithScrollFacadeResult from(
AcademiesByLocationWithScrollResults.AcademiesByLocationResultWithScroll result) {
return new AcademyByLocationWithScrollFacadeResult(
result.academyId(),
result.academyName(),
result.address(),
result.contact(),
result.categories(),
result.latitude(),
result.longitude(),
result.shuttleAvailable(),
result.isLiked()
);
}

}
}



Loading