Skip to content

Commit

Permalink
Merge pull request #63 from EFUB-SURFERS/feature/notice
Browse files Browse the repository at this point in the history
fix : 알림 생성 시간 반환 추가
  • Loading branch information
nammsamm authored Nov 5, 2023
2 parents 17a7fe6 + 452355f commit e46fceb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/efub/bageasy/domain/notice/domain/Notice.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.hibernate.annotations.ColumnDefault;

import javax.persistence.*;
import java.time.LocalDateTime;

@Entity
@AllArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down Expand Up @@ -49,21 +50,25 @@ public class Notice extends BaseTimeEntity {
@Column(name = "is_checked")
private Boolean isChecked;

@Column(name = "created_at")
private LocalDateTime createdAt;

/* 댓글 알림 */
@Builder
public Notice(Long contentId, Long postId, Long postWriterId,Long senderId, Long targetId){
public Notice(Long contentId, Long postId, Long postWriterId,Long senderId, Long targetId , LocalDateTime createdAt){
this.noticeType="comment";
this.contentId = contentId;
this.postId = postId;
this.postWriterId =postWriterId;
this.senderId = senderId;
this.targetId= targetId;
this.isChecked= Boolean.valueOf("false");
this.createdAt = createdAt;
}

/* 대댓글 알림 */
@Builder
public Notice(Long contentId, Long postId, Long postWriterId, Long commentId ,Long senderId, Long targetId){
public Notice(Long contentId, Long postId, Long postWriterId, Long commentId ,Long senderId, Long targetId ,LocalDateTime createdAt){
this.noticeType="reply";
this.contentId = contentId;
this.postId = postId;
Expand All @@ -72,6 +77,7 @@ public Notice(Long contentId, Long postId, Long postWriterId, Long commentId ,Lo
this.senderId = senderId;
this.targetId= targetId;
this.isChecked= Boolean.valueOf("false");
this.createdAt = createdAt;
}

// 알림 확인
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;

@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Builder
Expand All @@ -21,9 +23,10 @@ public class NoticeResponseDto {
private String senderNickname;
private String targetNickname;
private Boolean isChecked;
private LocalDateTime createdAt;

public NoticeResponseDto(Notice notice , String postWriterNickName,String senderNickname
, String targetNickname , String noticeContent ){
, String targetNickname , String noticeContent , LocalDateTime createdAt ){
this.noticeId = notice.getNoticeId();
this.noticeType = notice.getNoticeType();
this.noticeContent = noticeContent;
Expand All @@ -33,6 +36,7 @@ public NoticeResponseDto(Notice notice , String postWriterNickName,String sender
this.senderNickname = senderNickname;
this.targetNickname = targetNickname;
this.isChecked = notice.getIsChecked();
this.createdAt = createdAt;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class NoticeService {
/* 댓글 알림 생성 */
public void createCommentNotice(Member member, Comment comment) {
Post post = postService.findPost(comment.getPostId());
Notice notice = new Notice(comment.getCommentId(),comment.getPostId(), post.getMemberId(),member.getMemberId(), post.getMemberId());
Notice notice = new Notice(comment.getCommentId(),comment.getPostId(),
post.getMemberId(),member.getMemberId(), post.getMemberId() , comment.getCreatedAt());
noticeRepository.save(notice);
}

Expand All @@ -42,7 +43,7 @@ public void createReplyNotice(Member member, Reply reply) {
Comment comment = commentService.findComment(reply.getCommentId());
Post post = postService.findPost(comment.getPostId());
Notice notice = new Notice(reply.getReplyId(),comment.getPostId(),post.getMemberId(),comment.getCommentId(),
member.getMemberId(), comment.getMemberId());
member.getMemberId(), comment.getMemberId(), reply.getCreatedAt());
noticeRepository.save(notice);
}

Expand All @@ -62,9 +63,9 @@ public List<NoticeResponseDto> findNoticeListByMember(Member member) {
else {
noticeContent = replyService.findReply(notice.getContentId()).getContent();
}
responseDtoList.add(new NoticeResponseDto(notice,postWriterNickName,senderNickName,targetNickName,noticeContent));
responseDtoList.add(new NoticeResponseDto(notice,postWriterNickName,senderNickName,
targetNickName,noticeContent , notice.getCreatedAt()));
}

return responseDtoList;
}

Expand Down

0 comments on commit e46fceb

Please sign in to comment.