Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.backendsystemdesignlab.notification.user.domain;

public enum NotificationChannel {
PUSH,
SMS,
EMAIL
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.backendsystemdesignlab.notification.user.domain;

import jakarta.persistence.*;

@Entity
@Table(
name = "notification_preferences",
uniqueConstraints = {
@UniqueConstraint(
name = "uk_user_channel",
columnNames = {"user_id", "channel"}
)
}
)
public class NotificationPreference {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "user_id")
private User user;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private NotificationChannel channel;

@Column(nullable = false)
private boolean enabled;

protected NotificationPreference() {}

public NotificationPreference(User user, NotificationChannel channel, boolean enabled) {
this.user = user;
this.channel = channel;
this.enabled = enabled;
}

public Long getId() {
return id;
}

public User getUser() {
return user;
}

public NotificationChannel getChannel() {
return channel;
}

public boolean isEnabled() {
return enabled;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.backendsystemdesignlab.notification.user.domain;

public enum Platform {
IOS,
ANDROID
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.backendsystemdesignlab.notification.user.domain;

import jakarta.persistence.*;

@Entity
@Table(name = "users")
public class User {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(length = 255)
private String email;

@Column(length = 30)
private String phoneNumber;

protected User() {}

public User(String email, String phoneNumber) {
this.email = email;
this.phoneNumber = phoneNumber;
}

public Long getId() {
return id;
}

public String getEmail() {
return email;
}
public String getPhoneNumber() {
return phoneNumber;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.backendsystemdesignlab.notification.user.domain;

import jakarta.persistence.*;

@Entity
@Table(name = "user_devices")
public class UserDevice {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "user_id")
private User user;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Platform platform;

@Column(nullable = false, unique = true, length = 512)
private String deviceToken;

@Column(nullable = false)
private boolean active;

protected UserDevice() {}

public UserDevice(User user, Platform platform, String deviceToken) {
this.user = user;
this.platform = platform;
this.deviceToken = deviceToken;
}

public Long getId() {
return id;
}

public User getUser() {
return user;
}
public Platform getPlatform() {
return platform;
}

public String getDeviceToken() {
return deviceToken;
}

public boolean isActive() {
return active;
}
}