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