diff --git a/src/main/java/balancetalk/bookmark/domain/GameBookmark.java b/src/main/java/balancetalk/bookmark/domain/GameBookmark.java index f2918ca6d..34338a9fc 100644 --- a/src/main/java/balancetalk/bookmark/domain/GameBookmark.java +++ b/src/main/java/balancetalk/bookmark/domain/GameBookmark.java @@ -3,10 +3,7 @@ import balancetalk.game.domain.GameSet; import balancetalk.global.common.BaseTimeEntity; import balancetalk.member.domain.Member; -import jakarta.persistence.Column; import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -29,7 +26,6 @@ public class GameBookmark extends BaseTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") private Long id; @ManyToOne(fetch = FetchType.LAZY) diff --git a/src/main/java/balancetalk/bookmark/domain/TalkPickBookmark.java b/src/main/java/balancetalk/bookmark/domain/TalkPickBookmark.java index a08e7612a..716deb616 100644 --- a/src/main/java/balancetalk/bookmark/domain/TalkPickBookmark.java +++ b/src/main/java/balancetalk/bookmark/domain/TalkPickBookmark.java @@ -3,9 +3,19 @@ import balancetalk.global.common.BaseTimeEntity; import balancetalk.member.domain.Member; import balancetalk.talkpick.domain.TalkPick; -import jakarta.persistence.*; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import jakarta.validation.constraints.NotNull; -import lombok.*; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; @Entity @Builder @@ -13,9 +23,9 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) public class TalkPickBookmark extends BaseTimeEntity { + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") private Long id; @ManyToOne(fetch = FetchType.LAZY) @@ -44,5 +54,4 @@ public void activate() { public void deactivate() { this.active = false; } - } diff --git a/src/main/java/balancetalk/comment/domain/Comment.java b/src/main/java/balancetalk/comment/domain/Comment.java index 6b7f6af05..20d3c2120 100644 --- a/src/main/java/balancetalk/comment/domain/Comment.java +++ b/src/main/java/balancetalk/comment/domain/Comment.java @@ -5,16 +5,30 @@ import balancetalk.member.domain.Member; import balancetalk.talkpick.domain.TalkPick; import balancetalk.talkpick.domain.ViewStatus; -import jakarta.persistence.*; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Transient; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; -import lombok.*; -import org.springframework.lang.Nullable; - import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; @Entity @Builder @@ -23,8 +37,6 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) public class Comment extends BaseTimeEntity { - private static final int MIN_COUNT_FOR_BLIND = 5; - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @@ -34,12 +46,11 @@ public class Comment extends BaseTimeEntity { private String content; @Enumerated(value = EnumType.STRING) + @NotNull private ViewStatus viewStatus; - private Boolean isBest; - @NotNull - private int reportedCount; + private Boolean isBest; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "member_id") @@ -49,7 +60,6 @@ public class Comment extends BaseTimeEntity { @JoinColumn(name = "talk_pick_id") private TalkPick talkPick; - @Nullable @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "parent_id") private Comment parent; @@ -60,6 +70,7 @@ public class Comment extends BaseTimeEntity { @Transient private Boolean isNotifiedForFirstReply = false; + @NotNull private LocalDateTime editedAt; private boolean isEdited; @@ -77,19 +88,6 @@ public void setIsBest(boolean isBest) { this.isBest = isBest; } - public boolean isBlind() { - return this.viewStatus.equals(ViewStatus.BLIND); - } - - public void incrementReportCount() { - this.reportedCount++; - - if (this.reportedCount == MIN_COUNT_FOR_BLIND) { - this.content = "신고된 댓글입니다."; - this.viewStatus = ViewStatus.BLIND; - } - } - public void setIsNotifiedForFirstReplyTrue() { this.isNotifiedForFirstReply = true; } diff --git a/src/main/java/balancetalk/comment/dto/CommentDto.java b/src/main/java/balancetalk/comment/dto/CommentDto.java index b77af2070..7962ca520 100644 --- a/src/main/java/balancetalk/comment/dto/CommentDto.java +++ b/src/main/java/balancetalk/comment/dto/CommentDto.java @@ -7,13 +7,12 @@ import balancetalk.vote.domain.VoteOption; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDateTime; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - public class CommentDto { @Data @Builder @@ -32,7 +31,6 @@ public Comment toEntity(Member member, TalkPick talkPick) { .talkPick(talkPick) .isBest(false) .viewStatus(ViewStatus.NORMAL) - .reportedCount(0) .isNotifiedForFirstReply(false) .editedAt(LocalDateTime.now()) .isEdited(false) @@ -46,7 +44,6 @@ public Comment toEntity(Member member, TalkPick talkPick, Comment parent) { .talkPick(talkPick) .isBest(false) .viewStatus(ViewStatus.NORMAL) - .reportedCount(0) .parent(parent) .isEdited(false) .build(); @@ -128,7 +125,6 @@ public static LatestCommentResponse fromEntity(Comment comment, VoteOption voteO .likesCount(likesCount) .myLike(myLike) .replyCount(comment.getReplies() == null ? 0 : comment.getReplies().size()) - .reportedCount(comment.getReportedCount()) .isEdited(comment.isEdited()) .createdAt(comment.getCreatedAt()) .lastModifiedAt(comment.getLastModifiedAt()) @@ -202,7 +198,6 @@ public static BestCommentResponse fromEntity(Comment comment, VoteOption voteOpt .likesCount(likesCount) .myLike(myLike) .replyCount(comment.getReplies() == null ? 0 : comment.getReplies().size()) - .reportedCount(comment.getReportedCount()) .isBest(comment.getIsBest()) .isEdited(comment.isEdited()) .createdAt(comment.getCreatedAt()) @@ -278,7 +273,6 @@ public static CommentReplyResponse fromEntity(Comment comment, VoteOption voteOp .myLike(myLike) .parentId(comment.getParent() == null ? null : comment.getParent().getId()) .replyCount(comment.getReplies() == null ? 0 : comment.getReplies().size()) - .reportedCount(comment.getReportedCount()) .isEdited(comment.isEdited()) .createdAt(comment.getCreatedAt()) .lastModifiedAt(comment.getLastModifiedAt()) diff --git a/src/main/java/balancetalk/file/domain/File.java b/src/main/java/balancetalk/file/domain/File.java index a10d2175e..dfbd632f4 100644 --- a/src/main/java/balancetalk/file/domain/File.java +++ b/src/main/java/balancetalk/file/domain/File.java @@ -12,6 +12,7 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Positive; +import jakarta.validation.constraints.Size; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -32,12 +33,15 @@ public class File extends BaseTimeEntity { private Long resourceId; @Enumerated(value = EnumType.STRING) + @NotNull private FileType fileType; @NotBlank + @Size(max = 50) private String uploadName; @NotBlank + @Size(max = 100) private String storedName; @NotBlank diff --git a/src/main/java/balancetalk/game/domain/GameOption.java b/src/main/java/balancetalk/game/domain/GameOption.java index 8614533e0..ece4ee9eb 100644 --- a/src/main/java/balancetalk/game/domain/GameOption.java +++ b/src/main/java/balancetalk/game/domain/GameOption.java @@ -1,5 +1,6 @@ package balancetalk.game.domain; +import balancetalk.global.common.BaseTimeEntity; import balancetalk.vote.domain.GameVote; import balancetalk.vote.domain.VoteOption; import jakarta.persistence.Column; @@ -30,7 +31,7 @@ @Builder @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class GameOption { +public class GameOption extends BaseTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/balancetalk/global/oauth2/CustomSuccessHandler.java b/src/main/java/balancetalk/global/oauth2/CustomSuccessHandler.java index 600e7f59c..7f9a5f23c 100644 --- a/src/main/java/balancetalk/global/oauth2/CustomSuccessHandler.java +++ b/src/main/java/balancetalk/global/oauth2/CustomSuccessHandler.java @@ -9,11 +9,11 @@ import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; import org.springframework.stereotype.Component; -import java.io.IOException; @Component @RequiredArgsConstructor diff --git a/src/main/java/balancetalk/like/domain/Like.java b/src/main/java/balancetalk/like/domain/Like.java index 7f2d06b6d..ce9a53273 100644 --- a/src/main/java/balancetalk/like/domain/Like.java +++ b/src/main/java/balancetalk/like/domain/Like.java @@ -2,9 +2,22 @@ import balancetalk.global.common.BaseTimeEntity; import balancetalk.member.domain.Member; -import jakarta.persistence.*; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import jakarta.validation.constraints.NotNull; -import lombok.*; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; @Entity @Builder @@ -19,6 +32,7 @@ public class Like extends BaseTimeEntity { private Long id; @Enumerated(value = EnumType.STRING) + @NotNull private LikeType likeType; @ManyToOne(fetch = FetchType.LAZY) @@ -28,6 +42,7 @@ public class Like extends BaseTimeEntity { @NotNull private Long resourceId; + @NotNull private Boolean active = true; public void activate() { diff --git a/src/main/java/balancetalk/report/application/ReportCommentService.java b/src/main/java/balancetalk/report/application/ReportCommentService.java index 6f9c91d5f..e10939f01 100644 --- a/src/main/java/balancetalk/report/application/ReportCommentService.java +++ b/src/main/java/balancetalk/report/application/ReportCommentService.java @@ -1,5 +1,10 @@ package balancetalk.report.application; +import static balancetalk.global.exception.ErrorCode.ALREADY_REPORTED_COMMENT; +import static balancetalk.global.exception.ErrorCode.NOT_FOUND_COMMENT; +import static balancetalk.global.exception.ErrorCode.NOT_FOUND_COMMENT_AT_THAT_TALK_PICK; +import static balancetalk.global.exception.ErrorCode.REPORT_MY_COMMENT; + import balancetalk.comment.domain.Comment; import balancetalk.comment.domain.CommentRepository; import balancetalk.global.exception.BalanceTalkException; @@ -14,8 +19,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import static balancetalk.global.exception.ErrorCode.*; - @Service @Transactional @RequiredArgsConstructor @@ -48,7 +51,6 @@ public void createCommentReport(@Valid CreateReportRequest createReportRequest, Report report = createReportRequest.toEntity(reporter, reported, resourceId, comment.getContent()); reportRepository.save(report); - comment.incrementReportCount(); } private Comment validateCommentOnTalkPick(Long resourceId, Long talkPickId) { diff --git a/src/main/java/balancetalk/talkpick/domain/TalkPick.java b/src/main/java/balancetalk/talkpick/domain/TalkPick.java index 240252946..d5d302e52 100644 --- a/src/main/java/balancetalk/talkpick/domain/TalkPick.java +++ b/src/main/java/balancetalk/talkpick/domain/TalkPick.java @@ -6,16 +6,31 @@ import balancetalk.member.domain.Member; import balancetalk.vote.domain.TalkPickVote; import balancetalk.vote.domain.VoteOption; -import jakarta.persistence.*; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.PositiveOrZero; import jakarta.validation.constraints.Size; -import lombok.*; -import org.hibernate.annotations.ColumnDefault; - import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.hibernate.annotations.ColumnDefault; @Entity @Getter diff --git a/src/main/java/balancetalk/talkpick/domain/TempTalkPick.java b/src/main/java/balancetalk/talkpick/domain/TempTalkPick.java index a1f31eaff..4125d189e 100644 --- a/src/main/java/balancetalk/talkpick/domain/TempTalkPick.java +++ b/src/main/java/balancetalk/talkpick/domain/TempTalkPick.java @@ -1,17 +1,27 @@ package balancetalk.talkpick.domain; +import balancetalk.global.common.BaseTimeEntity; import balancetalk.member.domain.Member; -import jakarta.persistence.*; -import jakarta.validation.constraints.NotBlank; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; import jakarta.validation.constraints.Size; -import lombok.*; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; @Entity @Getter @Builder @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class TempTalkPick { +public class TempTalkPick extends BaseTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/balancetalk/vote/domain/GameVote.java b/src/main/java/balancetalk/vote/domain/GameVote.java index c11c12d71..16a36a4ac 100644 --- a/src/main/java/balancetalk/vote/domain/GameVote.java +++ b/src/main/java/balancetalk/vote/domain/GameVote.java @@ -3,8 +3,18 @@ import balancetalk.game.domain.GameOption; import balancetalk.global.common.BaseTimeEntity; import balancetalk.member.domain.Member; -import jakarta.persistence.*; -import lombok.*; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; @Entity @Getter diff --git a/src/main/java/balancetalk/vote/domain/TalkPickVote.java b/src/main/java/balancetalk/vote/domain/TalkPickVote.java index a3a8ad0aa..5017682cc 100644 --- a/src/main/java/balancetalk/vote/domain/TalkPickVote.java +++ b/src/main/java/balancetalk/vote/domain/TalkPickVote.java @@ -3,9 +3,21 @@ import balancetalk.global.common.BaseTimeEntity; import balancetalk.member.domain.Member; import balancetalk.talkpick.domain.TalkPick; -import jakarta.persistence.*; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import jakarta.validation.constraints.NotNull; -import lombok.*; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; @Entity @Getter