Skip to content

Commit

Permalink
[fix] entity null 불가한 제약 조건이 붙어있는 필드 -> 원시타입으로 변경
Browse files Browse the repository at this point in the history
- nullable false일 경우, 원시타입으로 변경하여 null 보장을 하고자 했습니다.
  • Loading branch information
JungYoonShin committed Dec 26, 2024
1 parent c84bce6 commit 25c3f44
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CommentConverter {
public static CommentResponseDto.ParentComment toComment(
Comment comment, Member member, List<Comment> subComments
) {
if (comment.getIsDeleted()) {
if (comment.isDeleted()) {
return CommentResponseDto.ParentComment.builder()
.userInfo(hideUserInfo(comment))
.id(null)
Expand Down Expand Up @@ -45,7 +45,7 @@ public static List<CommentResponseDto.SubComment> toSubComments(
return Collections.emptyList();
}
return subComments.stream().map(comment -> {
if (comment.getIsDeleted()) {
if (comment.isDeleted()) {
return CommentResponseDto.SubComment.builder()
.userInfo(hideUserInfo(comment))
.id(null)
Expand Down Expand Up @@ -140,7 +140,7 @@ public static UserInfoResponseDto showUserInfo(Comment comment) {

private static long getNotDeletedComment(List<Comment> comments) {
return comments.stream()
.filter(comment -> !comment.getIsDeleted())
.filter(comment -> !comment.isDeleted())
.count();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static GuestBookResponseDto.DetailGuestBookDto toDetailGuestBookInfo(

private static long getNotDeletedComment(List<Comment> comments) {
return comments.stream()
.filter(comment -> !comment.getIsDeleted())
.filter(comment -> !comment.isDeleted())
.count();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static PostResponseDto.PostInfo toPostInfo(Post post, Boolean isLike, Boo

private static long getNotDeletedComment(List<Comment> comments) {
return comments.stream()
.filter(comment -> !comment.getIsDeleted())
.filter(comment -> !comment.isDeleted())
.count();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/favoriteplace/app/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/favoriteplace/app/domain/item/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
4 changes: 2 additions & 2 deletions src/main/java/com/favoriteplace/app/domain/travel/Rally.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pilgrimage> pilgrimages;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/favoriteplace/app/dto/item/ItemDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -102,7 +102,7 @@ public static class ItemList {
private Integer id;
private String name;
private String imageUrl;
private Integer point;
private int point;
}

@Getter
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/favoriteplace/app/dto/member/MemberDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -247,5 +247,4 @@ private Comment setCommentRelation(Member member, CommentRequestDto.CreateCommen
return newComment;
}


}

0 comments on commit 25c3f44

Please sign in to comment.