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

Fix #281

Merged
merged 2 commits into from
May 26, 2024
Merged

Fix #281

Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -13,5 +13,7 @@ public interface SearchHistoryRepository extends JpaRepository<SearchHistoryEnti

SearchHistoryEntity findFirstByMissingPeopleEntityIdAndStepOrderByCreatedAtAsc(Long missingPeopleEntityId, Step step);

SearchHistoryEntity findFirstByMissingPeopleEntityIdAndStepOrderByCreatedAtDesc(Long missingPeopleEntityId, Step step);

SearchHistoryEntity findFirstByMissingPeopleEntityIdOrderByCreatedAtAsc(Long missingPeopleEntityId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ public class DetectService {
//수정 완료.
public FirstDetectionDataDto callFirstDetectAPI(Long id) throws CustomException {
try {

//과정1 : 실종자 id가 db에 있는지 확인합니다. (이건 수정해야될듯 (불필요한 db요청이 너무 많아지는거 같기도 함) todo : 리팩토링. 현재 너무 과도하게 데이터를 불러오고있음.
MissingPeopleEntity missingPeople = missingPeopleRepository.findById(id)
.orElseThrow(() -> new NoSuchElementException("Missing person not found with ID: " + id));
//해당 Id의 가장 최신 탐색기록을 가져와 요청 보낼 dto생성
SearchHistoryEntity searchHistoryEntity = searchHistoryRepository.findFirstByMissingPeopleEntityIdAndStepOrderByCreatedAtAsc(id, Step.fromValue("first"));
SearchHistoryEntity searchHistoryEntity = searchHistoryRepository.findFirstByMissingPeopleEntityIdAndStepOrderByCreatedAtDesc(id, Step.fromValue("first"));
//과정2 : ai server요청에 쓸 dto를생성합니다
FirstDetectionRequestDto firstDetectionRequestDto = FirstDetectionRequestDto.fromEntity(missingPeople, searchHistoryEntity);
firstDetectionRequestDto.setCctvId(cctvService.findCCTVsNearbyLocationWithinDistance(searchHistoryEntity.getLongitude(), searchHistoryEntity.getLatitude(), searchHistoryEntity.getSearchRadius()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ public Long createSearchHistory(SearchRequestDto searchRequestDto, Long missingP
SearchHistoryEntity searchHistoryEntity = searchRequestDto.toSearchHistoryEntity();
searchHistoryEntity.setMissingPeopleEntity(missingPeopleEntity);
searchHistoryEntity.setStep(step);
//실종자 step을 First로 설정
missingPeopleEntity.setStep(step);
return searchHistoryRepository.save(searchHistoryEntity).getId();
}

Expand Down
Loading