/**
 * 文章数据模型
 */
class Article {
  constructor(id, title, content, cover, summary, createTime) {
    this.id = id;
    this.title = title;
    this.content = content;
    this.cover = cover;
    this.summary = summary || this.generateSummary(content);
    this.createTime = createTime || new Date().getTime();
  }

  // 生成摘要
  generateSummary(content) {
    if (!content) return '';
    return content.substring(0, 100).replace(/<[^>]+>/g, '') + '...';
  }
}

module.exports = {
  Article
}