-
Notifications
You must be signed in to change notification settings - Fork 1
[chore] Elastic Search 관련 기능 디렉토리 구조 변경, 경고 문구 해결 #40
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
Changes from all commits
cf16044
455c526
c0ee97f
ffe660c
2b94fdf
b4501b3
7b39ac8
adf0705
f4b0d2b
c0dbab7
d7f15ab
6725846
b454e2e
8684288
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ services: | |
| networks: | ||
| es-network: | ||
| driver: bridge | ||
| external: false | ||
| attachable: true | ||
|
|
||
| volumes: | ||
| esdata: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.wayble.server.explore.controller; | ||
|
|
||
| import com.wayble.server.common.response.CommonResponse; | ||
| import com.wayble.server.explore.dto.recommend.WaybleZoneRecommendResponseDto; | ||
| import com.wayble.server.explore.service.WaybleZoneRecommendService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.validation.annotation.Validated; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @Validated | ||
| @RequestMapping("/api/v1/wayble-zones/recommend") | ||
| public class WaybleZoneRecommendController { | ||
|
|
||
| private final WaybleZoneRecommendService waybleZoneRecommendService; | ||
|
|
||
| @GetMapping("/{userId}") | ||
| public CommonResponse<WaybleZoneRecommendResponseDto> getWaybleZonePersonalRecommend( | ||
| @PathVariable("userId") Long userId) { | ||
| WaybleZoneRecommendResponseDto dto = waybleZoneRecommendService.getWaybleZonePersonalRecommend(userId); | ||
| return CommonResponse.success(dto); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.wayble.server.explore.dto.recommend; | ||
|
|
||
| public record WaybleZoneRecommendResponseDto( | ||
|
|
||
| String username | ||
|
|
||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package com.wayble.server.search.dto; | ||
| package com.wayble.server.explore.dto.search; | ||
|
|
||
| import java.util.List; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package com.wayble.server.explore.entity; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.Period; | ||
|
|
||
| public enum AgeGroup { | ||
| TEENAGERS, | ||
| TWENTIES, | ||
| THIRTIES, | ||
| FORTIES, | ||
| FIFTIES, | ||
| SIXTIES, | ||
| SEVENTIES, | ||
| EIGHTIES, | ||
| OTHERS; | ||
|
|
||
| public static AgeGroup fromBirthDate(LocalDate birthDate) { | ||
| if (birthDate == null) { | ||
| return OTHERS; | ||
| } | ||
| int age = Period.between(birthDate, LocalDate.now()).getYears(); | ||
|
|
||
| if (age >= 10 && age < 20) { | ||
| return TEENAGERS; | ||
| } else if (age < 30) { | ||
| return TWENTIES; | ||
| } else if (age < 40) { | ||
| return THIRTIES; | ||
| } else if (age < 50) { | ||
| return FORTIES; | ||
| } else if (age < 60) { | ||
| return FIFTIES; | ||
| } else if (age < 70) { | ||
| return SIXTIES; | ||
| } else if (age < 80) { | ||
| return SEVENTIES; | ||
| } else if (age < 90) { | ||
| return EIGHTIES; | ||
| } else { | ||
| return OTHERS; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package com.wayble.server.explore.entity; | ||
|
|
||
| import org.springframework.data.annotation.Id; | ||
| import com.wayble.server.user.entity.Gender; | ||
| import com.wayble.server.user.entity.User; | ||
| import lombok.*; | ||
| import org.springframework.data.elasticsearch.annotations.Document; | ||
| import org.springframework.data.elasticsearch.annotations.Field; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @ToString | ||
| @Builder | ||
| @Getter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| @Document(indexName = "wayble_zone_visit_log") | ||
| public class WaybleZoneVisitLogDocument { | ||
|
|
||
| @Id | ||
| @Field(name = "id") | ||
| private Long logId; | ||
|
|
||
| private Long userId; | ||
|
|
||
| private Long zoneId; | ||
|
|
||
| private Gender gender; | ||
|
|
||
| private AgeGroup ageGroup; | ||
|
|
||
| public static WaybleZoneVisitLogDocument fromEntity(User user, Long zoneId) { | ||
| return WaybleZoneVisitLogDocument.builder() | ||
| .logId(UUID.randomUUID().getMostSignificantBits() & Long.MAX_VALUE) | ||
| .userId(user.getId()) | ||
| .zoneId(zoneId) | ||
| .gender(user.getGender()) | ||
| .ageGroup(AgeGroup.fromBirthDate(user.getBirthDate())) | ||
| .build(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.wayble.server.explore.exception; | ||
|
|
||
| import com.wayble.server.common.exception.ErrorCase; | ||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public enum RecommendErrorCase implements ErrorCase { | ||
|
|
||
| INVALID_USER(400, 6001, "잘못된 유저 정보입니다."); | ||
|
|
||
| private final Integer httpStatusCode; | ||
| private final Integer errorCode; | ||
| private final String message; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.wayble.server.explore.repository; | ||
|
|
||
| import com.wayble.server.explore.entity.WaybleZoneDocument; | ||
| import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| public interface WaybleZoneDocumentRepository extends ElasticsearchRepository<WaybleZoneDocument, Long>{ | ||
| Optional<WaybleZoneDocument> findById(Long waybleZoneId); | ||
| List<WaybleZoneDocument> findAll(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.wayble.server.explore.repository; | ||
|
|
||
| import com.wayble.server.explore.entity.WaybleZoneVisitLogDocument; | ||
| import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; | ||
|
|
||
|
|
||
| public interface WaybleZoneVisitLogDocumentRepository extends ElasticsearchRepository<WaybleZoneVisitLogDocument, Long>{ | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||||||||||||||||||||
| package com.wayble.server.explore.repository.recommend; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import com.wayble.server.explore.dto.recommend.WaybleZoneRecommendResponseDto; | ||||||||||||||||||||||||
| import com.wayble.server.user.entity.User; | ||||||||||||||||||||||||
| import lombok.RequiredArgsConstructor; | ||||||||||||||||||||||||
| import org.springframework.data.elasticsearch.core.ElasticsearchOperations; | ||||||||||||||||||||||||
| import org.springframework.stereotype.Repository; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @Repository | ||||||||||||||||||||||||
| @RequiredArgsConstructor | ||||||||||||||||||||||||
| public class WaybleZoneQueryRecommendRepository { | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private final ElasticsearchOperations operations; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public WaybleZoneRecommendResponseDto searchPersonalWaybleZone(User user) { | ||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+13
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 미구현 메서드가
- public WaybleZoneRecommendResponseDto searchPersonalWaybleZone(User user) {
- return null;
- }
+ public WaybleZoneRecommendResponseDto searchPersonalWaybleZone(User user) {
+ // TODO: Elasticsearch 쿼리 구현
+ throw new UnsupportedOperationException("검색 로직이 아직 구현되지 않았습니다.");
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AgeGroup 임포트가 누락되었습니다.
AgeGroup타입이 사용되고 있지만 임포트 문이 누락되었습니다.다음 임포트를 추가하세요:
+import com.wayble.server.user.entity.AgeGroup;🤖 Prompt for AI Agents