mirror of https://github.com/halo-dev/halo
Support journal type.
parent
f99bf401a5
commit
9ae1f739c7
|
@ -52,6 +52,11 @@ public class ThemeController {
|
||||||
return themeService.listThemeFolderBy(themeService.getActivatedThemeId());
|
return themeService.listThemeFolderBy(themeService.getActivatedThemeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("{themeId}/files")
|
||||||
|
public List<ThemeFile> listFiles(@PathVariable("themeId") String themeId){
|
||||||
|
return themeService.listThemeFolderBy(themeId);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("files/content")
|
@GetMapping("files/content")
|
||||||
public BaseResponse<String> getContentBy(@RequestParam(name = "path") String path) {
|
public BaseResponse<String> getContentBy(@RequestParam(name = "path") String path) {
|
||||||
return BaseResponse.ok(HttpStatus.OK.getReasonPhrase(), themeService.getTemplateContent(path));
|
return BaseResponse.ok(HttpStatus.OK.getReasonPhrase(), themeService.getTemplateContent(path));
|
||||||
|
|
|
@ -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 run.halo.app.model.enums.JournalType;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ import javax.persistence.*;
|
||||||
* Journal entity
|
* Journal entity
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @author ryanwang
|
||||||
* @date 3/22/19
|
* @date 3/22/19
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@ -29,6 +31,9 @@ public class Journal extends BaseEntity {
|
||||||
@Column(name = "likes", columnDefinition = "bigint default 0")
|
@Column(name = "likes", columnDefinition = "bigint default 0")
|
||||||
private Long likes;
|
private Long likes;
|
||||||
|
|
||||||
|
@Column(name = "type", columnDefinition = "int default 1")
|
||||||
|
private JournalType type;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prePersist() {
|
public void prePersist() {
|
||||||
super.prePersist();
|
super.prePersist();
|
||||||
|
@ -38,5 +43,10 @@ public class Journal extends BaseEntity {
|
||||||
if (likes == null || likes < 0) {
|
if (likes == null || likes < 0) {
|
||||||
likes = 0L;
|
likes = 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (type == null) {
|
||||||
|
type = JournalType.PUBLIC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package run.halo.app.model.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Journal type.
|
||||||
|
*
|
||||||
|
* @author ryanwnag
|
||||||
|
*/
|
||||||
|
public enum JournalType implements ValueEnum<Integer> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public type.
|
||||||
|
*/
|
||||||
|
PUBLIC(1),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private type.
|
||||||
|
*/
|
||||||
|
PRIVATE(0);
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
|
||||||
|
JournalType(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package run.halo.app.model.params;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import run.halo.app.model.dto.base.InputConverter;
|
import run.halo.app.model.dto.base.InputConverter;
|
||||||
import run.halo.app.model.entity.Journal;
|
import run.halo.app.model.entity.Journal;
|
||||||
|
import run.halo.app.model.enums.JournalType;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
@ -11,6 +12,7 @@ import javax.validation.constraints.Size;
|
||||||
* Journal param.
|
* Journal param.
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
|
* @author ryanwang
|
||||||
* @date 19-4-25
|
* @date 19-4-25
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@ -19,4 +21,6 @@ public class JournalParam implements InputConverter<Journal> {
|
||||||
@NotBlank(message = "内容不能为空")
|
@NotBlank(message = "内容不能为空")
|
||||||
@Size(max = 511, message = "内容的字符长度不能超过 {max}")
|
@Size(max = 511, message = "内容的字符长度不能超过 {max}")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
|
private JournalType type = JournalType.PUBLIC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package run.halo.app.model.params;
|
package run.halo.app.model.params;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import run.halo.app.model.enums.JournalType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Journal query params.
|
* Journal query params.
|
||||||
|
@ -15,4 +16,6 @@ public class JournalQuery {
|
||||||
* Keyword.
|
* Keyword.
|
||||||
*/
|
*/
|
||||||
private String keyword;
|
private String keyword;
|
||||||
|
|
||||||
|
private JournalType type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,10 @@ public class JournalServiceImpl extends AbstractCrudService<Journal, Integer> im
|
||||||
return (Specification<Journal>) (root, query, criteriaBuilder) -> {
|
return (Specification<Journal>) (root, query, criteriaBuilder) -> {
|
||||||
List<Predicate> predicates = new LinkedList<>();
|
List<Predicate> predicates = new LinkedList<>();
|
||||||
|
|
||||||
|
if (journalQuery.getType() != null) {
|
||||||
|
predicates.add(criteriaBuilder.equal(root.get("type"), journalQuery.getType()));
|
||||||
|
}
|
||||||
|
|
||||||
if (journalQuery.getKeyword() != null) {
|
if (journalQuery.getKeyword() != null) {
|
||||||
// Format like condition
|
// Format like condition
|
||||||
String likeCondition = String.format("%%%s%%", StringUtils.strip(journalQuery.getKeyword()));
|
String likeCondition = String.format("%%%s%%", StringUtils.strip(journalQuery.getKeyword()));
|
||||||
|
|
Loading…
Reference in New Issue