Skip to content

Commit

Permalink
rename : Notice -> Notification 네이밍 통일한다.
Browse files Browse the repository at this point in the history
  • Loading branch information
60jong committed Feb 26, 2024
1 parent 4ba7d45 commit 4f8f9d0
Show file tree
Hide file tree
Showing 34 changed files with 205 additions and 235 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package life.offonoff.ab.application.event.topic;

import life.offonoff.ab.application.notice.NoticeService;
import life.offonoff.ab.application.notification.NotificationService;
import life.offonoff.ab.application.service.vote.VotingTopicService;
import life.offonoff.ab.application.service.vote.votingtopic.container.VotingTopic;
import life.offonoff.ab.domain.topic.Topic;
Expand All @@ -23,7 +23,7 @@
public class TopicEventHandler {

private final VotingTopicService votingTopicService;
private final NoticeService noticeService;
private final NotificationService notificationService;

/**
* 투표 생성 이벤트 -> VotingTopicContainer에서 관리 추가
Expand All @@ -42,7 +42,7 @@ public void addTopic(TopicCreateEvent event) {
public void voteClosed(VoteClosedEvent event) {
log.info("# Topic Vote Closed / topic-id : {}, deadline : {}", event.topic().getId(), event.topic().getDeadline());

noticeService.noticeVoteResult(event.result());
notificationService.noticeVoteResult(event.result());
}

/**
Expand All @@ -53,8 +53,8 @@ public void voted(VotedEvent event) {
Topic topic = event.getVote()
.getTopic();

if (noticeService.shouldNoticeVoteCountForTopic(topic)) {
noticeService.noticeVoteCountOnTopic(topic);
if (notificationService.shouldNoticeVoteCountForTopic(topic)) {
notificationService.noticeVoteCountOnTopic(topic);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package life.offonoff.ab.application.notice;
package life.offonoff.ab.application.notification;

import life.offonoff.ab.domain.member.Member;
import life.offonoff.ab.domain.notice.VoteCountOnTopicNotification;
import life.offonoff.ab.domain.notice.VoteResultNotification;
import life.offonoff.ab.domain.notification.VoteCountOnTopicNotification;
import life.offonoff.ab.domain.notification.VoteResultNotification;
import life.offonoff.ab.domain.topic.Topic;
import life.offonoff.ab.domain.vote.VoteResult;
import life.offonoff.ab.repository.member.MemberRepository;
import life.offonoff.ab.repository.notice.NotificationRepository;
import life.offonoff.ab.web.response.notice.NoticeResponse;
import life.offonoff.ab.web.response.notice.message.NoticeMessage;
import life.offonoff.ab.web.response.notice.message.NoticeMessageFactory;
import life.offonoff.ab.web.response.notification.NotificationResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -22,7 +20,7 @@
@Slf4j
@RequiredArgsConstructor
@Service
public class NoticeService {
public class NotificationService {

@Value("${ab.notification.vote_on_topic.count_unit}")
public int voteCountUnit;
Expand Down Expand Up @@ -80,11 +78,11 @@ public void noticeVoteCountOnTopic(Topic topic) {
notificationRepository.save(notification);
}

public List<NoticeResponse> findAllByReceiverId(Long memberId) {
public List<NotificationResponse> findAllByReceiverId(Long memberId) {

return notificationRepository.findAllByReceiverIdOrderByCreatedAtDesc(memberId)
.stream()
.map(NoticeResponse::new)
.map(NotificationResponse::new)
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ private void doHide(final Member member, final Topic topic) {
private void cancelHide(final Member member, final Topic topic) {
member.cancelHideIfExists(topic);
}

//== Vote ==//

@Transactional
public VoteResponse voteForTopicByMember(final Long topicId, final Long memberId, final VoteRequest request) {
Member member = findMember(memberId);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/life/offonoff/ab/domain/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import life.offonoff.ab.domain.comment.Comment;
import life.offonoff.ab.domain.comment.HatedComment;
import life.offonoff.ab.domain.comment.LikedComment;
import life.offonoff.ab.domain.notice.Notification;
import life.offonoff.ab.domain.notification.Notification;
import life.offonoff.ab.domain.topic.Topic;
import life.offonoff.ab.domain.topic.choice.ChoiceOption;
import life.offonoff.ab.domain.topic.hide.HiddenTopic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package life.offonoff.ab.domain.notice;
package life.offonoff.ab.domain.notification;

import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import life.offonoff.ab.domain.member.Member;
import life.offonoff.ab.domain.vote.VoteResult;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static life.offonoff.ab.domain.notice.NotificationType.COMMENT_ON_TOPIC_NOTIFICATION;
import static life.offonoff.ab.domain.notification.NotificationType.COMMENT_ON_TOPIC_NOTIFICATION;
// TODO:수정대상
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package life.offonoff.ab.domain.notice;
package life.offonoff.ab.domain.notification;

import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import life.offonoff.ab.domain.member.Member;
import life.offonoff.ab.domain.topic.Topic;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static life.offonoff.ab.domain.notice.NotificationType.DEFAULT;
import static life.offonoff.ab.domain.notice.NotificationType.VOTE_COUNT_ON_TOPIC_NOTIFICATION;
import static life.offonoff.ab.domain.notification.NotificationType.DEFAULT;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package life.offonoff.ab.domain.notice;
package life.offonoff.ab.domain.notification;

import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import life.offonoff.ab.domain.member.Member;
import life.offonoff.ab.domain.vote.VoteResult;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static life.offonoff.ab.domain.notice.NotificationType.LIKE_IN_COMMENT_NOTIFICATION;
import static life.offonoff.ab.domain.notification.NotificationType.LIKE_IN_COMMENT_NOTIFICATION;
// TODO:수정대상
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package life.offonoff.ab.domain.notice;
package life.offonoff.ab.domain.notification;

import jakarta.persistence.*;
import life.offonoff.ab.domain.BaseEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package life.offonoff.ab.domain.notice;
package life.offonoff.ab.domain.notification;

public class NotificationType {
public static final String DEFAULT = "DEFAULT";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package life.offonoff.ab.domain.notice;
package life.offonoff.ab.domain.notification;

import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import life.offonoff.ab.domain.member.Member;
import life.offonoff.ab.domain.topic.Topic;
import life.offonoff.ab.domain.vote.VoteResult;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static life.offonoff.ab.domain.notice.NotificationType.VOTE_COUNT_ON_TOPIC_NOTIFICATION;
import static life.offonoff.ab.domain.notification.NotificationType.VOTE_COUNT_ON_TOPIC_NOTIFICATION;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package life.offonoff.ab.domain.notice;
package life.offonoff.ab.domain.notification;

import jakarta.persistence.*;
import life.offonoff.ab.domain.member.Member;
Expand All @@ -7,7 +7,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import static life.offonoff.ab.domain.notice.NotificationType.*;
import static life.offonoff.ab.domain.notification.NotificationType.*;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package life.offonoff.ab.repository.notice;

import life.offonoff.ab.domain.notice.VoteResultNotification;
import life.offonoff.ab.domain.notification.VoteResultNotification;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

Expand All @@ -9,7 +9,7 @@
import java.time.LocalDateTime;
import java.util.List;

import static life.offonoff.ab.domain.notice.NotificationType.*;
import static life.offonoff.ab.domain.notification.NotificationType.*;

@Repository
public class NotificationJdbcRepository {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package life.offonoff.ab.repository.notice;

import life.offonoff.ab.domain.notice.Notification;
import life.offonoff.ab.domain.notification.Notification;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package life.offonoff.ab.repository.notice;

import life.offonoff.ab.domain.notice.VoteResultNotification;
import life.offonoff.ab.domain.notification.VoteResultNotification;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package life.offonoff.ab.repository.notice;

import life.offonoff.ab.domain.notice.VoteResultNotification;
import life.offonoff.ab.domain.notification.VoteResultNotification;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package life.offonoff.ab.web;

import life.offonoff.ab.application.notice.NoticeService;
import life.offonoff.ab.application.notification.NotificationService;
import life.offonoff.ab.web.common.aspect.auth.Authorized;
import life.offonoff.ab.web.response.notice.NoticeResponse;
import life.offonoff.ab.web.response.notification.NotificationResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -13,13 +13,13 @@

@RequiredArgsConstructor
@RestController
@RequestMapping("/notices")
public class NoticeController {
@RequestMapping("/notifications")
public class NotificationController {

private final NoticeService noticeService;
private final NotificationService notificationService;

@GetMapping("")
public ResponseEntity<List<NoticeResponse>> getNotices(@Authorized Long memberId) {
return ResponseEntity.ok(noticeService.findAllByReceiverId(memberId));
public ResponseEntity<List<NotificationResponse>> getNotifications(@Authorized Long memberId) {
return ResponseEntity.ok(notificationService.findAllByReceiverId(memberId));
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package life.offonoff.ab.web.response.notification;

import life.offonoff.ab.domain.notification.Notification;
import life.offonoff.ab.web.response.notification.message.NotificationMessage;
import life.offonoff.ab.web.response.notification.message.NotificationMessageFactory;
import lombok.Getter;

@Getter
public class NotificationResponse {

private String type;
private Boolean checked;
private NotificationMessage message;

public NotificationResponse(Notification notification) {
this.type = notification.getType();
this.checked = notification.getChecked();
this.message = NotificationMessageFactory.createNoticeMessage(notification);
}

public NotificationResponse(String type, Boolean checked, NotificationMessage message) {
this.type = type;
this.checked = checked;
this.message = message;
}
}
Loading

0 comments on commit 4f8f9d0

Please sign in to comment.