From 25c3f441a79b0e3ed661ef21c9371f73535534f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EC=9C=A4?= Date: Thu, 26 Dec 2024 12:02:48 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20entity=20null=20=EB=B6=88=EA=B0=80?= =?UTF-8?q?=ED=95=9C=20=EC=A0=9C=EC=95=BD=20=EC=A1=B0=EA=B1=B4=EC=9D=B4=20?= =?UTF-8?q?=EB=B6=99=EC=96=B4=EC=9E=88=EB=8A=94=20=ED=95=84=EB=93=9C=20->?= =?UTF-8?q?=20=EC=9B=90=EC=8B=9C=ED=83=80=EC=9E=85=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - nullable false일 경우, 원시타입으로 변경하여 null 보장을 하고자 했습니다. --- .../com/favoriteplace/app/converter/CommentConverter.java | 6 +++--- .../favoriteplace/app/converter/GuestBookConverter.java | 2 +- .../com/favoriteplace/app/converter/PostConverter.java | 2 +- .../com/favoriteplace/app/converter/ShopConverter.java | 2 +- src/main/java/com/favoriteplace/app/domain/Member.java | 4 ++-- .../com/favoriteplace/app/domain/community/Comment.java | 2 +- .../com/favoriteplace/app/domain/community/GuestBook.java | 4 ++-- .../java/com/favoriteplace/app/domain/community/Post.java | 4 ++-- src/main/java/com/favoriteplace/app/domain/item/Item.java | 2 +- .../com/favoriteplace/app/domain/item/PointHistory.java | 2 +- .../favoriteplace/app/domain/travel/CompleteRally.java | 3 +++ .../com/favoriteplace/app/domain/travel/Pilgrimage.java | 4 ++-- .../java/com/favoriteplace/app/domain/travel/Rally.java | 4 ++-- src/main/java/com/favoriteplace/app/dto/item/ItemDto.java | 8 ++++---- .../java/com/favoriteplace/app/dto/member/MemberDto.java | 4 ++-- .../app/service/community/CommentCommandService.java | 7 +++---- 16 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/favoriteplace/app/converter/CommentConverter.java b/src/main/java/com/favoriteplace/app/converter/CommentConverter.java index 4c4c4bc..3a3d2f9 100644 --- a/src/main/java/com/favoriteplace/app/converter/CommentConverter.java +++ b/src/main/java/com/favoriteplace/app/converter/CommentConverter.java @@ -17,7 +17,7 @@ public class CommentConverter { public static CommentResponseDto.ParentComment toComment( Comment comment, Member member, List subComments ) { - if (comment.getIsDeleted()) { + if (comment.isDeleted()) { return CommentResponseDto.ParentComment.builder() .userInfo(hideUserInfo(comment)) .id(null) @@ -45,7 +45,7 @@ public static List toSubComments( return Collections.emptyList(); } return subComments.stream().map(comment -> { - if (comment.getIsDeleted()) { + if (comment.isDeleted()) { return CommentResponseDto.SubComment.builder() .userInfo(hideUserInfo(comment)) .id(null) @@ -140,7 +140,7 @@ public static UserInfoResponseDto showUserInfo(Comment comment) { private static long getNotDeletedComment(List comments) { return comments.stream() - .filter(comment -> !comment.getIsDeleted()) + .filter(comment -> !comment.isDeleted()) .count(); } } diff --git a/src/main/java/com/favoriteplace/app/converter/GuestBookConverter.java b/src/main/java/com/favoriteplace/app/converter/GuestBookConverter.java index 4ebbc26..9f743f8 100644 --- a/src/main/java/com/favoriteplace/app/converter/GuestBookConverter.java +++ b/src/main/java/com/favoriteplace/app/converter/GuestBookConverter.java @@ -89,7 +89,7 @@ public static GuestBookResponseDto.DetailGuestBookDto toDetailGuestBookInfo( private static long getNotDeletedComment(List comments) { return comments.stream() - .filter(comment -> !comment.getIsDeleted()) + .filter(comment -> !comment.isDeleted()) .count(); } diff --git a/src/main/java/com/favoriteplace/app/converter/PostConverter.java b/src/main/java/com/favoriteplace/app/converter/PostConverter.java index 8e863a3..2887090 100644 --- a/src/main/java/com/favoriteplace/app/converter/PostConverter.java +++ b/src/main/java/com/favoriteplace/app/converter/PostConverter.java @@ -52,7 +52,7 @@ public static PostResponseDto.PostInfo toPostInfo(Post post, Boolean isLike, Boo private static long getNotDeletedComment(List comments) { return comments.stream() - .filter(comment -> !comment.getIsDeleted()) + .filter(comment -> !comment.isDeleted()) .count(); } } diff --git a/src/main/java/com/favoriteplace/app/converter/ShopConverter.java b/src/main/java/com/favoriteplace/app/converter/ShopConverter.java index 3b25708..380dafd 100644 --- a/src/main/java/com/favoriteplace/app/converter/ShopConverter.java +++ b/src/main/java/com/favoriteplace/app/converter/ShopConverter.java @@ -21,7 +21,7 @@ public static ItemDto.ItemList itemList(Item item) { .id(item.getId().intValue()) .name(item.getName()) .imageUrl(item.getDefaultImage().getUrl()) - .point(item.getPoint().intValue()) + .point(Long.valueOf(item.getPoint()).intValue()) .build(); } diff --git a/src/main/java/com/favoriteplace/app/domain/Member.java b/src/main/java/com/favoriteplace/app/domain/Member.java index 67f07ef..849243c 100644 --- a/src/main/java/com/favoriteplace/app/domain/Member.java +++ b/src/main/java/com/favoriteplace/app/domain/Member.java @@ -63,10 +63,10 @@ public class Member extends BaseTimeEntity { private MemberStatus status; @Column(nullable = false) - private Boolean alarmAllowance; //true: 허용, false: 허용x + private boolean alarmAllowance; //true: 허용, false: 허용x @Column(nullable = false) - private Long point; + private long point; @Enumerated(STRING) @Column(nullable = false) diff --git a/src/main/java/com/favoriteplace/app/domain/community/Comment.java b/src/main/java/com/favoriteplace/app/domain/community/Comment.java index 992b15d..b789ac3 100644 --- a/src/main/java/com/favoriteplace/app/domain/community/Comment.java +++ b/src/main/java/com/favoriteplace/app/domain/community/Comment.java @@ -70,7 +70,7 @@ public class Comment extends BaseTimeEntity { @Column(nullable = false) @Builder.Default - private Boolean isDeleted = false; + private boolean isDeleted = false; public void setGuestBook(GuestBook guestBook) {this.guestBook = guestBook;} public void setPost(Post post){this.post = post;} diff --git a/src/main/java/com/favoriteplace/app/domain/community/GuestBook.java b/src/main/java/com/favoriteplace/app/domain/community/GuestBook.java index d765382..5b379d8 100644 --- a/src/main/java/com/favoriteplace/app/domain/community/GuestBook.java +++ b/src/main/java/com/favoriteplace/app/domain/community/GuestBook.java @@ -53,10 +53,10 @@ public class GuestBook extends BaseTimeEntity { private String content; @Column(nullable = false) - private Long likeCount; + private long likeCount; @Column(nullable = false) - private Long view; + private long view; @OneToMany(mappedBy = "guestBook", cascade = CascadeType.ALL, orphanRemoval = true) @Builder.Default diff --git a/src/main/java/com/favoriteplace/app/domain/community/Post.java b/src/main/java/com/favoriteplace/app/domain/community/Post.java index e60a80d..ca48a44 100644 --- a/src/main/java/com/favoriteplace/app/domain/community/Post.java +++ b/src/main/java/com/favoriteplace/app/domain/community/Post.java @@ -47,10 +47,10 @@ public class Post extends BaseTimeEntity { private String content; @Column(nullable = false) - private Long likeCount; + private long likeCount; @Column(nullable = false) - private Long view; + private long view; @OneToMany(mappedBy = "post", cascade = CascadeType.ALL) @Builder.Default diff --git a/src/main/java/com/favoriteplace/app/domain/item/Item.java b/src/main/java/com/favoriteplace/app/domain/item/Item.java index 0c3ed68..1f30194 100644 --- a/src/main/java/com/favoriteplace/app/domain/item/Item.java +++ b/src/main/java/com/favoriteplace/app/domain/item/Item.java @@ -63,7 +63,7 @@ public class Item extends BaseTimeEntity{ private LocalDateTime saleDeadline; @Column(nullable = false) - private Long point; + private long point; @Column(nullable = false) private String description; diff --git a/src/main/java/com/favoriteplace/app/domain/item/PointHistory.java b/src/main/java/com/favoriteplace/app/domain/item/PointHistory.java index 43df91c..26f0a2f 100644 --- a/src/main/java/com/favoriteplace/app/domain/item/PointHistory.java +++ b/src/main/java/com/favoriteplace/app/domain/item/PointHistory.java @@ -39,7 +39,7 @@ public class PointHistory { private Member member; @Column(nullable = false) - private Long point; + private long point; @Column(nullable = false) private LocalDateTime dealtAt; diff --git a/src/main/java/com/favoriteplace/app/domain/travel/CompleteRally.java b/src/main/java/com/favoriteplace/app/domain/travel/CompleteRally.java index 24e4960..bd2b175 100644 --- a/src/main/java/com/favoriteplace/app/domain/travel/CompleteRally.java +++ b/src/main/java/com/favoriteplace/app/domain/travel/CompleteRally.java @@ -33,12 +33,15 @@ public class CompleteRally extends BaseTimeEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="complete_rally_id") private Long id; + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "rally_id", nullable = false) private Rally rally; + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "member_id", nullable = false) private Member member; + @Enumerated(EnumType.STRING) private RallyVersion version; } diff --git a/src/main/java/com/favoriteplace/app/domain/travel/Pilgrimage.java b/src/main/java/com/favoriteplace/app/domain/travel/Pilgrimage.java index e967154..03a7e8c 100644 --- a/src/main/java/com/favoriteplace/app/domain/travel/Pilgrimage.java +++ b/src/main/java/com/favoriteplace/app/domain/travel/Pilgrimage.java @@ -61,9 +61,9 @@ public class Pilgrimage extends BaseTimeEntity { private String detailAddressJp; @Column(nullable = false) - private Double latitude; + private double latitude; @Column(nullable = false) - private Double longitude; + private double longitude; } diff --git a/src/main/java/com/favoriteplace/app/domain/travel/Rally.java b/src/main/java/com/favoriteplace/app/domain/travel/Rally.java index 4db13fd..d743532 100644 --- a/src/main/java/com/favoriteplace/app/domain/travel/Rally.java +++ b/src/main/java/com/favoriteplace/app/domain/travel/Rally.java @@ -50,10 +50,10 @@ public class Rally extends BaseTimeEntity { private String description; @Column(nullable = false) - private Long achieveNumber; //달성한 사람 수 + private long achieveNumber; //달성한 사람 수 @Column(nullable = false) - private Long pilgrimageNumber; //해당 랠리의 성지 순례 갯수 + private long pilgrimageNumber; //해당 랠리의 성지 순례 갯수 @OneToMany(mappedBy = "rally") private List pilgrimages; diff --git a/src/main/java/com/favoriteplace/app/dto/item/ItemDto.java b/src/main/java/com/favoriteplace/app/dto/item/ItemDto.java index 8a6daf8..06ffb4c 100644 --- a/src/main/java/com/favoriteplace/app/dto/item/ItemDto.java +++ b/src/main/java/com/favoriteplace/app/dto/item/ItemDto.java @@ -41,20 +41,20 @@ public static class ItemDetailResDto { private String saleDeadline; private String status; private String name; - private Integer point; + private int point; private String description; private Boolean alreadyBought; public static ItemDetailResDto from(Item item, Member member, Boolean alreadyBought) { return ItemDetailResDto.builder() - .userPoint(member == null ? 0 : member.getPoint().intValue()) + .userPoint(member == null ? 0 : Long.valueOf(member.getPoint()).intValue()) .category(item.getCategory().getName()) .imageUrl(item.getDefaultImage().getUrl()) .imageCenterUrl(item.getCenterImage() == null ? null : item.getCenterImage().getUrl()) .saleDeadline(item.getSaleDeadline() == null ? null : DateTimeFormatUtils.convertDateToString(item.getSaleDeadline())) .status(item.getStatus().toString()) .name(item.getName()) - .point(item.getPoint().intValue()) + .point(Long.valueOf(item.getPoint()).intValue()) .description(item.getDescription()) .alreadyBought(alreadyBought) .build(); @@ -102,7 +102,7 @@ public static class ItemList { private Integer id; private String name; private String imageUrl; - private Integer point; + private int point; } @Getter diff --git a/src/main/java/com/favoriteplace/app/dto/member/MemberDto.java b/src/main/java/com/favoriteplace/app/dto/member/MemberDto.java index 82bbe5b..70f9eba 100644 --- a/src/main/java/com/favoriteplace/app/dto/member/MemberDto.java +++ b/src/main/java/com/favoriteplace/app/dto/member/MemberDto.java @@ -126,7 +126,7 @@ public static class TokenInfo { public static class MemberInfo { private Integer id; private String nickname; - private Integer point; + private int point; private String profileImageUrl; private String profileTitleUrl; private String profileIconUrl; @@ -136,7 +136,7 @@ public static MemberInfo from(Member member) { return MemberInfo.builder() .id(member == null ? null : member.getId().intValue()) .nickname(member == null ? null : member.getNickname()) - .point(member == null ? null : member.getPoint().intValue()) + .point(member == null ? null : Long.valueOf(member.getPoint()).intValue()) .profileImageUrl(member.getProfileImageUrl() == null ? null : member.getProfileImageUrl()) .profileIconUrl(member.getProfileIcon() == null ? null : member.getProfileIcon().getDefaultImage().getUrl()) .profileTitleUrl(member.getProfileTitle() == null ? null : member.getProfileTitle().getDefaultImage().getUrl()) diff --git a/src/main/java/com/favoriteplace/app/service/community/CommentCommandService.java b/src/main/java/com/favoriteplace/app/service/community/CommentCommandService.java index fb208f2..d7158e3 100644 --- a/src/main/java/com/favoriteplace/app/service/community/CommentCommandService.java +++ b/src/main/java/com/favoriteplace/app/service/community/CommentCommandService.java @@ -173,7 +173,7 @@ public void deleteComment(Member member, long commendId) { */ private Comment hardDeleteReferenceComment(Comment comment) { Comment referenceComment = comment.getReferenceComment(); - if (referenceComment != null && referenceComment.getIsDeleted() + if (referenceComment != null && referenceComment.isDeleted() && !commentRepository.existsByReferenceComment(referenceComment) ) { commentRepository.delete(referenceComment); @@ -190,7 +190,7 @@ private Comment hardDeleteReferenceComment(Comment comment) { */ private void hardDeleteParentComment(Comment comment) { Comment parentComment = comment.getParentComment(); - if (parentComment.getIsDeleted() && !commentRepository.existsByParentComment(parentComment)) { + if (parentComment.isDeleted() && !commentRepository.existsByParentComment(parentComment)) { commentRepository.delete(parentComment); } } @@ -208,7 +208,7 @@ private void checkAuthOfComment(Member member, Comment comment) { * soft delete로 이미 삭제된 댓글인지 확인하는 함수 (삭제된 댓글이면 에러 출력) */ private void checkIsDeleteOfComment(Comment comment) { - if (comment.getIsDeleted()) { + if (comment.isDeleted()) { throw new RestApiException(ErrorCode.COMMENT_ALREADY_DELETED); } } @@ -247,5 +247,4 @@ private Comment setCommentRelation(Member member, CommentRequestDto.CreateCommen return newComment; } - }