forked from kookmin-sw/cap-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
실종자 List 가져오기 api 변경, ai 탐색결과 가져오기 더미 api 생성
�Feat : 실종자 List 가져오기 api 변경, ai 탐색결과 가져오기 더미 api 생성
- Loading branch information
Showing
9 changed files
with
184 additions
and
68 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
25 changes: 25 additions & 0 deletions
25
server/src/main/java/com/capstone/server/dto/SearchResultDto.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.capstone.server.dto; | ||
|
||
import com.capstone.server.model.SearchResultEntity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class SearchResultDto { | ||
private double similarity; | ||
private String imgUrl; | ||
private LocalDateTime time; | ||
|
||
public SearchResultDto(SearchResultEntity searchResultEntity) { | ||
this.similarity = searchResultEntity.getSimilarity(); | ||
this.imgUrl = searchResultEntity.getImageUrl(); | ||
this.time = searchResultEntity.getTime(); | ||
} | ||
|
||
public static SearchResultDto fromEntity(SearchResultEntity searchResultEntity) { | ||
return new SearchResultDto(searchResultEntity); | ||
} | ||
} |
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
server/src/main/java/com/capstone/server/model/enums/SearchResultSortBy.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 com.capstone.server.model.enums; | ||
|
||
import com.capstone.server.code.ErrorCode; | ||
import com.capstone.server.exception.CustomException; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.Arrays; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum SearchResultSortBy { | ||
SIMILARITY("similarity", "similarity"), | ||
LATEST("latest", "time"); | ||
private final String value; | ||
private final String sortBy; | ||
|
||
public static SearchResultSortBy fromValue(String value) { | ||
return Arrays.stream(SearchResultSortBy.values()) | ||
.filter(sortBy -> sortBy.value.equals(value.trim())) | ||
.findFirst() | ||
.orElseThrow(() -> new CustomException(ErrorCode.BAD_REQUEST, "sort type error", "wrong sort type")); | ||
} | ||
} |
11 changes: 9 additions & 2 deletions
11
server/src/main/java/com/capstone/server/repository/SearchResultRepository.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 |
---|---|---|
@@ -1,10 +1,17 @@ | ||
package com.capstone.server.repository; | ||
|
||
import com.capstone.server.model.SearchHistoryEntity; | ||
import com.capstone.server.model.SearchResultEntity; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import com.capstone.server.model.SearchHistoryEntity; | ||
import java.util.List; | ||
|
||
public interface SearchResultRepository extends JpaRepository<SearchResultEntity, Long>{ | ||
@Repository | ||
public interface SearchResultRepository extends JpaRepository<SearchResultEntity, Long> { | ||
List<SearchResultEntity> findAllBySearchHistoryEntity(SearchHistoryEntity searchHistoryEntity); | ||
|
||
Page<SearchResultEntity> findAllBySearchHistoryEntity(Pageable pageable, SearchHistoryEntity searchHistoryEntity); | ||
} |
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.