我试图弄清楚如何才能找到列表中的成员——但只有那些没有超过过期日期的成员——这是模型的属性之一。
现在我有:
public static Result getAllNotifications() {
List<Notification> notifications = Notification.getAllNotifications();
for (Notification i: notifications) {
List<Attachments> attachments = Attachments.findAllById(i.id);
i.attached = attachments;
}
return ok(toJson(notifications));
}
在那里的某个地方,我需要检查单个通知的到期日期,如果今天已经过了那个日期,就不要退回它。
现在,通知模型如下所示:
public class Notification extends Model {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@NonEmpty
public Long id;
@Constraints.Required
public String title;
@Formats.DateTime(pattern = "dd/MM/yyyy")
public Date created = new Date();
@Constraints.Required
@Column(columnDefinition="TEXT")
public String text;
@Formats.DateTime(pattern = "dd/MM/yyyy")
public Date updated = new Date();
public Boolean status;
public Date expires;
public String author;
public List<Attachments> attached;
public Notification() {
}
public Notification(Long id, String title, String text) {
this.created = new Date();
this.title = title;
this.text = text;
this.id = id;
}
public static Model.Finder<String, Notification> find = new Model.Finder<String, Notification>(String.class, Notification.class);
这是我第一次在 Stackoverflow 上发帖,所以放轻松!并提前感谢您的帮助!