mirror of https://github.com/halo-dev/halo
Support set thumbnail to category and tag. (#574)
* feat: support set thumbnail to category and tag. * style: reformat code.pull/578/head
parent
b78e2161e5
commit
78c389b2d4
|
@ -7,6 +7,7 @@ import java.lang.annotation.*;
|
|||
|
||||
/**
|
||||
* 该注解可以限制某些条件下禁止访问api
|
||||
*
|
||||
* @author guqing
|
||||
* @date 2020-02-14 13:48
|
||||
*/
|
||||
|
|
|
@ -28,6 +28,8 @@ public class CategoryDTO implements OutputConverter<CategoryDTO, Category> {
|
|||
|
||||
private String description;
|
||||
|
||||
private String thumbnail;
|
||||
|
||||
private Integer parentId;
|
||||
|
||||
private Date createTime;
|
||||
|
|
|
@ -22,6 +22,8 @@ public class TagDTO implements OutputConverter<TagDTO, Tag> {
|
|||
|
||||
private String slugName;
|
||||
|
||||
private String thumbnail;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private String fullPath;
|
||||
|
|
|
@ -10,6 +10,8 @@ import javax.persistence.*;
|
|||
* Category entity.
|
||||
*
|
||||
* @author johnniang
|
||||
* @author ryanwang
|
||||
* @date 2019-03-15
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
|
@ -40,6 +42,12 @@ public class Category extends BaseEntity {
|
|||
@Column(name = "description", columnDefinition = "varchar(100) default ''")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* Cover thumbnail of the category.
|
||||
*/
|
||||
@Column(name = "thumbnail", columnDefinition = "varchar(1023) default ''")
|
||||
private String thumbnail;
|
||||
|
||||
/**
|
||||
* Parent category.
|
||||
*/
|
||||
|
|
|
@ -36,6 +36,12 @@ public class Tag extends BaseEntity {
|
|||
@Column(name = "slug_name", columnDefinition = "varchar(255) not null", unique = true)
|
||||
private String slugName;
|
||||
|
||||
/**
|
||||
* Cover thumbnail of the tag.
|
||||
*/
|
||||
@Column(name = "thumbnail", columnDefinition = "varchar(1023) default ''")
|
||||
private String thumbnail;
|
||||
|
||||
@Override
|
||||
protected void prePersist() {
|
||||
super.prePersist();
|
||||
|
|
|
@ -19,28 +19,19 @@ import javax.validation.constraints.Size;
|
|||
@Data
|
||||
public class CategoryParam implements InputConverter<Category> {
|
||||
|
||||
/**
|
||||
* Category name.
|
||||
*/
|
||||
@NotBlank(message = "分类名称不能为空")
|
||||
@Size(max = 50, message = "分类名称的字符长度不能超过 {max}")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Category slug name.
|
||||
*/
|
||||
@Size(max = 50, message = "分类别名的字符长度不能超过 {max}")
|
||||
private String slugName;
|
||||
|
||||
/**
|
||||
* Category description.
|
||||
*/
|
||||
@Size(max = 100, message = "分类描述的字符长度不能超过 {max}")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* Parent category.
|
||||
*/
|
||||
@Size(max = 1023, message = "封面图链接的字符长度不能超过 {max}")
|
||||
private String thumbnail;
|
||||
|
||||
private Integer parentId = 0;
|
||||
|
||||
@Override
|
||||
|
@ -49,6 +40,20 @@ public class CategoryParam implements InputConverter<Category> {
|
|||
|
||||
slugName = StringUtils.isBlank(slugName) ? SlugUtils.slug(name) : SlugUtils.slug(slugName);
|
||||
|
||||
if (null == thumbnail) {
|
||||
thumbnail = "";
|
||||
}
|
||||
|
||||
return InputConverter.super.convertTo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Category category) {
|
||||
|
||||
if (null == thumbnail) {
|
||||
thumbnail = "";
|
||||
}
|
||||
|
||||
InputConverter.super.update(category);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class PostParam implements InputConverter<Post> {
|
|||
|
||||
private String summary;
|
||||
|
||||
@Size(max = 255, message = "文章缩略图链接的字符长度不能超过 {max}")
|
||||
@Size(max = 1023, message = "封面图链接的字符长度不能超过 {max}")
|
||||
private String thumbnail;
|
||||
|
||||
private Boolean disallowComment = false;
|
||||
|
|
|
@ -38,7 +38,7 @@ public class SheetParam implements InputConverter<Sheet> {
|
|||
|
||||
private String summary;
|
||||
|
||||
@Size(max = 255, message = "页面缩略图链接的字符长度不能超过 {max}")
|
||||
@Size(max = 255, message = "封面图链接的字符长度不能超过 {max}")
|
||||
private String thumbnail;
|
||||
|
||||
private Boolean disallowComment = false;
|
||||
|
|
|
@ -26,11 +26,28 @@ public class TagParam implements InputConverter<Tag> {
|
|||
@Size(max = 255, message = "标签别名的字符长度不能超过 {max}")
|
||||
private String slugName;
|
||||
|
||||
@Size(max = 1023, message = "封面图链接的字符长度不能超过 {max}")
|
||||
private String thumbnail;
|
||||
|
||||
@Override
|
||||
public Tag convertTo() {
|
||||
|
||||
slugName = StringUtils.isBlank(slugName) ? SlugUtils.slug(name) : SlugUtils.slug(slugName);
|
||||
|
||||
if (null == thumbnail) {
|
||||
thumbnail = "";
|
||||
}
|
||||
|
||||
return InputConverter.super.convertTo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tag tag) {
|
||||
|
||||
if (null == thumbnail) {
|
||||
thumbnail = "";
|
||||
}
|
||||
|
||||
InputConverter.super.update(tag);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package run.halo.app.model.support;
|
|||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
|
|
Loading…
Reference in New Issue