-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Follow 서비스 알림 구현 * feat: notification 서비스 구현 * feat: PUSH_SERVICE_CONTENT 멘트 수정 * feat: Notification 엔티티 수정 * fix: 정상적이라면_팔로우가_추가된다 임시 주석 Co-authored-by: uiurihappy <[email protected]>
- Loading branch information
Showing
8 changed files
with
140 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/depromeet/domain/notification/application/NotificationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.depromeet.domain.notification.application; | ||
|
||
import com.depromeet.domain.member.domain.Member; | ||
import com.depromeet.domain.notification.dao.NotificationRepository; | ||
import com.depromeet.domain.notification.domain.Notification; | ||
import com.depromeet.domain.notification.domain.NotificationType; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class NotificationService { | ||
|
||
private final NotificationRepository notificationRepository; | ||
|
||
public void createNotification( | ||
NotificationType notificationType, Member currentMember, Member targetMember) { | ||
Notification notification = | ||
Notification.createNotification(notificationType, currentMember, targetMember); | ||
notificationRepository.save(notification); | ||
} | ||
} |
Empty file.
6 changes: 6 additions & 0 deletions
6
src/main/java/com/depromeet/domain/notification/dao/NotificationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.depromeet.domain.notification.dao; | ||
|
||
import com.depromeet.domain.notification.domain.Notification; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface NotificationRepository extends JpaRepository<Notification, Long> {} |
Empty file.
56 changes: 56 additions & 0 deletions
56
src/main/java/com/depromeet/domain/notification/domain/Notification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.depromeet.domain.notification.domain; | ||
|
||
import com.depromeet.domain.common.model.BaseTimeEntity; | ||
import com.depromeet.domain.member.domain.Member; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.OneToOne; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Notification extends BaseTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "notification_id") | ||
private Long id; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private NotificationType notificationType; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "source_id") | ||
private Member sourceMember; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "target_id") | ||
private Member targetMember; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
private Notification( | ||
NotificationType notificationType, Member sourceMember, Member targetMember) { | ||
this.notificationType = notificationType; | ||
this.sourceMember = sourceMember; | ||
this.targetMember = targetMember; | ||
} | ||
|
||
public static Notification createNotification( | ||
NotificationType notificationType, Member currentMember, Member targetMember) { | ||
return Notification.builder() | ||
.notificationType(notificationType) | ||
.sourceMember(currentMember) | ||
.targetMember(targetMember) | ||
.build(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/depromeet/domain/notification/domain/NotificationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.depromeet.domain.notification.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum NotificationType { | ||
FOLLOW("팔로우"), | ||
; | ||
|
||
private final String value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters