net.guerlab.smart.article.service.entity.Article Maven / Gradle / Ivy
package net.guerlab.smart.article.service.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.guerlab.smart.article.core.domain.ArticleDTO;
import net.guerlab.smart.article.core.eneity.Attachments;
import net.guerlab.smart.article.core.enums.AuditStatus;
import net.guerlab.smart.article.core.enums.PublishType;
import net.guerlab.smart.platform.commons.domain.MultiId;
import net.guerlab.smart.platform.commons.entity.BaseOrderEntity;
import net.guerlab.smart.platform.commons.util.BeanConvertUtils;
import net.guerlab.spring.commons.dto.ConvertDTO;
import org.springframework.beans.BeanUtils;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.time.LocalDateTime;
import java.util.Collection;
/**
* 文章
*
* @author guer
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Table(name = "article_article")
public class Article extends BaseOrderEntity implements ConvertDTO {
/**
* 文章ID
*/
@Id
private Long articleId;
/**
* 唯一key
*/
@Column(name = "uniqueKey", updatable = false)
private String uniqueKey;
/**
* 文章分类ID
*/
@Column(name = "articleCategoryId", nullable = false)
private Long articleCategoryId;
/**
* 文章分类名称
*/
@Column(name = "articleCategoryName", nullable = false)
private String articleCategoryName;
/**
* 文章分类类型
*/
private String articleCategoryType;
/**
* 次要文章分类ID列表
*/
@Column(name = "secondaryArticleCategoryIds", nullable = false)
private MultiId secondaryArticleCategoryIds;
/**
* 文章分类ID列表
*/
@Column(name = "articleCategoryIds", nullable = false)
private MultiId articleCategoryIds;
/**
* 标题
*/
@Column(name = "title", nullable = false)
private String title;
/**
* 封面URL
*/
@Column(name = "coverUrl", nullable = false)
private String coverUrl;
/**
* 是否有封面
*/
@Column(name = "hasCoverUrl", nullable = false)
private Boolean hasCoverUrl;
/**
* 作者
*/
@Column(name = "author", nullable = false)
private String author;
/**
* 发布时间
*/
@Column(name = "releaseTime", nullable = false)
private LocalDateTime releaseTime;
/**
* 简介
*/
@Column(name = "synopsis", nullable = false)
private String synopsis;
/**
* 内容
*/
@Column(name = "content", nullable = false)
private String content;
/**
* 已发布标志
*/
@Column(name = "published", nullable = false)
private Boolean published;
/**
* 原文链接
*/
@Column(name = "originalLink", nullable = false)
private String originalLink;
/**
* 总是跳转标志
*/
@Column(name = "alwaysRedirect", nullable = false)
private Boolean alwaysRedirect;
/**
* 发布方式
*/
@Column(name = "publishType", nullable = false)
private PublishType publishType;
/**
* 计划发布时间
*/
private LocalDateTime planPublishTime;
/**
* 实际发布时间
*/
private LocalDateTime publishTime;
/**
* 新建时间
*/
@Column(name = "createTime", nullable = false, updatable = false)
private LocalDateTime createTime;
/**
* 更新时间
*/
@Column(name = "updateTime", nullable = false)
private LocalDateTime updateTime;
/**
* 附件列表
*/
@Column(name = "attachments", nullable = false)
private Attachments attachments;
/**
* 包含附件标志
*/
@Column(name = "hasAttachment", nullable = false)
private Boolean hasAttachment;
/**
* 审核状态
*/
@Column(name = "auditStatus", nullable = false)
private AuditStatus auditStatus;
/**
* 阅读量
*/
@Column(name = "viewNumber", nullable = false, updatable = false)
private Long viewNumber;
/**
* 文章分类列表
*/
@Transient
private Collection categories;
@Override
public ArticleDTO toDTO() {
ArticleDTO dto = new ArticleDTO();
BeanUtils.copyProperties(this, dto);
dto.setCategories(BeanConvertUtils.toList(this.categories));
return dto;
}
}