-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT] 길찾기 검색 연관 키워드 API #109
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fb0437f
[feat] diractionDocumnet 초기 설계
zyovn 633cf1c
Merge branch 'develop' of https://github.com/Wayble-Project/wayble-sp…
zyovn dbac114
[feat] place 엔티티 설계
zyovn 8fadc51
[fix] place name nullable = true로 수정
zyovn a798c93
[feat] 장소 검색 후, 저장 API 구현
zyovn 9a04447
[feat] direction mappings, settings
zyovn de642ba
[feat] directionEsRepository
zyovn 75a7c98
[fix] mappings, settings 수정
zyovn 22e3ed7
[refactor] tmap관련 패키지 common으로 이동
zyovn d0b6f8d
[feat] dto 구현
zyovn 9e159a9
[feat] 길찾기 검색 자동완성 API
zyovn 6b4fa94
[remove] 불필요한 클래스 및 메서드 삭제
zyovn 2c32ec5
[remove] 중복되는 변수 삭제
zyovn 922edb0
[docs] directionSwagger 작성
zyovn 6a80a37
[docs] walkingSwagger 수정
zyovn 4517480
[fix] list를 내부에서 받도록 수정
zyovn 3d69dc3
[docs] response schema 작성
zyovn 4f1a31e
[fix] api명 수정
zyovn 664f789
[fix] 피드백 반영
zyovn bb47cea
[fix] 충돌 해결
zyovn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
6 changes: 3 additions & 3 deletions
6
...r/direction/external/tmap/TMapClient.java → ...server/common/client/tmap/TMapClient.java
This file contains hidden or 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
...rection/external/tmap/TMapProperties.java → ...er/common/client/tmap/TMapProperties.java
This file contains hidden or 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
...xternal/tmap/dto/request/TMapRequest.java → .../client/tmap/dto/request/TMapRequest.java
This file contains hidden or 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
...map/dto/response/TMapParsingResponse.java → ...map/dto/response/TMapParsingResponse.java
This file contains hidden or 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
...ernal/tmap/dto/response/TMapResponse.java → ...lient/tmap/dto/response/TMapResponse.java
This file contains hidden or 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
6 changes: 3 additions & 3 deletions
6
...tion/external/tmap/mapper/TMapMapper.java → ...common/client/tmap/mapper/TMapMapper.java
This file contains hidden or 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
src/main/java/com/wayble/server/common/config/WebClientConfig.java
This file contains hidden or 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
32 changes: 18 additions & 14 deletions
32
src/main/java/com/wayble/server/direction/controller/DirectionController.java
This file contains hidden or 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 |
|---|---|---|
| @@ -1,29 +1,33 @@ | ||
| package com.wayble.server.direction.controller; | ||
|
|
||
| import com.wayble.server.common.response.CommonResponse; | ||
| import com.wayble.server.direction.controller.swagger.DirectionSwagger; | ||
| import com.wayble.server.direction.dto.request.PlaceSaveRequest; | ||
| import com.wayble.server.direction.dto.response.DirectionSearchResponse; | ||
| import com.wayble.server.direction.service.DirectionService; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/directions") | ||
| public class DirectionController { | ||
| @RequestMapping("/api/v1/directions") | ||
| public class DirectionController implements DirectionSwagger { | ||
|
|
||
| private final DirectionService directionService; | ||
|
|
||
| // 참고용 컨트롤러(지우셔도 돼요) | ||
| @GetMapping("/hello") | ||
| public CommonResponse<String> hello() { | ||
| return CommonResponse.success("hello"); | ||
| @Override | ||
| @PostMapping("/place") | ||
| public CommonResponse<String> savePlace(@RequestBody @Valid PlaceSaveRequest request) { | ||
| directionService.savePlaceAndIndexDocument(request.requests()); | ||
| return CommonResponse.success("Place Save successful"); | ||
| } | ||
|
|
||
| // 예외 사용 참고용 컨트롤러(지우셔도 돼요) | ||
| @GetMapping("/ex") | ||
| public CommonResponse<String> exception() { | ||
| directionService.makeException(); | ||
| return CommonResponse.success("예외 발생!"); | ||
| @Override | ||
| @GetMapping("/auto-complete") | ||
| public CommonResponse<List<DirectionSearchResponse>> getDirectionKeywords(@RequestParam String keyword) { | ||
| return CommonResponse.success(directionService.searchDirection(keyword)); | ||
| } | ||
| } | ||
This file contains hidden or 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
45 changes: 45 additions & 0 deletions
45
src/main/java/com/wayble/server/direction/controller/swagger/DirectionSwagger.java
This file contains hidden or 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,45 @@ | ||
| package com.wayble.server.direction.controller.swagger; | ||
|
|
||
| import com.wayble.server.common.response.CommonResponse; | ||
| import com.wayble.server.direction.dto.request.PlaceSaveRequest; | ||
| import com.wayble.server.direction.dto.response.DirectionSearchResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.validation.Valid; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Tag(name = "[길찾기 - 검색]", description = "길찾기 검색 등 API") | ||
| public interface DirectionSwagger { | ||
| @Operation( | ||
| summary = "길찾기에서 검색한 장소 저장 및 place -> directionDocument 변환 API", | ||
| description = "네이버 검색 API 호출 후, 검색한 장소를 저장 및 변환 + 색인 과정을 진행합니다." | ||
| ) | ||
| @ApiResponses(value = { | ||
| @ApiResponse( | ||
| responseCode = "200", | ||
| description = "장소 저장 및 변환이 성공적으로 실행되었습니다." | ||
| ) | ||
| }) | ||
| CommonResponse<String> savePlace( | ||
| @RequestBody @Valid PlaceSaveRequest request | ||
| ); | ||
|
|
||
| @Operation( | ||
| summary = "길찾기 검색 연관어 자동완성 API", | ||
| description = "길찾기 장소 검색 시, 연관어 자동완성을 진행합니다." | ||
| ) | ||
| @ApiResponses(value = { | ||
| @ApiResponse( | ||
| responseCode = "200", | ||
| description = "길찾기 검색 연관어 자동완성이 성공적으로 실행되었습니다." | ||
| ) | ||
| }) | ||
| CommonResponse<List<DirectionSearchResponse>> getDirectionKeywords( | ||
| @RequestParam String keyword | ||
| ); | ||
| } |
This file contains hidden or 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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/wayble/server/direction/dto/request/DirectionSearchRequest.java
This file contains hidden or 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,11 @@ | ||
| package com.wayble.server.direction.dto.request; | ||
|
|
||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| public record DirectionSearchRequest( | ||
| String name, | ||
| Double latitude, | ||
| Double longitude | ||
| ) { | ||
| } |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/wayble/server/direction/dto/request/PlaceSaveRequest.java
This file contains hidden or 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,18 @@ | ||
| package com.wayble.server.direction.dto.request; | ||
|
|
||
| import com.wayble.server.common.entity.Address; | ||
| import lombok.Builder; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Builder | ||
| public record PlaceSaveRequest( | ||
| List<PlaceDetailRequest> requests | ||
| ) { | ||
|
|
||
| @Builder | ||
| public record PlaceDetailRequest( | ||
| String name, | ||
| Address address | ||
| ) {} | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/wayble/server/direction/dto/response/DirectionSearchResponse.java
This file contains hidden or 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 com.wayble.server.direction.dto.response; | ||
|
|
||
| import com.wayble.server.direction.entity.DirectionDocument; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| @Schema(description = "지도 연관어 자동완성 API") | ||
| public record DirectionSearchResponse( | ||
| @Schema(description = "장소의 고유 ID", example = "1") | ||
| Long placeId, | ||
|
|
||
| @Schema(description = "장소의 이름", example = "아임히어") | ||
| String name, | ||
|
|
||
| @Schema(description = "주소", example = "서울시 용산구 청파동") | ||
| String address, | ||
|
|
||
| @Schema(description = "위도", example = "37.84512") | ||
| Double latitude, | ||
|
|
||
| @Schema(description = "경도", example = "127.87451") | ||
| Double longitude | ||
| ) { | ||
| public static DirectionSearchResponse from(DirectionDocument directionDocument) { | ||
| return DirectionSearchResponse.builder() | ||
| .placeId(directionDocument.getId()) | ||
| .name(directionDocument.getName()) | ||
| .address(directionDocument.getEsAddress().getStreetAddress()) | ||
| .latitude(directionDocument.getEsAddress().getLocation().getLat()) | ||
| .longitude(directionDocument.getEsAddress().getLocation().getLon()) | ||
| .build(); | ||
| } | ||
zyovn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
46 changes: 46 additions & 0 deletions
46
src/main/java/com/wayble/server/direction/entity/DirectionDocument.java
This file contains hidden or 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,46 @@ | ||
| package com.wayble.server.direction.entity; | ||
|
|
||
| import com.wayble.server.explore.entity.EsAddress; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.springframework.data.annotation.Id; | ||
| import org.springframework.data.elasticsearch.annotations.*; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Document(indexName = "direction", createIndex = true) | ||
| @Setting(settingPath = "/elasticsearch/settings/direction_settings.json") | ||
| @Mapping(mappingPath = "/elasticsearch/settings/direction_mappings.json") | ||
| public class DirectionDocument { | ||
|
|
||
| @Id | ||
| @Field(type = FieldType.Long) | ||
| private Long id; | ||
|
|
||
| @Field( | ||
| type = FieldType.Text, | ||
| analyzer = "korean_edge_ngram_analyzer", | ||
| searchAnalyzer = "korean_search_analyzer" | ||
| ) | ||
| private String name; | ||
|
|
||
| @Field(type = FieldType.Object) | ||
| private EsAddress esAddress; | ||
|
|
||
| @Builder | ||
| private DirectionDocument(Long id, String name, EsAddress esAddress) { | ||
| this.id = id; | ||
| this.name = name; | ||
| this.esAddress = esAddress; | ||
| } | ||
|
|
||
| public static DirectionDocument from(Place place) { | ||
| return DirectionDocument.builder() | ||
| .id(place.getId()) | ||
| .name(place.getName()) | ||
| .esAddress(EsAddress.from(place.getAddress())) | ||
| .build(); | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/wayble/server/direction/entity/Place.java
This file contains hidden or 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,38 @@ | ||
| package com.wayble.server.direction.entity; | ||
|
|
||
| import com.wayble.server.common.entity.Address; | ||
| import com.wayble.server.common.entity.BaseEntity; | ||
| import jakarta.persistence.*; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @Entity | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class Place extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(name = "name") | ||
| private String name; | ||
|
|
||
| @Embedded | ||
| private Address address; | ||
|
|
||
| @Builder | ||
| public Place(String name, Address address) { | ||
| this.name = name; | ||
| this.address = address; | ||
| } | ||
|
|
||
| public static Place of(String name, Address address) { | ||
| return Place.builder() | ||
| .name(name) | ||
| .address(address) | ||
| .build(); | ||
| } | ||
| } |
This file contains hidden or 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
10 changes: 10 additions & 0 deletions
10
...n/java/com/wayble/server/direction/repository/DirectionElasticSearchCustomRepository.java
This file contains hidden or 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,10 @@ | ||
| package com.wayble.server.direction.repository; | ||
|
|
||
| import com.wayble.server.direction.dto.request.DirectionSearchRequest; | ||
| import com.wayble.server.direction.dto.response.DirectionSearchResponse; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface DirectionElasticSearchCustomRepository { | ||
| List<DirectionSearchResponse> searchDirection(DirectionSearchRequest request); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.