style: add some comment.

pull/461/head
ruibaby 2020-01-01 21:24:28 +08:00
parent 9ac31d0b1c
commit 79e66cd3c0
93 changed files with 273 additions and 184 deletions

View File

@ -13,12 +13,10 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import run.halo.app.repository.base.BaseRepositoryImpl;
/**
* <pre>
* Halo run!
* </pre>
* Halo main class.
*
* @author ryanwang
* @date : 2017/11/14
* @date 2017-11-14
*/
@SpringBootApplication
@EnableJpaAuditing

View File

@ -40,7 +40,7 @@ import static run.halo.app.utils.HaloUtils.*;
* Mvc configuration.
*
* @author ryanwang
* @date : 2018/1/2
* @date 2018-01-02
*/
@Slf4j
@Configuration

View File

@ -86,6 +86,7 @@ public class AdminController {
*/
@GetMapping("counts")
@ApiOperation("Gets count info")
@Deprecated
public StatisticDTO getCount() {
return adminService.getCount();
}

View File

@ -38,7 +38,7 @@ import java.util.Set;
* Installation controller.
*
* @author ryanwang
* @date : 2019-03-17
* @date 2019-03-17
*/
@Slf4j
@Controller

View File

@ -16,7 +16,7 @@ import java.util.List;
* Link Controller
*
* @author ryanwang
* @date : 2019/3/21
* @date 2019/3/21
*/
@RestController
@RequestMapping("/api/admin/links")

View File

@ -22,7 +22,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Photo controller
*
* @author ryanwang
* @date : 2019-3-21
* @date 2019-3-21
*/
@RestController
@RequestMapping("/api/admin/photos")

View File

@ -11,7 +11,7 @@ import run.halo.app.service.StatisticService;
/**
* Statistic controller.
*
* @author ryan0up
* @author ryanwang
* @date 2019-12-16
*/
@RestController

View File

@ -20,7 +20,7 @@ import java.util.Set;
* Theme controller.
*
* @author ryanwang
* @date : 2019/3/20
* @date 2019-03-20
*/
@RestController
@RequestMapping("/api/admin/themes")

View File

@ -36,7 +36,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
*
* @author ryanwang
* @author guqing
* @date : 2019-03-17
* @date 2019-03-17
*/
@Slf4j
@Controller

View File

@ -23,7 +23,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Category controller.
*
* @author ryanwang
* @date : 2019/3/20
* @date 2019-03-20
*/
@Controller
@RequestMapping(value = "/categories")

View File

@ -32,7 +32,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
/**
* @author ryanwang
* @date : 2019-03-21
* @date 2019-03-21
*/
@Slf4j
@Controller

View File

@ -25,7 +25,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Blog index page controller
*
* @author ryanwang
* @date : 2019-03-17
* @date 2019-03-17
*/
@Slf4j
@Controller

View File

@ -25,7 +25,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Blog journal page controller
*
* @author ryanwang
* @date : 2019-05-04
* @date 2019-05-04
*/
@Slf4j
@Controller

View File

@ -25,7 +25,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Search controller.
*
* @author ryanwang
* @date : 2019-04-21
* @date 2019-04-21
*/
@Controller
@RequestMapping(value = "/search")

View File

@ -28,7 +28,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Content sheet controller.
*
* @author ryanwang
* @date : 2019-03-21
* @date 2019-03-21
*/
@Controller
public class ContentSheetController {

View File

@ -23,7 +23,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Tag controller.
*
* @author ryanwang
* @date : 2019-03-21
* @date 2019-03-21
*/
@Controller
@RequestMapping(value = "/tags")

View File

@ -20,7 +20,7 @@ import java.io.IOException;
* Main controller.
*
* @author ryanwang
* @date : 2019-04-23
* @date 2019-04-23
*/
@Controller
public class MainController {

View File

@ -29,7 +29,7 @@ import java.util.Map;
* Error page Controller
*
* @author ryanwang
* @date : 2017/12/26
* @date 2017-12-26
*/
@Slf4j
@Controller
@ -44,6 +44,8 @@ public class CommonController extends AbstractErrorController {
private static final String DEFAULT_ERROR_PATH = "common/error/error";
private static final String COULD_NOT_RESOLVE_VIEW_WITH_NAME_PREFIX = "Could not resolve view with name '";
private final ThemeService themeService;
private final ErrorProperties errorProperties;
@ -167,7 +169,7 @@ public class CommonController extends AbstractErrorController {
request.setAttribute("javax.servlet.error.exception", rootCause);
request.setAttribute("javax.servlet.error.message", haloException.getMessage());
}
} else if (StringUtils.startsWithIgnoreCase(throwable.getMessage(), "Could not resolve view with name '")) {
} else if (StringUtils.startsWithIgnoreCase(throwable.getMessage(), COULD_NOT_RESOLVE_VIEW_WITH_NAME_PREFIX)) {
request.setAttribute("javax.servlet.error.status_code", HttpStatus.NOT_FOUND.value());
NotFoundException viewNotFound = new NotFoundException("该路径没有对应的模板");
@ -193,7 +195,7 @@ public class CommonController extends AbstractErrorController {
* @param request the source request
* @return if the stacktrace attribute should be included
*/
protected boolean isIncludeStackTrace(HttpServletRequest request) {
private boolean isIncludeStackTrace(HttpServletRequest request) {
ErrorProperties.IncludeStacktrace include = errorProperties.getIncludeStacktrace();
if (include == ErrorProperties.IncludeStacktrace.ALWAYS) {
return true;

View File

@ -21,6 +21,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Objects;
/**
* @author johnniang
*/
@Aspect
@Component
@Slf4j

View File

@ -10,8 +10,10 @@ import org.springframework.stereotype.Component;
import java.util.List;
/**
* Freemarker template random method.
*
* @author ryanwang
* @date : 2018/12/21
* @date 2018-12-21
*/
@Component
public class RandomMethod implements TemplateMethodModelEx {

View File

@ -17,7 +17,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Freemarker custom tag of category.
*
* @author ryanwang
* @date : 2019/3/22
* @date 2019-03-22
*/
@Component
public class CategoryTagDirective implements TemplateDirectiveModel {

View File

@ -16,7 +16,7 @@ import java.util.Map;
* Freemarker custom tag of comment.
*
* @author ryanwang
* @date : 2019/3/22
* @date 2019-03-22
*/
@Component
public class CommentTagDirective implements TemplateDirectiveModel {

View File

@ -16,7 +16,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Freemarker custom tag of link.
*
* @author ryanwang
* @date : 2019/3/22
* @date 2019-03-22
*/
@Component
public class LinkTagDirective implements TemplateDirectiveModel {

View File

@ -16,7 +16,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Freemarker custom tag of menu.
*
* @author ryanwang
* @date : 2019/3/22
* @date 2019-03-22
*/
@Component
public class MenuTagDirective implements TemplateDirectiveModel {

View File

@ -16,7 +16,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Freemarker custom tag of photo.
*
* @author ryanwang
* @date : 2019/4/21
* @date 2019-04-21
*/
@Component
public class PhotoTagDirective implements TemplateDirectiveModel {

View File

@ -16,7 +16,7 @@ import java.util.Map;
* Freemarker custom tag of post.
*
* @author ryanwang
* @date : 2018/4/26
* @date 2018-04-26
*/
@Component
public class PostTagDirective implements TemplateDirectiveModel {

View File

@ -17,7 +17,7 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
* Freemarker custom tag of tag.
*
* @author ryanwang
* @date : 2019/3/22
* @date 2019-03-22
*/
@Component
public class TagTagDirective implements TemplateDirectiveModel {

View File

@ -56,6 +56,11 @@ public class CommentEventListener {
this.userService = userService;
}
/**
* Received a new new comment event.
*
* @param newEvent new comment event.
*/
@Async
@EventListener
public void handleCommentNewEvent(CommentNewEvent newEvent) {
@ -118,12 +123,11 @@ public class CommentEventListener {
mailService.sendTemplateMail(user.getEmail(), "您的博客有新的评论", data, "common/mail_template/mail_notice.ftl");
}
@Async
@EventListener
public void handleCommentPassEvent(CommentPassEvent passEvent) {
}
/**
* Received a new reply comment event.
*
* @param newEvent reply comment event.
*/
@Async
@EventListener
public void handleCommentReplyEvent(CommentReplyEvent replyEvent) {

View File

@ -1,22 +0,0 @@
package run.halo.app.event.comment;
import org.springframework.lang.NonNull;
/**
* PostComment pass event.
*
* @author johnniang
* @date 19-4-23
*/
public class CommentPassEvent extends CommentBaseEvent {
/**
* Create a new ApplicationEvent.
*
* @param source the object on which the event initially occurred (never {@code null})
* @param commentId comment id
*/
public CommentPassEvent(Object source, @NonNull Long commentId) {
super(source, commentId);
}
}

View File

@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
/**
* @author ryanwang
* @date : 2019/3/14
* @date 2019-3-14
*/
@Component
public class StringToEnumConverterFactory implements ConverterFactory<String, Enum> {

View File

@ -22,7 +22,7 @@ import java.awt.image.BufferedImage;
import java.util.Objects;
/**
* AliYun file handler.
* Ali oss file handler.
*
* @author MyFaith
* @author ryanwang

View File

@ -23,7 +23,7 @@ import java.awt.image.BufferedImage;
import java.util.Objects;
/**
* BaiDuYun file handler.
* Baidu bos file handler.
*
* @author wangya
* @author ryanwang

View File

@ -16,7 +16,7 @@ import static run.halo.app.model.support.HaloConst.FILE_SEPARATOR;
* File handler interface.
*
* @author johnniang
* @date 3/27/19
* @date 2019-03-27
*/
public interface FileHandler {

View File

@ -20,7 +20,7 @@ import java.util.LinkedList;
* File handler manager.
*
* @author johnniang
* @date 3/27/19
* @date 2019-03-27
*/
@Slf4j
@Component

View File

@ -33,7 +33,7 @@ import java.util.Objects;
import static run.halo.app.handler.file.FileHandler.isImageType;
/**
* Qi niu yun file handler.
* Qiniu oss file handler.
*
* @author johnniang
* @author ryanwang

View File

@ -26,7 +26,7 @@ import java.awt.image.BufferedImage;
import java.util.Objects;
/**
* TencentYun file handler.
* Tencent cos file handler.
*
* @author wangya
* @author ryanwang

View File

@ -20,7 +20,7 @@ import java.awt.image.BufferedImage;
import java.util.Objects;
/**
* Up Yun file handler.
* Up oss file handler.
*
* @author johnniang
* @author ryanwang

View File

@ -10,7 +10,7 @@ import java.util.List;
* Theme config resolver interface.
*
* @author johnniang
* @date 4/10/19
* @date 2019-04-10
*/
public interface ThemeConfigResolver {

View File

@ -9,7 +9,7 @@ import java.io.IOException;
* Theme file resolver.
*
* @author johnniang
* @date 4/11/19
* @date 2019-04-11
*/
public interface ThemePropertyResolver {

View File

@ -14,7 +14,7 @@ import java.io.IOException;
* Yaml theme file resolver.
*
* @author johnniang
* @date 4/11/19
* @date 2019-04-11
*/
@Service
public class YamlThemePropertyResolver implements ThemePropertyResolver {

View File

@ -28,7 +28,7 @@ import java.util.Collections;
*
* @author ryanwang
* @author guqing
* @date : 2018-12-05
* @date 2018-12-05
*/
@Slf4j
@Configuration

View File

@ -7,7 +7,7 @@ import run.halo.app.model.enums.Mode;
* Theme controller.
*
* @author ryanwang
* @date : 2019/5/4
* @date 2019/5/4
*/
@Data
public class EnvironmentDTO {

View File

@ -6,7 +6,7 @@ import lombok.Data;
* Theme controller.
*
* @author ryanwang
* @date : 2019/5/4
* @date 2019/5/4
*/
@Data
public class InternalSheetDTO {

View File

@ -8,7 +8,7 @@ import run.halo.app.model.entity.Link;
* Link output dto.
*
* @author ryanwang
* @date : 2019/3/21
* @date 2019/3/21
*/
@Data
public class LinkDTO implements OutputConverter<LinkDTO, Link> {

View File

@ -8,7 +8,7 @@ import java.util.Date;
/**
* @author ryanwang
* @date : 2019/3/21
* @date 2019-03-21
*/
@Data
public class PhotoDTO implements OutputConverter<PhotoDTO, Photo> {

View File

@ -11,7 +11,7 @@ import javax.persistence.*;
* Attachment entity
*
* @author ryanwang
* @date : 2019-03-12
* @date 2019-03-12
*/
@Data
@Entity

View File

@ -7,7 +7,7 @@ import javax.persistence.Entity;
* Journal comment.
*
* @author johnniang
* @date 19-4-25
* @date 2019-04-25
*/
@Entity(name = "JournalComment")
@DiscriminatorValue("2")

View File

@ -10,7 +10,7 @@ import javax.persistence.*;
* Link entity
*
* @author ryanwang
* @date : 2019-03-12
* @date 2019-03-12
*/
@Data
@Entity

View File

@ -10,7 +10,7 @@ import javax.persistence.*;
* Menu entity
*
* @author ryanwang
* @date : 2019-03-12
* @date 2019-03-12
*/
@Data
@Entity

View File

@ -11,7 +11,7 @@ import java.util.Date;
* Photo entity
*
* @author ryanwang
* @date : 2019-03-12
* @date 2019-03-12
*/
@Data
@Entity

View File

@ -10,7 +10,7 @@ import java.util.Objects;
* Post tag entity.
*
* @author ryanwang
* @date : 2019-03-12
* @date 2019-03-12
*/
@Data
@Entity

View File

@ -1,5 +1,7 @@
package run.halo.app.model.entity;
import lombok.EqualsAndHashCode;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
@ -12,5 +14,6 @@ import javax.persistence.Entity;
*/
@Entity(name = "SheetMeta")
@DiscriminatorValue("1")
@EqualsAndHashCode(callSuper = true)
public class SheetMeta extends BaseMeta {
}

View File

@ -10,7 +10,7 @@ import javax.persistence.*;
* Tag entity
*
* @author ryanwang
* @date : 2019-03-12
* @date 2019-03-12
*/
@Data
@Entity

View File

@ -12,7 +12,7 @@ import java.util.Date;
* User entity
*
* @author ryanwang
* @date : 2019-03-12
* @date 2019-03-12
*/
@Data
@Entity

View File

@ -4,7 +4,7 @@ package run.halo.app.model.enums;
* Attach origin.
*
* @author ryanwang
* @date : 2019-03-12
* @date 2019-03-12
*/
public enum AttachmentType implements ValueEnum<Integer> {

View File

@ -4,7 +4,7 @@ package run.halo.app.model.enums;
* Migrate type.
*
* @author ryanwang
* @date : 2019-03-12
* @date 2019-03-12
*/
public enum MigrateType implements ValueEnum<Integer> {

View File

@ -4,7 +4,7 @@ package run.halo.app.model.enums;
* Option Type.
*
* @author ryanwang
* @date : 2019-12-02
* @date 2019-12-02
*/
public enum OptionType implements ValueEnum<Integer> {

View File

@ -11,7 +11,7 @@ import javax.validation.constraints.Size;
* Attachment params.
*
* @author ryanwang
* @date : 2019/04/20
* @date 2019/04/20
*/
@Data
public class AttachmentParam implements InputConverter<Attachment> {

View File

@ -7,7 +7,7 @@ import run.halo.app.model.enums.AttachmentType;
* Attachment query params.
*
* @author ryanwang
* @date : 2019/04/18
* @date 2019/04/18
*/
@Data
public class AttachmentQuery {

View File

@ -7,7 +7,7 @@ import run.halo.app.model.enums.CommentStatus;
* Comment query params.
*
* @author ryanwang
* @date : 2019/04/18
* @date 2019/04/18
*/
@Data
public class CommentQuery {

View File

@ -7,7 +7,7 @@ import run.halo.app.model.enums.JournalType;
* Journal query params.
*
* @author ryanwang
* @date : 2019/04/26
* @date 2019/04/26
*/
@Data
public class JournalQuery {

View File

@ -9,7 +9,7 @@ import javax.validation.constraints.NotBlank;
* Journal query params.
*
* @author ryanwang
* @date : 2019/05/07
* @date 2019/05/07
*/
@Data
public class MailParam {

View File

@ -7,7 +7,7 @@ import run.halo.app.model.enums.OptionType;
* Option query params.
*
* @author ryanwang
* @date : 2019-12-02
* @date 2019-12-02
*/
@Data
public class OptionQuery {

View File

@ -6,7 +6,7 @@ import lombok.Data;
* Photo query params.
*
* @author ryanwang
* @date : 2019/04/25
* @date 2019/04/25
*/
@Data
public class PhotoQuery {

View File

@ -2,7 +2,7 @@ package run.halo.app.model.properties;
/**
* @author ryanwang
* @date : 2019-03-17
* @date 2019-03-17
*/
public enum BlogProperties implements PropertyEnum {

View File

@ -10,7 +10,7 @@ import java.util.Date;
* </pre>
*
* @author ryanwang
* @date : 2018/6/4
* @date 2018/6/4
*/
@Data
@Deprecated

View File

@ -11,7 +11,7 @@ import java.time.Duration;
* </pre>
*
* @author ryanwang
* @date : 2017/12/29
* @date 2017/12/29
*/
public class HaloConst {

View File

@ -8,7 +8,7 @@ import lombok.Data;
* </pre>
*
* @author : Yawn
* @date : 2018/12/3
* @date 2018/12/3
*/
@Data
public class QiNiuPutSet {

View File

@ -10,7 +10,7 @@ import java.util.List;
* Link team vo.
*
* @author ryanwang
* @date : 2019/3/22
* @date 2019/3/22
*/
@Data
@ToString

View File

@ -10,7 +10,7 @@ import java.util.List;
* Menu team vo.
*
* @author ryanwang
* @date : 2019/8/28
* @date 2019/8/28
*/
@Data
@ToString

View File

@ -9,7 +9,7 @@ import java.util.List;
/**
* @author ryanwang
* @date : 2019-04-07
* @date 2019-04-07
*/
@Data
@EqualsAndHashCode(callSuper = true)

View File

@ -10,7 +10,7 @@ import java.util.List;
* Link team vo.
*
* @author ryanwang
* @date : 2019/3/22
* @date 2019/3/22
*/
@Data
@ToString

View File

@ -32,6 +32,12 @@ public interface JournalCommentRepository extends BaseCommentRepository<JournalC
@Override
List<CommentCountProjection> countByPostIds(@NonNull Collection<Integer> postIds);
/**
* Finds direct children count by comment ids.
*
* @param commentIds comment ids must not be null.
* @return a list of CommentChildrenCountProjection
*/
@Query("select new run.halo.app.model.projection.CommentChildrenCountProjection(count(comment.id), comment.parentId) " +
"from JournalComment comment " +
"where comment.parentId in ?1 " +

View File

@ -17,13 +17,39 @@ import java.util.List;
*/
public interface MenuRepository extends BaseRepository<Menu, Integer> {
/**
* Query if the menu name already exists
*
* @param name name must not be null.
* @return true or false
*/
boolean existsByName(@NonNull String name);
/**
* Query if the menu name already exists by id and name.
*
* @param id id must not be null.
* @param name name must not be null.
* @return true or false.
*/
boolean existsByIdNotAndName(@NonNull Integer id, @NonNull String name);
/**
* Finds by menu parent id.
*
* @param id parent id must not be null.
* @return a list of menu.
*/
List<Menu> findByParentId(@NonNull Integer id);
List<Menu> findByTeam(String team, Sort sort);
/**
* Finds by menu team.
*
* @param team team must not be null.
* @param sort sort.
* @return a list of menu
*/
List<Menu> findByTeam(@NonNull String team, Sort sort);
/**
* Find all menu teams.

View File

@ -19,6 +19,12 @@ import java.util.List;
*/
public interface PostCommentRepository extends BaseCommentRepository<PostComment> {
/**
* Count comments by post ids.
*
* @param postIds post id collection must not be null
* @return a list of CommentCountProjection
*/
@Query("select new run.halo.app.model.projection.CommentCountProjection(count(comment.id), comment.postId) " +
"from PostComment comment " +
"where comment.postId in ?1 group by comment.postId")
@ -26,6 +32,12 @@ public interface PostCommentRepository extends BaseCommentRepository<PostComment
@Override
List<CommentCountProjection> countByPostIds(@NonNull Collection<Integer> postIds);
/**
* Finds direct children count by comment ids.
*
* @param commentIds comment ids must not be null.
* @return a list of CommentChildrenCountProjection
*/
@Query("select new run.halo.app.model.projection.CommentChildrenCountProjection(count(comment.id), comment.parentId) " +
"from PostComment comment " +
"where comment.parentId in ?1 " +

View File

@ -14,10 +14,20 @@ import run.halo.app.repository.base.BasePostRepository;
*/
public interface PostRepository extends BasePostRepository<Post>, JpaSpecificationExecutor<Post> {
/**
* Count all post visits.
*
* @return visits.
*/
@Override
@Query("select sum(p.visits) from Post p")
Long countVisit();
/**
* Count all post likes.
*
* @return likes.
*/
@Override
@Query("select sum(p.likes) from Post p")
Long countLike();

View File

@ -19,13 +19,25 @@ import java.util.List;
*/
public interface SheetCommentRepository extends BaseCommentRepository<SheetComment> {
/**
* Count comments by sheet ids.
*
* @param sheetIds sheet id collection must not be null
* @return a list of CommentCountProjection
*/
@Query("select new run.halo.app.model.projection.CommentCountProjection(count(comment.id), comment.postId) " +
"from SheetComment comment " +
"where comment.postId in ?1 group by comment.postId")
@NonNull
@Override
List<CommentCountProjection> countByPostIds(@NonNull Collection<Integer> postIds);
List<CommentCountProjection> countByPostIds(@NonNull Collection<Integer> sheetIds);
/**
* Finds direct children count by comment ids.
*
* @param commentIds comment ids must not be null.
* @return a list of CommentChildrenCountProjection
*/
@Query("select new run.halo.app.model.projection.CommentChildrenCountProjection(count(comment.id), comment.parentId) " +
"from SheetComment comment " +
"where comment.parentId in ?1 " +

View File

@ -16,14 +16,31 @@ import java.util.Optional;
*/
public interface SheetRepository extends BasePostRepository<Sheet> {
/**
* Count all sheet visits.
*
* @return visits.
*/
@Override
@Query("select sum(p.visits) from Sheet p")
Long countVisit();
/**
* Count all sheet likes.
*
* @return likes.
*/
@Override
@Query("select sum(p.likes) from Sheet p")
Long countLike();
/**
* Gets sheet by url and status.
*
* @param url url must not be blank
* @param status status must not be null
* @return an optional of sheet.
*/
@NonNull
@Override
Optional<Sheet> getByUrlAndStatus(@NonNull String url, @NonNull PostStatus status);

View File

@ -25,16 +25,16 @@ public interface TagRepository extends BaseRepository<Tag, Integer> {
/**
* Get tag by slug name
*
* @param slugName slug name
* @return Tag
* @param slugName slug name must not be null.
* @return an optional of slug name.
*/
Optional<Tag> getBySlugName(@NonNull String slugName);
/**
* Get tag by name
*
* @param name name
* @return Tag
* @param name name must not be null.
* @return an optional of tag
*/
Optional<Tag> getByName(@NonNull String name);
}

View File

@ -166,6 +166,12 @@ public interface BaseCommentRepository<COMMENT extends BaseComment> extends Base
Page<COMMENT> findAllByPostIdAndStatusAndParentId(Integer postId, CommentStatus status, Long parentId, Pageable pageable);
/**
* Finds direct children count by comment ids.
*
* @param commentIds comment ids must not be null.
* @return a list of CommentChildrenCountProjection
*/
@Query("select new run.halo.app.model.projection.CommentChildrenCountProjection(count(comment.id), comment.parentId) " +
"from BaseComment comment " +
"where comment.parentId in ?1 " +

View File

@ -18,7 +18,7 @@ import java.util.Optional;
* Base post repository.
*
* @author johnniang
* @date 3/22/19
* @date 2019-03-22
*/
public interface BasePostRepository<POST extends BasePost> extends BaseRepository<POST, Integer> {
@ -108,9 +108,22 @@ public interface BasePostRepository<POST extends BasePost> extends BaseRepositor
*/
long countByStatus(@NonNull PostStatus status);
boolean existsByUrl(@NonNull String title);
/**
* Determine if the url exists.
*
* @param url url must not be null.
* @return true or false.
*/
boolean existsByUrl(@NonNull String url);
boolean existsByIdNotAndUrl(@NonNull Integer id, @NonNull String title);
/**
* Determine if the url exists.
*
* @param id post id must not be null.
* @param url url must not be null.
* @return true or false.
*/
boolean existsByIdNotAndUrl(@NonNull Integer id, @NonNull String url);
/**
* Get post by url
@ -143,7 +156,7 @@ public interface BasePostRepository<POST extends BasePost> extends BaseRepositor
int updateLikes(@Param("likes") long likes, @Param("postId") @NonNull Integer postId);
/**
* Updates post original content/
* Updates post original content.
*
* @param content content could be blank but disallow to be null
* @param postId post id must not be null
@ -153,10 +166,24 @@ public interface BasePostRepository<POST extends BasePost> extends BaseRepositor
@Query("update BasePost p set p.originalContent = :content where p.id = :postId")
int updateOriginalContent(@Param("content") @NonNull String content, @Param("postId") @NonNull Integer postId);
/**
* Updates post status by post id.
*
* @param status post status must not be null.
* @param postId post id must not be null.
* @return updated rows.
*/
@Modifying
@Query("update BasePost p set p.status = :status where p.id = :postId")
int updateStatus(@Param("status") @NonNull PostStatus status, @Param("postId") @NonNull Integer postId);
/**
* Updates post format content by post id.
*
* @param formatContent format content must not be null.
* @param postId post id must not be null.
* @return updated rows.
*/
@Modifying
@Query("update BasePost p set p.formatContent = :formatContent where p.id = :postId")
int updateFormatContent(@Param("formatContent") @NonNull String formatContent, @Param("postId") @NonNull Integer postId);

View File

@ -15,18 +15,18 @@ public class SecurityUtils {
/**
* Access token cache prefix.
*/
public final static String TOKEN_ACCESS_CACHE_PREFIX = "halo.admin.access.token.";
private final static String TOKEN_ACCESS_CACHE_PREFIX = "halo.admin.access.token.";
/**
* Refresh token cache prefix.
*/
public final static String TOKEN_REFRESH_CACHE_PREFIX = "halo.admin.refresh.token.";
private final static String TOKEN_REFRESH_CACHE_PREFIX = "halo.admin.refresh.token.";
public final static String ACCESS_TOKEN_CACHE_PREFIX = "halo.admin.access_token.";
private final static String ACCESS_TOKEN_CACHE_PREFIX = "halo.admin.access_token.";
public final static String REFRESH_TOKEN_CACHE_PREFIX = "halo.admin.refresh_token.";
private final static String REFRESH_TOKEN_CACHE_PREFIX = "halo.admin.refresh_token.";
public final static String TEMP_TOKEN_CACHE_PREFIX = "halo.temp.token.";
private final static String TEMP_TOKEN_CACHE_PREFIX = "halo.temp.token.";
private SecurityUtils() {

View File

@ -19,14 +19,15 @@ import java.util.List;
* Attachment service.
*
* @author johnniang
* @date : 2019-03-14
* @date 2019-03-14
*/
public interface AttachmentService extends CrudService<Attachment, Integer> {
/**
* Pages attachment output dtos.
*
* @param pageable page info must not be null
* @param pageable page info must not be null
* @param attachmentQuery attachment query param.
* @return a page of attachment output dto
*/
@NonNull

View File

@ -16,7 +16,7 @@ import java.util.List;
*
* @author johnniang
* @author ryanwang
* @date : 2019-03-14
* @date 2019-03-14
*/
@Transactional(readOnly = true)
public interface CategoryService extends CrudService<Category, Integer> {

View File

@ -195,24 +195,66 @@ public interface BasePostService<POST extends BasePost> extends CrudService<POST
@NonNull
POST filterIfEncrypt(@NonNull POST post);
/**
* Convert POST to minimal dto.
*
* @param post post must not be null.
* @return minimal dto.
*/
@NonNull
BasePostMinimalDTO convertToMinimal(@NonNull POST post);
/**
* Convert list of POST to minimal dto of list.
*
* @param posts posts must not be null.
* @return a list of minimal dto.
*/
@NonNull
List<BasePostMinimalDTO> convertToMinimal(@Nullable List<POST> posts);
/**
* Convert page of POST to minimal dto of page.
*
* @param postPage postPage must not be null.
* @return a page of minimal dto.
*/
@NonNull
Page<BasePostMinimalDTO> convertToMinimal(@NonNull Page<POST> postPage);
/**
* Convert POST to simple dto.
*
* @param post post must not be null.
* @return simple dto.
*/
@NonNull
BasePostSimpleDTO convertToSimple(@NonNull POST post);
/**
* Convert list of POST to list of simple dto.
*
* @param posts posts must not be null.
* @return a list of simple dto.
*/
@NonNull
List<BasePostSimpleDTO> convertToSimple(@Nullable List<POST> posts);
/**
* Convert page of POST to page of simple dto.
*
* @param postPage postPage must not be null.
* @return a page of simple dto.
*/
@NonNull
Page<BasePostSimpleDTO> convertToSimple(@NonNull Page<POST> postPage);
/**
* Convert POST to detail dto.
*
* @param post post must not be null.
* @return detail dto.
*/
@NonNull
BasePostDetailDTO convertToDetail(@NonNull POST post);

View File

@ -34,7 +34,7 @@ import java.util.stream.Collectors;
*
* @author ryanwang
* @author johnniang
* @date : 2019-03-14
* @date 2019-03-14
*/
@Slf4j
@Service

View File

@ -15,7 +15,6 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import run.halo.app.event.comment.CommentNewEvent;
import run.halo.app.event.comment.CommentPassEvent;
import run.halo.app.event.comment.CommentReplyEvent;
import run.halo.app.exception.BadRequestException;
import run.halo.app.exception.NotFoundException;
@ -342,14 +341,7 @@ public abstract class BaseCommentServiceImpl<COMMENT extends BaseComment> extend
comment.setStatus(status);
// Update comment
COMMENT updatedComment = update(comment);
if (CommentStatus.PUBLISHED.equals(status)) {
// Pass a comment
eventPublisher.publishEvent(new CommentPassEvent(this, commentId));
}
return updatedComment;
return update(comment);
}
@Override

View File

@ -29,7 +29,7 @@ import java.util.stream.Collectors;
*
* @author ryanwang
* @author johnniang
* @date : 2019-03-14
* @date 2019-03-14
*/
@Slf4j
@Service

View File

@ -17,7 +17,7 @@ import static run.halo.app.model.support.HaloConst.FILE_SEPARATOR;
*
* @author ryanwang
* @author johnniang
* @date : 2017/12/22
* @date 2017/12/22
*/
@Slf4j
public class HaloUtils {

View File

@ -32,7 +32,7 @@ import java.util.Map;
* Markdown utils.
*
* @author ryanwang
* @date : 2019/06/27
* @date 2019/06/27
*/
public class MarkdownUtils {

View File

@ -1,15 +0,0 @@
<div class="emailpaged" style="background: #fff;">
<div class="emailcontent" style="width:100%;max-width:720px;text-align: left;margin: 0 auto;padding-top: 20px;padding-bottom: 80px">
<div class="emailtitle" style="border-radius: 5px;border:1px solid #eee;overflow: hidden;">
<h1 style="color:#fff;background: #3798e8;line-height:70px;font-size:24px;font-weight:normal;padding-left:40px;margin:0">
您有新的备份,请按需下载附件。
</h1>
<div class="emailtext" style="background:#fff;padding:20px 32px 40px;">
备份详情:<br />
文件名:${fileName}<br />
备份时间:${createAt?string("yyyy-MM-dd HH:mm")}<br />
文件大小:${size}
</div>
</div>
</div>
</div>

View File

@ -1,21 +0,0 @@
<div class="emailpaged" style="background: #fff;">
<div class="emailcontent" style="width:100%;max-width:720px;text-align: left;margin: 0 auto;padding-top: 20px;padding-bottom: 80px">
<div class="emailtitle" style="border-radius: 5px;border:1px solid #eee;overflow: hidden;">
<h1 style="color:#fff;background: #3798e8;line-height:70px;font-size:24px;font-weight:normal;padding-left:40px;margin:0">
留言审核通过通知
</h1>
<div class="emailtext" style="background:#fff;padding:20px 32px 40px;">
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">您在${blogTitle}《<a href="${pageUrl}">${pageName}</a>》发表的评论:</p>
<p style="color: #6e6e6e;font-size:13px;line-height:24px;padding:10px 20px;background:#f8f8f8;margin:0px">${commentContent}</p>
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">已通过管理员审核并显示。
<br /> 您可在此查看您的评论:
<a href="${pageUrl}">前往查看</a>
</p>
<p style="color: #6e6e6e;font-size:13px;line-height:24px;">(此邮件由系统自动发出, 请勿回复。)</p>
</div>
<p style="color: #6e6e6e;font-size:13px;line-height:24px;text-align:right;padding:0 32px">邮件发自:
<a href="${blogUrl}" style="color:#51a0e3;text-decoration:none">${author}</a>
</p>
</div>
</div>
</div>

View File

@ -1,17 +0,0 @@
package run.halo.app.utils;
import org.junit.Test;
/**
* @author ryanwang
* @date : 2017/12/26
* @version : 1.0
* description:
*/
public class DemoUtilTest {
@Test
public void testZip(){
//ZipUtils.unZip("/Users/ryan0up/Desktop/adminlog.html.zip","/Users/ryan0up/Desktop/");
}
}