-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from Guzzing/academies
[학원] 학원 검색 필터 구현 및 학원 목록에서 사용자가 좋아요를 한 학원인지의 여부 추가
- Loading branch information
Showing
64 changed files
with
800 additions
and
259 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
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
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
39 changes: 39 additions & 0 deletions
39
.../org/guzzing/studayserver/domain/academy/controller/dto/request/AcademyFilterRequest.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 org.guzzing.studayserver.domain.academy.controller.dto.request; | ||
|
||
import jakarta.validation.constraints.DecimalMin; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Positive; | ||
import org.guzzing.studayserver.domain.academy.controller.dto.validation.ValidAreaOfExpertise; | ||
import org.guzzing.studayserver.domain.academy.service.dto.param.AcademyFilterParam; | ||
|
||
import java.util.List; | ||
|
||
public record AcademyFilterRequest( | ||
@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, | ||
|
||
|
||
@ValidAreaOfExpertise | ||
List<String> areaOfExpertises, | ||
|
||
@Positive | ||
Long desiredMinAmount, | ||
|
||
@Positive | ||
Long desiredMaxAmount | ||
){ | ||
public static AcademyFilterParam to(AcademyFilterRequest request) { | ||
return new AcademyFilterParam ( | ||
request.lat, | ||
request.lng, | ||
request.areaOfExpertises(), | ||
request.desiredMinAmount, | ||
request.desiredMaxAmount | ||
); | ||
} | ||
} |
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
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
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
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
29 changes: 29 additions & 0 deletions
29
...rg/guzzing/studayserver/domain/academy/controller/dto/response/AcademyFilterResponse.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,29 @@ | ||
package org.guzzing.studayserver.domain.academy.controller.dto.response; | ||
|
||
import org.guzzing.studayserver.domain.academy.service.dto.result.AcademyFilterResult; | ||
|
||
public record AcademyFilterResponse( | ||
Long academyId, | ||
String academyName, | ||
String fullAddress, | ||
String contact, | ||
String areaOfExpertise, | ||
Double latitude, | ||
Double longitude, | ||
String shuttleAvailable, | ||
boolean isLiked | ||
) { | ||
public static AcademyFilterResponse from(AcademyFilterResult academyFilterResult) { | ||
return new AcademyFilterResponse( | ||
academyFilterResult.academyId(), | ||
academyFilterResult.academyName(), | ||
academyFilterResult.fullAddress(), | ||
academyFilterResult.contact(), | ||
academyFilterResult.areaOfExpertise(), | ||
academyFilterResult.latitude(), | ||
academyFilterResult.longitude(), | ||
academyFilterResult.shuttleAvailable(), | ||
academyFilterResult.isLiked() | ||
); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...g/guzzing/studayserver/domain/academy/controller/dto/response/AcademyFilterResponses.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,19 @@ | ||
package org.guzzing.studayserver.domain.academy.controller.dto.response; | ||
|
||
import org.guzzing.studayserver.domain.academy.service.dto.result.AcademyFilterResults; | ||
|
||
import java.util.List; | ||
|
||
public record AcademyFilterResponses( | ||
List<AcademyFilterResponse> academyFilterResponses | ||
) { | ||
public static AcademyFilterResponses from(AcademyFilterResults academyFilterResults) { | ||
return new AcademyFilterResponses( | ||
academyFilterResults.academyFilterResults() | ||
.stream() | ||
.map(academyFilterResult -> AcademyFilterResponse.from(academyFilterResult)) | ||
.toList() | ||
); | ||
} | ||
} | ||
|
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
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
2 changes: 1 addition & 1 deletion
2
...a/org/guzzing/studayserver/domain/academy/controller/dto/response/LessonGetResponses.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
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
24 changes: 24 additions & 0 deletions
24
...va/org/guzzing/studayserver/domain/academy/controller/dto/validation/AreaOfExpertise.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,24 @@ | ||
package org.guzzing.studayserver.domain.academy.controller.dto.validation; | ||
|
||
public enum AreaOfExpertise { | ||
|
||
FOREIGN_LANGUAGE("국제화"), | ||
DANCE("기예(대)"), | ||
ETC("기타(대)"), | ||
READING_ROOM("독서실"), | ||
ART_AND_MUSIC("예능(대)"), | ||
HUMANITIES_AND_HISTORY("인문사회(대)"), | ||
TUTORING_SCHOOL("입시.검정 및 보습"), | ||
COMPREHENSIVE("종합(대)"); | ||
|
||
private String kind; | ||
|
||
AreaOfExpertise(String kind) { | ||
this.kind = kind; | ||
} | ||
|
||
public String getAreaOfExpertise() { | ||
return kind; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...g/guzzing/studayserver/domain/academy/controller/dto/validation/ValidAreaOfExpertise.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,20 @@ | ||
package org.guzzing.studayserver.domain.academy.controller.dto.validation; | ||
|
||
import jakarta.validation.Constraint; | ||
import jakarta.validation.Payload; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({ElementType.FIELD, ElementType.PARAMETER}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Constraint(validatedBy = ValidAreaOfExpertiseValidator.class) | ||
public @interface ValidAreaOfExpertise { | ||
String message() default "유효하지 않은 학원 분야입니다."; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
} |
34 changes: 34 additions & 0 deletions
34
.../studayserver/domain/academy/controller/dto/validation/ValidAreaOfExpertiseValidator.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,34 @@ | ||
package org.guzzing.studayserver.domain.academy.controller.dto.validation; | ||
|
||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class ValidAreaOfExpertiseValidator implements ConstraintValidator<ValidAreaOfExpertise, List<String>> { | ||
|
||
@Override | ||
public void initialize(ValidAreaOfExpertise constraintAnnotation) { | ||
} | ||
|
||
@Override | ||
public boolean isValid(List<String> value, ConstraintValidatorContext context) { | ||
if (value == null || value.isEmpty()) { | ||
return false; | ||
} | ||
|
||
for (String areaOfExpertise : value) { | ||
if (!isValidAreaOfExpertise(areaOfExpertise)) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private boolean isValidAreaOfExpertise(String areaOfExpertise) { | ||
return Arrays.stream(AreaOfExpertise.values()) | ||
.anyMatch(enumValue -> enumValue.getAreaOfExpertise().equals(areaOfExpertise)); | ||
} | ||
} |
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.