Skip to content
Snippets Groups Projects

Resolve "Notification asking students for feedback"

Files

@@ -22,12 +22,19 @@ import java.util.Objects;
import javax.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.json.JSONObject;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
@Getter
@Setter
@NoArgsConstructor
public class Notification {
public final static String TIME_FORMAT = "dd/MM/yyyy HH:mm";
@@ -51,12 +58,11 @@ public class Notification {
private boolean read;
private String url;
@DateTimeFormat(pattern = TIME_FORMAT)
private LocalDateTime createdAt;
public Notification() {
}
public Notification(User user, Course course, String title, String message, int ttl) {
this.user = user;
this.course = course;
@@ -66,70 +72,22 @@ public class Notification {
this.createdAt = LocalDateTime.now();
}
public Long getId() {
return id;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Course getCourse() {
return course;
}
public void setCourse(Course course) {
this.course = course;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public int getTtl() {
return ttl;
}
public void setTtl(int ttl) {
this.ttl = ttl;
public Notification(User user, Course course, String title, String message, int ttl, String url) {
this(user, course, title, message, ttl);
this.url = url;
}
public boolean isRead() {
return read;
public String getUrl() {
if (this.url == null) {
return "/notification/" + id;
}
return this.url;
}
public boolean isUnread() {
return !isRead();
}
public void setRead(boolean read) {
this.read = read;
}
public LocalDateTime getCreatedAt() {
return createdAt;
}
public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}
public String toJSON() {
return new JSONObject()
.put("title", title)
Loading