File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
src/main/java/kr/kro/photoliner/domain/photo Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 22
33import java .time .LocalDateTime ;
44import java .util .List ;
5+ import java .util .Optional ;
56import kr .kro .photoliner .domain .photo .model .Photo ;
67import kr .kro .photoliner .domain .photo .model .Photos ;
8+ import org .locationtech .jts .geom .Point ;
79
810public record PhotosResponse (
911 Integer count ,
@@ -23,18 +25,19 @@ public record InnerPhotoResponse(
2325 Long id ,
2426 String filePath ,
2527 LocalDateTime capturedDt ,
26- double lat ,
27- double lng ,
28+ Double lat ,
29+ Double lng ,
2830 Long userId
2931 ) {
3032
3133 public static InnerPhotoResponse from (Photo photo ) {
34+ Optional <Point > location = Optional .ofNullable (photo .getLocation ());
3235 return new InnerPhotoResponse (
3336 photo .getId (),
3437 photo .getFilePath (),
3538 photo .getCapturedDt (),
36- photo . getLocation (). getY ( ),
37- photo . getLocation (). getX ( ),
39+ location . map ( Point :: getY ). orElse ( null ),
40+ location . map ( Point :: getX ). orElse ( null ),
3841 photo .getUser ().getId ());
3942 }
4043 }
Original file line number Diff line number Diff line change 1212import jakarta .validation .constraints .NotNull ;
1313import java .time .LocalDate ;
1414import java .time .LocalDateTime ;
15+ import java .util .Optional ;
1516import kr .kro .photoliner .common .model .BaseEntity ;
1617import kr .kro .photoliner .domain .user .model .User ;
1718import lombok .AccessLevel ;
@@ -52,8 +53,10 @@ public class Photo extends BaseEntity {
5253 private User user ;
5354
5455 public boolean isBetween (LocalDate start , LocalDate end ) {
55- LocalDate capturedDate = capturedDt .toLocalDate ();
56- return capturedDate .isAfter (start ) && capturedDate .isBefore (end );
56+ return Optional .ofNullable (capturedDt )
57+ .map (LocalDateTime ::toLocalDate )
58+ .filter (localDate -> localDate .isAfter (start ) && localDate .isBefore (end ))
59+ .isPresent ();
5760 }
5861
5962 public void updateCapturedDate (LocalDateTime capturedDt ) {
You can’t perform that action at this time.
0 commit comments