You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.9 KiB
56 lines
1.9 KiB
package com.example.datacollect.model;
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
public class Article {
|
|
private String title;
|
|
private String url;
|
|
private String content;
|
|
private String author; // 新增:作者
|
|
private LocalDate publishDate; // 新增:发布日期
|
|
|
|
public Article(String title, String url, String content) {
|
|
this(title, url, content, null, null);
|
|
}
|
|
|
|
public Article(String title, String url, String content, String author, LocalDate publishDate) {
|
|
this.title = title;
|
|
this.url = url;
|
|
this.content = content;
|
|
this.author = author;
|
|
this.publishDate = publishDate;
|
|
}
|
|
|
|
// Getters and Setters
|
|
public String getTitle() { return title; }
|
|
public void setTitle(String title) { this.title = title; }
|
|
|
|
public String getUrl() { return url; }
|
|
public void setUrl(String url) { this.url = url; }
|
|
|
|
public String getContent() { return content; }
|
|
public void setContent(String content) { this.content = content; }
|
|
|
|
public String getAuthor() { return author; }
|
|
public void setAuthor(String author) { this.author = author; }
|
|
|
|
public LocalDate getPublishDate() { return publishDate; }
|
|
public void setPublishDate(LocalDate publishDate) { this.publishDate = publishDate; }
|
|
|
|
// 可选:格式化日期字符串的便捷方法
|
|
public String getFormattedPublishDate() {
|
|
if (publishDate == null) return "未知";
|
|
return publishDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Article{"
|
|
+ "title='" + title + '\''
|
|
+ ", url='" + url + '\''
|
|
+ ", author='" + author + '\''
|
|
+ ", publishDate=" + publishDate
|
|
+ '}';
|
|
}
|
|
}
|