Skip to content

Commit

Permalink
Hot fix : Cctv 가져오기 로직 버그수정
Browse files Browse the repository at this point in the history
Hot fix : Cctv 가져오기 로직 버그수정
  • Loading branch information
begong313 authored May 22, 2024
2 parents 75c597e + c0f8975 commit 22401a5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface CCTVRepository extends JpaRepository<CCTVEntity, Long> {
@Query(value = "SELECT * FROM cctv WHERE ST_DWithin(gps, ST_SetSRID(ST_MakePoint(:longitude, :latitude), 4326), 1000, true)", nativeQuery = true)
List<CCTVEntity> findCCTVsByDistance(@Param("longitude") double longitude, @Param("latitude") double latitude);

@Query(value = "SELECT * FROM cctv WHERE ST_DWithin(gps, ST_SetSRID(ST_MakePoint(:longitude, :latitude), 4326), :distance*1000, true)", nativeQuery = true)
@Query(value = "SELECT * FROM cctv WHERE ST_DWithin(gps, ST_SetSRID(ST_MakePoint(:longitude, :latitude), 4326), :distance, true)", nativeQuery = true)
List<CCTVEntity> findCCTVsByDistance(@Param("longitude") double longitude, @Param("latitude") double latitude, @Param("distance") double distance);

@Query(value = "SELECT count(*) FROM cctv WHERE ST_DWithin(gps, ST_SetSRID(ST_MakePoint(:longitude, :latitude), 4326), 1000, true)", nativeQuery = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public List<CCTVDto> findCCTVsNearbyLocationWithinDistance(double longitude, dou

public List<CCTVDto> findCCTVsNearbyLocationWithinDistance(double longitude, double latitude, double radius) {

List<CCTVEntity> cctvEntities = cctvRepository.findCCTVsByDistance(longitude, latitude, radius); // distance 기준: m(미터)
List<CCTVEntity> cctvEntities = cctvRepository.findCCTVsByDistance(longitude, latitude, radius * 1000); // distance 기준: m(미터)

return cctvEntities.stream()
.map(CCTVDto::fromEntity) // 엔티티를 DTO로 변환
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public StepDto getStep(Long missingPeopleId, boolean police) {
StepDto stepDto = StepDto.fromEntity(missingPeopleEntity);
SearchHistoryEntity searchHistoryEntity = searchHistoryRepository.findFirstByMissingPeopleEntityIdAndStepOrderByCreatedAtAsc(missingPeopleId, stepDto.getStep());
if (police && (stepDto.getStep().equals(Step.FIRST) || stepDto.getStep().equals(Step.SECOND))) {
int count = cctvService.findCCTVsNearbyLocationWithinDistance(searchHistoryEntity.getLongitude(), searchHistoryEntity.getLatitude(),searchHistoryEntity.getSearchRadius()).size();
int count = cctvService.findCCTVsNearbyLocationWithinDistance(searchHistoryEntity.getLongitude(), searchHistoryEntity.getLatitude(), searchHistoryEntity.getSearchRadius()).size();
stepDto = new StepDetailDto(stepDto, String.format("CCTV %s개 탐색중", count));
}

Expand Down

0 comments on commit 22401a5

Please sign in to comment.