feat: create theme content api. (#503)

pull/816/head
Ryan Wang 2020-01-17 12:47:55 +08:00 committed by John Niang
parent 89086dd345
commit bd6cb393ff
27 changed files with 123 additions and 109 deletions

View File

@ -1,8 +1,6 @@
package run.halo.app.controller.content;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.PageUtil;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;

View File

@ -59,7 +59,7 @@ public class ContentContentController {
this.sheetService = sheetService;
}
@GetMapping("{prefix}")
// @GetMapping("{prefix}")
public String content(@PathVariable("prefix") String prefix,
Model model) {
String archivesPrefix = optionService.getByPropertyOrDefault(PermalinkProperties.ARCHIVES_PREFIX, String.class, PermalinkProperties.ARCHIVES_PREFIX.defaultValue());
@ -89,7 +89,7 @@ public class ContentContentController {
}
}
@GetMapping("{prefix}/{url}")
// @GetMapping("{prefix}/{url}")
public String content(@PathVariable("prefix") String prefix,
@PathVariable("url") String url,
@RequestParam(value = "token", required = false) String token,

View File

@ -10,10 +10,10 @@ import run.halo.app.service.PostService;
import java.util.List;
/**
* Archive portal controller.
* Content archive controller.
*
* @author johnniang
* @date 4/2/19
* @date 2019-04-02
*/
@RestController("ApiContentArchiveController")
@RequestMapping("/api/content/archives")

View File

@ -21,10 +21,10 @@ import java.util.List;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* Category portal controller.
* Content category controller.
*
* @author ryanwang
* @date 6/9/19
* @date 2019-06-09
*/
@RestController("ApiContentCategoryController")
@RequestMapping("/api/content/categories")

View File

@ -29,7 +29,7 @@ import java.util.List;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* Content Journal controller.
* Content journal controller.
*
* @author johnniang
* @author ryanwang

View File

@ -15,11 +15,11 @@ import java.util.List;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* Portal link controller.
* Content link controller.
*
* @author johnniang
* @author ryanwang
* @date 4/3/19
* @date 2019-04-03
*/
@RestController("ApiContentLinkController")
@RequestMapping("/api/content/links")

View File

@ -15,11 +15,11 @@ import java.util.List;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* Portal menu controller.
* Content menu controller.
*
* @author johnniang
* @author ryanwang
* @date 4/3/19
* @date 2019-04-03
*/
@RestController("ApiContentMenuController")
@RequestMapping("/api/content/menus")

View File

@ -13,10 +13,10 @@ import java.util.List;
import java.util.Map;
/**
* Portal option controller.
* Content option controller.
*
* @author johnniang
* @date 4/3/19
* @date 2019-04-03
*/
@RestController("ApiContentOptionController")
@RequestMapping("/api/content/options")

View File

@ -26,10 +26,10 @@ import java.util.List;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* Portal post controller.
* Content post controller.
*
* @author johnniang
* @date 4/2/19
* @date 2019-04-02
*/
@RestController("ApiContentPostController")
@RequestMapping("/api/content/posts")

View File

@ -25,11 +25,11 @@ import java.util.List;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* Sheet controller.
* Content sheet controller.
*
* @author johnniang
* @author ryanwang
* @date 19-4-26
* @date 2019-04-26
*/
@RestController("ApiContentSheetController")
@RequestMapping("/api/content/sheets")

View File

@ -9,7 +9,7 @@ import run.halo.app.model.dto.StatisticWithUserDTO;
import run.halo.app.service.StatisticService;
/**
* Statistic controller.
* Content statistic controller.
*
* @author ryan0up
* @date 2019-12-16

View File

@ -22,11 +22,11 @@ import java.util.List;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* Portal tag controller.
* Content tag controller.
*
* @author johnniang
* @author ryanwang
* @date 4/2/19
* @date 2019-04-02
*/
@RestController("ApiContentTagController")
@RequestMapping("/api/content/tags")

View File

@ -0,0 +1,43 @@
package run.halo.app.controller.content.api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import run.halo.app.handler.theme.config.support.ThemeProperty;
import run.halo.app.service.ThemeService;
import run.halo.app.service.ThemeSettingService;
import java.util.Map;
/**
* Content theme controller.
*
* @author ryanwang
* @date 2020-01-17
*/
@RestController("ApiContentThemeController")
@RequestMapping("/api/content/themes")
public class ThemeController {
private final ThemeService themeService;
private final ThemeSettingService themeSettingService;
public ThemeController(ThemeService themeService, ThemeSettingService themeSettingService) {
this.themeService = themeService;
this.themeSettingService = themeSettingService;
}
@GetMapping("activation")
@ApiOperation("Gets activated theme property")
public ThemeProperty getBy() {
return themeService.getThemeOfNonNullBy(themeService.getActivatedThemeId());
}
@GetMapping("activation/settings")
@ApiOperation("Lists activated theme settings")
public Map<String, Object> listSettingsBy() {
return themeSettingService.listAsMapBy(themeService.getActivatedThemeId());
}
}

View File

@ -8,10 +8,10 @@ import run.halo.app.model.dto.UserDTO;
import run.halo.app.service.UserService;
/**
* Portal user controller.
* Content user controller.
*
* @author johnniang
* @date 4/3/19
* @date 2019-04-03
*/
@RestController("ApiContentUserController")
@RequestMapping("/api/content/users")

View File

@ -1,7 +1,6 @@
package run.halo.app.controller.content.model;
import cn.hutool.core.util.PageUtil;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

View File

@ -4,6 +4,7 @@ import lombok.Getter;
/**
*
*
* @author Lei XinXin
* @date 2020/1/5
*/
@ -12,9 +13,11 @@ public enum BanStatusEnum {
/**
*
*/
NORMAL(0),;
NORMAL(0),
;
private int status;
BanStatusEnum(int status) {
this.status = status;
}

View File

@ -21,6 +21,7 @@ public enum CommentViolationTypeEnum {
;
private int type;
CommentViolationTypeEnum(int type) {
this.type = type;
}

View File

@ -32,7 +32,6 @@ public enum CommentProperties implements PropertyEnum {
COMMENT_RANGE("comment_range", Integer.class, "30");
private final String value;
private final Class<?> type;

View File

@ -1,12 +1,13 @@
package run.halo.app.model.vo;
import java.util.Optional;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import run.halo.app.model.entity.Post;
import java.util.Optional;
/**
* AdjacentPost class
*

View File

@ -7,7 +7,6 @@ import run.halo.app.model.projection.CommentChildrenCountProjection;
import run.halo.app.model.projection.CommentCountProjection;
import run.halo.app.repository.base.BaseCommentRepository;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Date;
import java.util.List;

View File

@ -1,8 +1,5 @@
package run.halo.app.repository.base;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
@ -13,6 +10,10 @@ import org.springframework.lang.NonNull;
import run.halo.app.model.entity.BasePost;
import run.halo.app.model.enums.PostStatus;
import java.util.Date;
import java.util.List;
import java.util.Optional;
/**
* Base post repository.
*

View File

@ -4,6 +4,7 @@ import run.halo.app.model.enums.CommentViolationTypeEnum;
/**
* Comment BlackList Service
*
* @author Lei XinXin
* @date 2020/1/3
*/

View File

@ -1,6 +1,5 @@
package run.halo.app.service;
import javax.validation.constraints.NotNull;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
@ -9,13 +8,10 @@ import run.halo.app.model.entity.Post;
import run.halo.app.model.entity.PostMeta;
import run.halo.app.model.enums.PostStatus;
import run.halo.app.model.params.PostQuery;
import run.halo.app.model.vo.AdjacentPostVO;
import run.halo.app.model.vo.ArchiveMonthVO;
import run.halo.app.model.vo.ArchiveYearVO;
import run.halo.app.model.vo.PostDetailVO;
import run.halo.app.model.vo.PostListVO;
import run.halo.app.model.vo.*;
import run.halo.app.service.base.BasePostService;
import javax.validation.constraints.NotNull;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@ -234,6 +230,7 @@ public interface PostService extends BasePostService<Post> {
/**
* Gets pre && next post.
*
* @param currentPost post must not be null
* @return AdjacentPostVO. it contains prePost and nextPost.
* AdjacentPostVO will not be null. But prePost and nextPost may be null.
@ -243,8 +240,9 @@ public interface PostService extends BasePostService<Post> {
/**
* Get Post Pageable default sort
* @Desc contains three parts. First, Top Priority; Second, From Custom index sort; Third, basic id sort
*
* @return
* @Desc contains three parts. First, Top Priority; Second, From Custom index sort; Third, basic id sort
*/
@NotNull
Sort getPostDefaultSort();

View File

@ -1,27 +1,8 @@
package run.halo.app.service.impl;
import static org.springframework.data.domain.Sort.Direction.DESC;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.StrBuilder;
import cn.hutool.core.util.StrUtil;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Subquery;
import javax.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationEventPublisher;
@ -40,39 +21,30 @@ import run.halo.app.event.logger.LogEvent;
import run.halo.app.event.post.PostVisitEvent;
import run.halo.app.exception.NotFoundException;
import run.halo.app.model.dto.BaseMetaDTO;
import run.halo.app.model.dto.post.BasePostMinimalDTO;
import run.halo.app.model.entity.Category;
import run.halo.app.model.entity.Post;
import run.halo.app.model.entity.PostCategory;
import run.halo.app.model.entity.PostComment;
import run.halo.app.model.entity.PostMeta;
import run.halo.app.model.entity.PostTag;
import run.halo.app.model.entity.Tag;
import run.halo.app.model.entity.*;
import run.halo.app.model.enums.LogType;
import run.halo.app.model.enums.PostPermalinkType;
import run.halo.app.model.enums.PostStatus;
import run.halo.app.model.params.PostQuery;
import run.halo.app.model.properties.PermalinkProperties;
import run.halo.app.model.properties.PostProperties;
import run.halo.app.model.vo.AdjacentPostVO;
import run.halo.app.model.vo.ArchiveMonthVO;
import run.halo.app.model.vo.ArchiveYearVO;
import run.halo.app.model.vo.PostDetailVO;
import run.halo.app.model.vo.PostListVO;
import run.halo.app.model.vo.*;
import run.halo.app.repository.PostRepository;
import run.halo.app.service.CategoryService;
import run.halo.app.service.OptionService;
import run.halo.app.service.PostCategoryService;
import run.halo.app.service.PostCommentService;
import run.halo.app.service.PostMetaService;
import run.halo.app.service.PostService;
import run.halo.app.service.PostTagService;
import run.halo.app.service.TagService;
import run.halo.app.service.*;
import run.halo.app.utils.DateUtils;
import run.halo.app.utils.MarkdownUtils;
import run.halo.app.utils.ServiceUtils;
import run.halo.app.utils.SlugUtils;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Subquery;
import javax.validation.constraints.NotNull;
import java.util.*;
import java.util.stream.Collectors;
import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* Post service implementation.
*

View File

@ -6,7 +6,6 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.PageUtil;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;