mirror of https://github.com/halo-dev/halo
refactor: hibernate column build. (#638)
* refactor: hibernate column build. * feat: after the database migration fails, the record table is automatically cleaned up.pull/662/head
parent
7ae722e6fd
commit
c5af5d787d
|
@ -139,7 +139,7 @@ public class LocalFileHandler implements FileHandler {
|
||||||
uploadResult.setSize(file.getSize());
|
uploadResult.setSize(file.getSize());
|
||||||
|
|
||||||
// TODO refactor this: if image is svg ext. extension
|
// TODO refactor this: if image is svg ext. extension
|
||||||
boolean isSvg = "svg" .equals(extension);
|
boolean isSvg = "svg".equals(extension);
|
||||||
|
|
||||||
// Check file type
|
// Check file type
|
||||||
if (FileHandler.isImageType(uploadResult.getMediaType()) && !isSvg) {
|
if (FileHandler.isImageType(uploadResult.getMediaType()) && !isSvg) {
|
||||||
|
|
|
@ -86,6 +86,7 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
||||||
.baselineOnMigrate(true)
|
.baselineOnMigrate(true)
|
||||||
.dataSource(url, username, password)
|
.dataSource(url, username, password)
|
||||||
.load();
|
.load();
|
||||||
|
flyway.repair();
|
||||||
flyway.migrate();
|
flyway.migrate();
|
||||||
log.info("Migrate database succeed.");
|
log.info("Migrate database succeed.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package run.halo.app.model.dto;
|
package run.halo.app.model.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import run.halo.app.model.dto.base.OutputConverter;
|
import run.halo.app.model.dto.base.OutputConverter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,6 +11,7 @@ import run.halo.app.model.dto.base.OutputConverter;
|
||||||
* @date 2019-12-16
|
* @date 2019-12-16
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class StatisticWithUserDTO extends StatisticDTO implements OutputConverter<StatisticWithUserDTO, StatisticDTO> {
|
public class StatisticWithUserDTO extends StatisticDTO implements OutputConverter<StatisticWithUserDTO, StatisticDTO> {
|
||||||
|
|
||||||
private UserDTO user;
|
private UserDTO user;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package run.halo.app.model.entity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.ColumnDefault;
|
||||||
import run.halo.app.model.enums.AttachmentType;
|
import run.halo.app.model.enums.AttachmentType;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
@ -28,61 +29,64 @@ public class Attachment extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Attachment name.
|
* Attachment name.
|
||||||
*/
|
*/
|
||||||
@Column(name = "name", columnDefinition = "varchar(255) not null")
|
@Column(name = "name", nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attachment access path.
|
* Attachment access path.
|
||||||
*/
|
*/
|
||||||
@Column(name = "path", columnDefinition = "varchar(1023) not null")
|
@Column(name = "path", length = 1023, nullable = false)
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File key: oss file key or local file key (Just for deleting)
|
* File key: oss file key or local file key (Just for deleting)
|
||||||
*/
|
*/
|
||||||
@Column(name = "file_key", columnDefinition = "varchar(2047) default ''")
|
@Column(name = "file_key", length = 2047)
|
||||||
private String fileKey;
|
private String fileKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thumbnail access path.
|
* Thumbnail access path.
|
||||||
*/
|
*/
|
||||||
@Column(name = "thumb_path", columnDefinition = "varchar(1023) default ''")
|
@Column(name = "thumb_path", length = 1023)
|
||||||
private String thumbPath;
|
private String thumbPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attachment media type.
|
* Attachment media type.
|
||||||
*/
|
*/
|
||||||
@Column(name = "media_type", columnDefinition = "varchar(127) not null")
|
@Column(name = "media_type", length = 127, nullable = false)
|
||||||
private String mediaType;
|
private String mediaType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attachment suffix,such as png, zip, mp4, jpge.
|
* Attachment suffix,such as png, zip, mp4, jpge.
|
||||||
*/
|
*/
|
||||||
@Column(name = "suffix", columnDefinition = "varchar(50) default ''")
|
@Column(name = "suffix", length = 50)
|
||||||
private String suffix;
|
private String suffix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attachment width.
|
* Attachment width.
|
||||||
*/
|
*/
|
||||||
@Column(name = "width", columnDefinition = "int default 0")
|
@Column(name = "width")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Integer width;
|
private Integer width;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attachment height.
|
* Attachment height.
|
||||||
*/
|
*/
|
||||||
@Column(name = "height", columnDefinition = "int default 0")
|
@Column(name = "height")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Integer height;
|
private Integer height;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attachment size.
|
* Attachment size.
|
||||||
*/
|
*/
|
||||||
@Column(name = "size", columnDefinition = "bigint not null")
|
@Column(name = "size", nullable = false)
|
||||||
private Long size;
|
private Long size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attachment upload type,LOCAL,UPYUN or QNYUN.
|
* Attachment upload type,LOCAL,UPYUN or QNYUN.
|
||||||
*/
|
*/
|
||||||
@Column(name = "type", columnDefinition = "int default 0")
|
@Column(name = "type")
|
||||||
|
@ColumnDefault("0")
|
||||||
private AttachmentType type;
|
private AttachmentType type;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,6 +3,7 @@ package run.halo.app.model.entity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.ColumnDefault;
|
||||||
import run.halo.app.model.enums.CommentStatus;
|
import run.halo.app.model.enums.CommentStatus;
|
||||||
import run.halo.app.utils.ServiceUtils;
|
import run.halo.app.utils.ServiceUtils;
|
||||||
|
|
||||||
|
@ -30,89 +31,90 @@ public class BaseComment extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Commentator's name.
|
* Commentator's name.
|
||||||
*/
|
*/
|
||||||
@Column(name = "author", columnDefinition = "varchar(50) not null")
|
@Column(name = "author", length = 50, nullable = false)
|
||||||
private String author;
|
private String author;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commentator's email.
|
* Commentator's email.
|
||||||
*/
|
*/
|
||||||
@Column(name = "email", columnDefinition = "varchar(255) not null")
|
@Column(name = "email", nullable = false)
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commentator's ip address.
|
* Commentator's ip address.
|
||||||
*/
|
*/
|
||||||
@Column(name = "ip_address", columnDefinition = "varchar(127) default ''")
|
@Column(name = "ip_address", length = 127)
|
||||||
private String ipAddress;
|
private String ipAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commentator's website.
|
* Commentator's website.
|
||||||
*/
|
*/
|
||||||
@Column(name = "author_url", columnDefinition = "varchar(512) default ''")
|
@Column(name = "author_url", length = 511)
|
||||||
private String authorUrl;
|
private String authorUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gravatar md5
|
* Gravatar md5
|
||||||
*/
|
*/
|
||||||
@Column(name = "gravatar_md5", columnDefinition = "varchar(128) default ''")
|
@Column(name = "gravatar_md5", length = 127)
|
||||||
private String gravatarMd5;
|
private String gravatarMd5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment content.
|
* Comment content.
|
||||||
*/
|
*/
|
||||||
@Column(name = "content", columnDefinition = "varchar(1023) not null")
|
@Column(name = "content", length = 1023, nullable = false)
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment status.
|
* Comment status.
|
||||||
*/
|
*/
|
||||||
@Column(name = "status", columnDefinition = "int default 1")
|
@Column(name = "status")
|
||||||
|
@ColumnDefault("1")
|
||||||
private CommentStatus status;
|
private CommentStatus status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commentator's userAgent.
|
* Commentator's userAgent.
|
||||||
*/
|
*/
|
||||||
@Column(name = "user_agent", columnDefinition = "varchar(512) default ''")
|
@Column(name = "user_agent", length = 511)
|
||||||
private String userAgent;
|
private String userAgent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is admin's comment.
|
* Is admin's comment.
|
||||||
*/
|
*/
|
||||||
@Column(name = "is_admin", columnDefinition = "tinyint default 0")
|
@Column(name = "is_admin")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Boolean isAdmin;
|
private Boolean isAdmin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow notification.
|
* Allow notification.
|
||||||
*/
|
*/
|
||||||
@Column(name = "allow_notification", columnDefinition = "tinyint default 1")
|
@Column(name = "allow_notification")
|
||||||
|
@ColumnDefault("1")
|
||||||
private Boolean allowNotification;
|
private Boolean allowNotification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post id.
|
* Post id.
|
||||||
*/
|
*/
|
||||||
@Column(name = "post_id", columnDefinition = "int not null")
|
@Column(name = "post_id", nullable = false)
|
||||||
private Integer postId;
|
private Integer postId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to top the comment.
|
* Whether to top the comment.
|
||||||
*/
|
*/
|
||||||
@Column(name = "top_priority", columnDefinition = "int default 0")
|
@Column(name = "top_priority")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Integer topPriority;
|
private Integer topPriority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent comment.
|
* Parent comment.
|
||||||
*/
|
*/
|
||||||
@Column(name = "parent_id", columnDefinition = "bigint default 0")
|
@Column(name = "parent_id")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prePersist() {
|
public void prePersist() {
|
||||||
super.prePersist();
|
super.prePersist();
|
||||||
|
|
||||||
if (ServiceUtils.isEmptyId(id)) {
|
|
||||||
id = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ServiceUtils.isEmptyId(parentId)) {
|
if (ServiceUtils.isEmptyId(parentId)) {
|
||||||
parentId = 0L;
|
parentId = 0L;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,26 +23,19 @@ public class BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Create time.
|
* Create time.
|
||||||
*/
|
*/
|
||||||
@Column(name = "create_time", columnDefinition = "timestamp default CURRENT_TIMESTAMP")
|
@Column(name = "create_time")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update time.
|
* Update time.
|
||||||
*/
|
*/
|
||||||
@Column(name = "update_time", columnDefinition = "timestamp default CURRENT_TIMESTAMP")
|
@Column(name = "update_time")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete flag.
|
|
||||||
*/
|
|
||||||
@Column(name = "deleted", columnDefinition = "TINYINT default 0")
|
|
||||||
private Boolean deleted = false;
|
|
||||||
|
|
||||||
@PrePersist
|
@PrePersist
|
||||||
protected void prePersist() {
|
protected void prePersist() {
|
||||||
deleted = false;
|
|
||||||
Date now = DateUtils.now();
|
Date now = DateUtils.now();
|
||||||
if (createTime == null) {
|
if (createTime == null) {
|
||||||
createTime = now;
|
createTime = now;
|
||||||
|
|
|
@ -29,18 +29,18 @@ public class BaseMeta extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Post id.
|
* Post id.
|
||||||
*/
|
*/
|
||||||
@Column(name = "post_id", columnDefinition = "int not null")
|
@Column(name = "post_id", nullable = false)
|
||||||
private Integer postId;
|
private Integer postId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta key
|
* meta key
|
||||||
*/
|
*/
|
||||||
@Column(name = "meta_key", columnDefinition = "varchar(100) not null")
|
@Column(name = "meta_key", nullable = false)
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta value
|
* meta value
|
||||||
*/
|
*/
|
||||||
@Column(name = "meta_value", columnDefinition = "varchar(1023) not null")
|
@Column(name = "meta_value", length = 1023, nullable = false)
|
||||||
private String value;
|
private String value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package run.halo.app.model.entity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.ColumnDefault;
|
||||||
import run.halo.app.model.enums.PostEditorType;
|
import run.halo.app.model.enums.PostEditorType;
|
||||||
import run.halo.app.model.enums.PostStatus;
|
import run.halo.app.model.enums.PostStatus;
|
||||||
|
|
||||||
|
@ -30,121 +31,126 @@ public class BasePost extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Post title.
|
* Post title.
|
||||||
*/
|
*/
|
||||||
@Column(name = "title", columnDefinition = "varchar(100) not null")
|
@Column(name = "title", nullable = false)
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post status.
|
* Post status.
|
||||||
*/
|
*/
|
||||||
@Column(name = "status", columnDefinition = "int default 1")
|
@Column(name = "status")
|
||||||
|
@ColumnDefault("1")
|
||||||
private PostStatus status;
|
private PostStatus status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post url.
|
* Post url.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Column(name = "url", columnDefinition = "varchar(255) not null")
|
@Column(name = "url")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post slug.
|
* Post slug.
|
||||||
*/
|
*/
|
||||||
@Column(name = "slug", columnDefinition = "varchar(255)", unique = true)
|
@Column(name = "slug", unique = true)
|
||||||
private String slug;
|
private String slug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post editor type.
|
* Post editor type.
|
||||||
*/
|
*/
|
||||||
@Column(name = "editor_type", columnDefinition = "int default 0")
|
@Column(name = "editor_type")
|
||||||
|
@ColumnDefault("0")
|
||||||
private PostEditorType editorType;
|
private PostEditorType editorType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Original content,not format.
|
* Original content,not format.
|
||||||
*/
|
*/
|
||||||
@Column(name = "original_content", columnDefinition = "longtext not null")
|
@Column(name = "original_content", nullable = false)
|
||||||
|
@Lob
|
||||||
private String originalContent;
|
private String originalContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rendered content.
|
* Rendered content.
|
||||||
*
|
|
||||||
* @see run.halo.app.utils.MarkdownUtils#renderHtml(String)
|
|
||||||
*/
|
*/
|
||||||
@Column(name = "format_content", columnDefinition = "longtext not null")
|
@Column(name = "format_content")
|
||||||
|
@Lob
|
||||||
private String formatContent;
|
private String formatContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post summary.
|
* Post summary.
|
||||||
*/
|
*/
|
||||||
@Column(name = "summary", columnDefinition = "longtext default ''")
|
@Column(name = "summary")
|
||||||
|
@Lob
|
||||||
private String summary;
|
private String summary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cover thumbnail of the post.
|
* Cover thumbnail of the post.
|
||||||
*/
|
*/
|
||||||
@Column(name = "thumbnail", columnDefinition = "varchar(1023) default ''")
|
@Column(name = "thumbnail", length = 1023)
|
||||||
private String thumbnail;
|
private String thumbnail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post visits.
|
* Post visits.
|
||||||
*/
|
*/
|
||||||
@Column(name = "visits", columnDefinition = "bigint default 0")
|
@Column(name = "visits")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Long visits;
|
private Long visits;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to allow comments.
|
* Whether to allow comments.
|
||||||
*/
|
*/
|
||||||
@Column(name = "disallow_comment", columnDefinition = "int default 0")
|
@Column(name = "disallow_comment")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Boolean disallowComment;
|
private Boolean disallowComment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post password.
|
* Post password.
|
||||||
*/
|
*/
|
||||||
@Column(name = "password", columnDefinition = "varchar(255) default ''")
|
@Column(name = "password")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom template.
|
* Custom template.
|
||||||
*/
|
*/
|
||||||
@Column(name = "template", columnDefinition = "varchar(255) default ''")
|
@Column(name = "template")
|
||||||
private String template;
|
private String template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to top the post.
|
* Whether to top the post.
|
||||||
*/
|
*/
|
||||||
@Column(name = "top_priority", columnDefinition = "int default 0")
|
@Column(name = "top_priority")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Integer topPriority;
|
private Integer topPriority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Likes
|
* Likes
|
||||||
*/
|
*/
|
||||||
@Column(name = "likes", columnDefinition = "bigint default 0")
|
@Column(name = "likes")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Long likes;
|
private Long likes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit time.
|
* Edit time.
|
||||||
*/
|
*/
|
||||||
@Column(name = "edit_time", columnDefinition = "timestamp default CURRENT_TIMESTAMP")
|
@Column(name = "edit_time")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date editTime;
|
private Date editTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meta keywords.
|
* Meta keywords.
|
||||||
*/
|
*/
|
||||||
@Column(name = "meta_keywords", columnDefinition = "varchar(500) default ''")
|
@Column(name = "meta_keywords", length = 511)
|
||||||
private String metaKeywords;
|
private String metaKeywords;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meta description.
|
* Meta description.
|
||||||
*/
|
*/
|
||||||
@Column(name = "meta_description", columnDefinition = "varchar(1023) default ''")
|
@Column(name = "meta_description", length = 1023)
|
||||||
private String metaDescription;
|
private String metaDescription;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prePersist() {
|
public void prePersist() {
|
||||||
super.prePersist();
|
super.prePersist();
|
||||||
|
|
||||||
id = null;
|
|
||||||
|
|
||||||
if (editTime == null) {
|
if (editTime == null) {
|
||||||
editTime = getCreateTime();
|
editTime = getCreateTime();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package run.halo.app.model.entity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.ColumnDefault;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
@ -27,44 +28,44 @@ public class Category extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Category name.
|
* Category name.
|
||||||
*/
|
*/
|
||||||
@Column(name = "name", columnDefinition = "varchar(255) not null")
|
@Column(name = "name", nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category slug name.
|
* Category slug name.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Column(name = "slug_name", columnDefinition = "varchar(50) not null", unique = true)
|
@Column(name = "slug_name")
|
||||||
private String slugName;
|
private String slugName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category slug.
|
* Category slug.
|
||||||
*/
|
*/
|
||||||
@Column(name = "slug", columnDefinition = "varchar(255)", unique = true)
|
@Column(name = "slug", unique = true)
|
||||||
private String slug;
|
private String slug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description,can be display on category page.
|
* Description,can be display on category page.
|
||||||
*/
|
*/
|
||||||
@Column(name = "description", columnDefinition = "varchar(100) default ''")
|
@Column(name = "description", length = 100)
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cover thumbnail of the category.
|
* Cover thumbnail of the category.
|
||||||
*/
|
*/
|
||||||
@Column(name = "thumbnail", columnDefinition = "varchar(1023) default ''")
|
@Column(name = "thumbnail", length = 1023)
|
||||||
private String thumbnail;
|
private String thumbnail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent category.
|
* Parent category.
|
||||||
*/
|
*/
|
||||||
@Column(name = "parent_id", columnDefinition = "int default 0")
|
@Column(name = "parent_id")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Integer parentId;
|
private Integer parentId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prePersist() {
|
public void prePersist() {
|
||||||
super.prePersist();
|
super.prePersist();
|
||||||
id = null;
|
|
||||||
|
|
||||||
if (description == null) {
|
if (description == null) {
|
||||||
description = "";
|
description = "";
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class CommentBlackList extends BaseEntity {
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column(name = "ip_address", columnDefinition = "VARCHAR(127) NOT NULL")
|
@Column(name = "ip_address", length = 127, nullable = false)
|
||||||
private String ipAddress;
|
private String ipAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,7 @@ package run.halo.app.model.entity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.ColumnDefault;
|
||||||
import run.halo.app.model.enums.JournalType;
|
import run.halo.app.model.enums.JournalType;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
@ -25,24 +26,26 @@ public class Journal extends BaseEntity {
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@Column(name = "source_content", columnDefinition = "varchar(1023) not null default ''")
|
@Column(name = "source_content", nullable = false)
|
||||||
|
@Lob
|
||||||
private String sourceContent;
|
private String sourceContent;
|
||||||
|
|
||||||
@Column(name = "content", columnDefinition = "text not null")
|
@Column(name = "content", nullable = false)
|
||||||
|
@Lob
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
@Column(name = "likes", columnDefinition = "bigint default 0")
|
@Column(name = "likes")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Long likes;
|
private Long likes;
|
||||||
|
|
||||||
@Column(name = "type", columnDefinition = "int default 1")
|
@Column(name = "type")
|
||||||
|
@ColumnDefault("1")
|
||||||
private JournalType type;
|
private JournalType type;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prePersist() {
|
public void prePersist() {
|
||||||
super.prePersist();
|
super.prePersist();
|
||||||
|
|
||||||
id = null;
|
|
||||||
|
|
||||||
if (likes == null || likes < 0) {
|
if (likes == null || likes < 0) {
|
||||||
likes = 0L;
|
likes = 0L;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package run.halo.app.model.entity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.ColumnDefault;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
@ -27,45 +28,44 @@ public class Link extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Link name.
|
* Link name.
|
||||||
*/
|
*/
|
||||||
@Column(name = "name", columnDefinition = "varchar(255) not null")
|
@Column(name = "name", nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link website address.
|
* Link website address.
|
||||||
*/
|
*/
|
||||||
@Column(name = "url", columnDefinition = "varchar(1023) not null")
|
@Column(name = "url", length = 1023, nullable = false)
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Website logo.
|
* Website logo.
|
||||||
*/
|
*/
|
||||||
@Column(name = "logo", columnDefinition = "varchar(1023) default ''")
|
@Column(name = "logo", length = 1023)
|
||||||
private String logo;
|
private String logo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Website description.
|
* Website description.
|
||||||
*/
|
*/
|
||||||
@Column(name = "description", columnDefinition = "varchar(255) default ''")
|
@Column(name = "description")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link team name.
|
* Link team name.
|
||||||
*/
|
*/
|
||||||
@Column(name = "team", columnDefinition = "varchar(255) default ''")
|
@Column(name = "team")
|
||||||
private String team;
|
private String team;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort.
|
* Sort.
|
||||||
*/
|
*/
|
||||||
@Column(name = "priority", columnDefinition = "int default 0")
|
@Column(name = "priority")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Integer priority;
|
private Integer priority;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prePersist() {
|
public void prePersist() {
|
||||||
super.prePersist();
|
super.prePersist();
|
||||||
|
|
||||||
id = null;
|
|
||||||
|
|
||||||
if (priority == null) {
|
if (priority == null) {
|
||||||
priority = 0;
|
priority = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,32 +27,31 @@ public class Log extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Log key.
|
* Log key.
|
||||||
*/
|
*/
|
||||||
@Column(name = "log_key", columnDefinition = "varchar(1023) default ''")
|
@Column(name = "log_key", length = 1023)
|
||||||
private String logKey;
|
private String logKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log type.
|
* Log type.
|
||||||
*/
|
*/
|
||||||
@Column(name = "type", columnDefinition = "int not null")
|
@Column(name = "type", nullable = false)
|
||||||
private LogType type;
|
private LogType type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log content.
|
* Log content.
|
||||||
*/
|
*/
|
||||||
@Column(name = "content", columnDefinition = "varchar(1023) not null")
|
@Column(name = "content", length = 1023, nullable = false)
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operator's ip address.
|
* Operator's ip address.
|
||||||
*/
|
*/
|
||||||
@Column(name = "ip_address", columnDefinition = "varchar(127) default ''")
|
@Column(name = "ip_address", length = 127)
|
||||||
private String ipAddress;
|
private String ipAddress;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prePersist() {
|
public void prePersist() {
|
||||||
super.prePersist();
|
super.prePersist();
|
||||||
id = null;
|
|
||||||
|
|
||||||
if (logKey == null) {
|
if (logKey == null) {
|
||||||
logKey = "";
|
logKey = "";
|
||||||
|
|
|
@ -3,6 +3,7 @@ package run.halo.app.model.entity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.ColumnDefault;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
@ -27,51 +28,52 @@ public class Menu extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Menu name.
|
* Menu name.
|
||||||
*/
|
*/
|
||||||
@Column(name = "name", columnDefinition = "varchar(50) not null")
|
@Column(name = "name", length = 50, nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Menu access url.
|
* Menu access url.
|
||||||
*/
|
*/
|
||||||
@Column(name = "url", columnDefinition = "varchar(1023) not null")
|
@Column(name = "url", length = 1023, nullable = false)
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort.
|
* Sort.
|
||||||
*/
|
*/
|
||||||
@Column(name = "priority", columnDefinition = "int default 0")
|
@Column(name = "priority")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Integer priority;
|
private Integer priority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page opening method
|
* Page opening method
|
||||||
*/
|
*/
|
||||||
@Column(name = "target", columnDefinition = "varchar(20) default '_self'")
|
@Column(name = "target", length = 20)
|
||||||
|
@ColumnDefault("'_self'")
|
||||||
private String target;
|
private String target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Menu icon,Template support required.
|
* Menu icon,Template support required.
|
||||||
*/
|
*/
|
||||||
@Column(name = "icon", columnDefinition = "varchar(50) default ''")
|
@Column(name = "icon", length = 50)
|
||||||
private String icon;
|
private String icon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent menu.
|
* Parent menu.
|
||||||
*/
|
*/
|
||||||
@Column(name = "parent_id", columnDefinition = "int default 0")
|
@Column(name = "parent_id")
|
||||||
|
@ColumnDefault("0")
|
||||||
private Integer parentId;
|
private Integer parentId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Menu team name.
|
* Menu team name.
|
||||||
*/
|
*/
|
||||||
@Column(name = "team", columnDefinition = "varchar(255) default ''")
|
@Column(name = "team")
|
||||||
private String team;
|
private String team;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prePersist() {
|
public void prePersist() {
|
||||||
super.prePersist();
|
super.prePersist();
|
||||||
|
|
||||||
id = null;
|
|
||||||
|
|
||||||
if (priority == null) {
|
if (priority == null) {
|
||||||
priority = 0;
|
priority = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.hibernate.annotations.ColumnDefault;
|
||||||
import run.halo.app.model.enums.OptionType;
|
import run.halo.app.model.enums.OptionType;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
@ -30,19 +31,20 @@ public class Option extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* option type
|
* option type
|
||||||
*/
|
*/
|
||||||
@Column(name = "type", columnDefinition = "int default 0")
|
@Column(name = "type")
|
||||||
|
@ColumnDefault("0")
|
||||||
private OptionType type;
|
private OptionType type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* option key
|
* option key
|
||||||
*/
|
*/
|
||||||
@Column(name = "option_key", columnDefinition = "varchar(100) not null")
|
@Column(name = "option_key", length = 100, nullable = false)
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* option value
|
* option value
|
||||||
*/
|
*/
|
||||||
@Column(name = "option_value", columnDefinition = "varchar(1023) not null")
|
@Column(name = "option_value", length = 1023, nullable = false)
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public Option(String key, String value) {
|
public Option(String key, String value) {
|
||||||
|
@ -59,7 +61,6 @@ public class Option extends BaseEntity {
|
||||||
@Override
|
@Override
|
||||||
public void prePersist() {
|
public void prePersist() {
|
||||||
super.prePersist();
|
super.prePersist();
|
||||||
id = null;
|
|
||||||
|
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
type = OptionType.INTERNAL;
|
type = OptionType.INTERNAL;
|
||||||
|
|
|
@ -28,50 +28,49 @@ public class Photo extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Picture name.
|
* Picture name.
|
||||||
*/
|
*/
|
||||||
@Column(name = "name", columnDefinition = "varchar(255) not null")
|
@Column(name = "name", nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Picture description.
|
* Picture description.
|
||||||
*/
|
*/
|
||||||
@Column(name = "description", columnDefinition = "varchar(255) default ''")
|
@Column(name = "description")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shooting time / creation time.
|
* Shooting time / creation time.
|
||||||
*/
|
*/
|
||||||
@Column(name = "take_time", columnDefinition = "timestamp default CURRENT_TIMESTAMP")
|
@Column(name = "take_time")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date takeTime;
|
private Date takeTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Picture location.
|
* Picture location.
|
||||||
*/
|
*/
|
||||||
@Column(name = "location", columnDefinition = "varchar(255) default ''")
|
@Column(name = "location")
|
||||||
private String location;
|
private String location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thumbnail
|
* Thumbnail
|
||||||
*/
|
*/
|
||||||
@Column(name = "thumbnail", columnDefinition = "varchar(1023) default ''")
|
@Column(name = "thumbnail", length = 1023)
|
||||||
private String thumbnail;
|
private String thumbnail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Picture access path.
|
* Picture access path.
|
||||||
*/
|
*/
|
||||||
@Column(name = "url", columnDefinition = "varchar(1023) not null")
|
@Column(name = "url", length = 1023, nullable = false)
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Photo team name.
|
* Photo team name.
|
||||||
*/
|
*/
|
||||||
@Column(name = "team", columnDefinition = "varchar(255) default ''")
|
@Column(name = "team")
|
||||||
private String team;
|
private String team;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prePersist() {
|
public void prePersist() {
|
||||||
super.prePersist();
|
super.prePersist();
|
||||||
id = null;
|
|
||||||
|
|
||||||
if (takeTime == null) {
|
if (takeTime == null) {
|
||||||
takeTime = this.getCreateTime();
|
takeTime = this.getCreateTime();
|
||||||
|
|
|
@ -33,13 +33,6 @@ public class PostCategory extends BaseEntity {
|
||||||
@Column(name = "post_id")
|
@Column(name = "post_id")
|
||||||
private Integer postId;
|
private Integer postId;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void prePersist() {
|
|
||||||
super.prePersist();
|
|
||||||
id = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
|
|
|
@ -26,21 +26,15 @@ public class PostTag extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Post id.
|
* Post id.
|
||||||
*/
|
*/
|
||||||
@Column(name = "post_id", columnDefinition = "int not null")
|
@Column(name = "post_id", nullable = false)
|
||||||
private Integer postId;
|
private Integer postId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag id.
|
* Tag id.
|
||||||
*/
|
*/
|
||||||
@Column(name = "tag_id", columnDefinition = "int not null")
|
@Column(name = "tag_id", nullable = false)
|
||||||
private Integer tagId;
|
private Integer tagId;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void prePersist() {
|
|
||||||
super.prePersist();
|
|
||||||
id = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
|
|
|
@ -27,31 +27,25 @@ public class Tag extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Tag name.
|
* Tag name.
|
||||||
*/
|
*/
|
||||||
@Column(name = "name", columnDefinition = "varchar(255) not null")
|
@Column(name = "name", nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag slug name.
|
* Tag slug name.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Column(name = "slug_name", columnDefinition = "varchar(255) not null", unique = true)
|
@Column(name = "slug_name")
|
||||||
private String slugName;
|
private String slugName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag slug.
|
* Tag slug.
|
||||||
*/
|
*/
|
||||||
@Column(name = "slug", columnDefinition = "varchar(255)", unique = true)
|
@Column(name = "slug", unique = true)
|
||||||
private String slug;
|
private String slug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cover thumbnail of the tag.
|
* Cover thumbnail of the tag.
|
||||||
*/
|
*/
|
||||||
@Column(name = "thumbnail", columnDefinition = "varchar(1023) default ''")
|
@Column(name = "thumbnail", length = 1023)
|
||||||
private String thumbnail;
|
private String thumbnail;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void prePersist() {
|
|
||||||
super.prePersist();
|
|
||||||
id = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,25 +26,18 @@ public class ThemeSetting extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* Setting key.
|
* Setting key.
|
||||||
*/
|
*/
|
||||||
@Column(name = "setting_key", columnDefinition = "varchar(255) not null")
|
@Column(name = "setting_key", nullable = false)
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setting value
|
* Setting value
|
||||||
*/
|
*/
|
||||||
@Column(name = "setting_value", columnDefinition = "varchar(10239) not null")
|
@Column(name = "setting_value", nullable = false)
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Theme id.
|
* Theme id.
|
||||||
*/
|
*/
|
||||||
@Column(name = "theme_id", columnDefinition = "varchar(255) not null")
|
@Column(name = "theme_id", nullable = false)
|
||||||
private String themeId;
|
private String themeId;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void prePersist() {
|
|
||||||
super.prePersist();
|
|
||||||
|
|
||||||
id = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,43 +29,43 @@ public class User extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* User name.
|
* User name.
|
||||||
*/
|
*/
|
||||||
@Column(name = "username", columnDefinition = "varchar(50) not null")
|
@Column(name = "username", length = 50, nullable = false)
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User nick name,used to display on page.
|
* User nick name,used to display on page.
|
||||||
*/
|
*/
|
||||||
@Column(name = "nickname", columnDefinition = "varchar(255) not null")
|
@Column(name = "nickname", nullable = false)
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Password.
|
* Password.
|
||||||
*/
|
*/
|
||||||
@Column(name = "password", columnDefinition = "varchar(255) not null")
|
@Column(name = "password", nullable = false)
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User email.
|
* User email.
|
||||||
*/
|
*/
|
||||||
@Column(name = "email", columnDefinition = "varchar(127) default ''")
|
@Column(name = "email", length = 127)
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User avatar.
|
* User avatar.
|
||||||
*/
|
*/
|
||||||
@Column(name = "avatar", columnDefinition = "varchar(1023) default ''")
|
@Column(name = "avatar", length = 1023)
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User description.
|
* User description.
|
||||||
*/
|
*/
|
||||||
@Column(name = "description", columnDefinition = "varchar(1023) default ''")
|
@Column(name = "description", length = 1023)
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expire time.
|
* Expire time.
|
||||||
*/
|
*/
|
||||||
@Column(name = "expire_time", columnDefinition = "timestamp default CURRENT_TIMESTAMP")
|
@Column(name = "expire_time")
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date expireTime;
|
private Date expireTime;
|
||||||
|
|
||||||
|
@ -74,8 +74,6 @@ public class User extends BaseEntity {
|
||||||
public void prePersist() {
|
public void prePersist() {
|
||||||
super.prePersist();
|
super.prePersist();
|
||||||
|
|
||||||
id = null;
|
|
||||||
|
|
||||||
if (email == null) {
|
if (email == null) {
|
||||||
email = "";
|
email = "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.lang.reflect.ParameterizedType;
|
||||||
@Data
|
@Data
|
||||||
public abstract class BaseMetaParam<META> implements InputConverter<META> {
|
public abstract class BaseMetaParam<META> implements InputConverter<META> {
|
||||||
|
|
||||||
@NotBlank(message = "文章id不能为空")
|
@NotBlank(message = "文章 id 不能为空")
|
||||||
private Integer postId;
|
private Integer postId;
|
||||||
|
|
||||||
@NotBlank(message = "Meta key 不能为空")
|
@NotBlank(message = "Meta key 不能为空")
|
||||||
|
|
|
@ -21,6 +21,7 @@ import run.halo.app.model.dto.BackupDTO;
|
||||||
import run.halo.app.model.dto.post.BasePostDetailDTO;
|
import run.halo.app.model.dto.post.BasePostDetailDTO;
|
||||||
import run.halo.app.model.entity.Post;
|
import run.halo.app.model.entity.Post;
|
||||||
import run.halo.app.model.entity.Tag;
|
import run.halo.app.model.entity.Tag;
|
||||||
|
import run.halo.app.model.enums.PostStatus;
|
||||||
import run.halo.app.model.support.HaloConst;
|
import run.halo.app.model.support.HaloConst;
|
||||||
import run.halo.app.security.service.OneTimeTokenService;
|
import run.halo.app.security.service.OneTimeTokenService;
|
||||||
import run.halo.app.service.BackupService;
|
import run.halo.app.service.BackupService;
|
||||||
|
@ -137,7 +138,7 @@ public class BackupServiceImpl implements BackupService {
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(post.getPassword())) {
|
if (StringUtils.isNotBlank(post.getPassword())) {
|
||||||
passwords.add(one);
|
passwords.add(one);
|
||||||
} else if (post.getDeleted()) {
|
} else if (post.getStatus() == PostStatus.DRAFT) {
|
||||||
drafts.add(one);
|
drafts.add(one);
|
||||||
} else {
|
} else {
|
||||||
posts.add(one);
|
posts.add(one);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
update posts set `slug`=`url`;
|
update posts set `slug`=`url`;
|
||||||
alter table posts modify slug varchar(255) not null;
|
alter table posts modify slug varchar(255) not null;
|
||||||
alter table posts modify url varchar(255) null;
|
alter table posts modify url varchar(255) null;
|
||||||
alter table posts modify summary longtext default '';
|
alter table posts modify summary longtext;
|
||||||
|
|
||||||
-- Migrate categories Table
|
-- Migrate categories Table
|
||||||
update categories set `slug`=`slug_name`;
|
update categories set `slug`=`slug_name`;
|
||||||
|
|
Loading…
Reference in New Issue