-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
252 additions
and
14 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
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 zipdabang.server.domain.enums; | ||
|
||
public enum AlarmType { | ||
|
||
USER, RECIPE,MYPAGE,NOTIFICATION | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/zipdabang/server/domain/inform/AlarmCategory.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,26 @@ | ||
package zipdabang.server.domain.inform; | ||
|
||
import lombok.*; | ||
import org.hibernate.annotations.DynamicInsert; | ||
import org.hibernate.annotations.DynamicUpdate; | ||
import zipdabang.server.domain.enums.AlarmType; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@DynamicInsert | ||
@DynamicUpdate | ||
public class AlarmCategory { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(unique = true) | ||
@Enumerated(EnumType.STRING) | ||
private AlarmType name; | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/zipdabang/server/domain/inform/PushAlarm.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 zipdabang.server.domain.inform; | ||
|
||
import lombok.*; | ||
import org.hibernate.annotations.DynamicInsert; | ||
import org.hibernate.annotations.DynamicUpdate; | ||
import zipdabang.server.domain.common.BaseEntity; | ||
import zipdabang.server.domain.member.Member; | ||
import zipdabang.server.domain.recipe.Recipe; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@DynamicInsert | ||
@DynamicUpdate | ||
public class PushAlarm extends BaseEntity { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String title; | ||
|
||
private String body; | ||
|
||
private Boolean isConfirmed; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "owner_id") | ||
private Member ownerMember; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member targetMember; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "recipe_id") | ||
private Recipe targetRecipe; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "notification_id") | ||
private Notification targetNotification; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "category_id") | ||
private AlarmCategory alarmCategory; | ||
|
||
public void setMember(Member member){ | ||
if (this.ownerMember != null) | ||
this.ownerMember.getPushAlarmList().remove(this); | ||
this.ownerMember = member; | ||
member.getPushAlarmList().add(this); | ||
} | ||
} |
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
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
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
12 changes: 12 additions & 0 deletions
12
src/main/java/zipdabang/server/repository/AlarmRepository/AlarmCategoryRepository.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,12 @@ | ||
package zipdabang.server.repository.AlarmRepository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import zipdabang.server.domain.enums.AlarmType; | ||
import zipdabang.server.domain.inform.AlarmCategory; | ||
|
||
import java.util.Optional; | ||
|
||
public interface AlarmCategoryRepository extends JpaRepository<AlarmCategory, Long> { | ||
|
||
Optional<AlarmCategory> findByName(AlarmType name); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/zipdabang/server/repository/AlarmRepository/PushAlarmRepository.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,12 @@ | ||
package zipdabang.server.repository.AlarmRepository; | ||
|
||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import zipdabang.server.domain.inform.PushAlarm; | ||
import zipdabang.server.domain.member.Member; | ||
|
||
public interface PushAlarmRepository extends JpaRepository<PushAlarm, Long> { | ||
|
||
Page<PushAlarm> findByOwnerMember(Member member, PageRequest pageRequest); | ||
} |
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
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
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
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
Oops, something went wrong.