diff --git a/build.gradle b/build.gradle index 5ac2a52e1..4c0a5c554 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { - id 'org.springframework.boot' version '2.1.7.RELEASE' + id 'org.springframework.boot' version '2.2.0.RELEASE' id "io.freefair.lombok" version "3.6.6" -// id 'war' + id 'war' id 'java' } diff --git a/src/main/java/run/halo/app/controller/admin/api/TraceController.java b/src/main/java/run/halo/app/controller/admin/api/TraceController.java index 147e2a111..f2fed933e 100644 --- a/src/main/java/run/halo/app/controller/admin/api/TraceController.java +++ b/src/main/java/run/halo/app/controller/admin/api/TraceController.java @@ -1,34 +1,34 @@ -package run.halo.app.controller.admin.api; - -import io.swagger.annotations.ApiOperation; -import org.springframework.boot.actuate.trace.http.HttpTrace; -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.service.TraceService; - -import java.util.List; - -/** - * Trace controller. - * - * @author johnniang - * @date 19-6-18 - */ -@RestController -@RequestMapping("/api/admin/traces") -public class TraceController { - - private final TraceService traceService; - - public TraceController(TraceService traceService) { - this.traceService = traceService; - } - - @GetMapping - @ApiOperation("Lists http traces") - public List listHttpTraces() { - return traceService.listHttpTraces(); - } - -} +//package run.halo.app.controller.admin.api; +// +//import io.swagger.annotations.ApiOperation; +//import org.springframework.boot.actuate.trace.http.HttpTrace; +//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.service.TraceService; +// +//import java.util.List; +// +///** +// * Trace controller. +// * +// * @author johnniang +// * @date 19-6-18 +// */ +//@RestController +//@RequestMapping("/api/admin/traces") +//public class TraceController { +// +// private final TraceService traceService; +// +// public TraceController(TraceService traceService) { +// this.traceService = traceService; +// } +// +// @GetMapping +// @ApiOperation("Lists http traces") +// public List listHttpTraces() { +// return traceService.listHttpTraces(); +// } +// +//} diff --git a/src/main/java/run/halo/app/repository/CategoryRepository.java b/src/main/java/run/halo/app/repository/CategoryRepository.java index f01e079ee..86f330a82 100644 --- a/src/main/java/run/halo/app/repository/CategoryRepository.java +++ b/src/main/java/run/halo/app/repository/CategoryRepository.java @@ -48,6 +48,7 @@ public interface CategoryRepository extends BaseRepository { /** * List categories by parent id. + * * @param id parent id. * @return list of category */ diff --git a/src/main/java/run/halo/app/repository/JournalCommentRepository.java b/src/main/java/run/halo/app/repository/JournalCommentRepository.java index 737ff89a8..44fe68818 100644 --- a/src/main/java/run/halo/app/repository/JournalCommentRepository.java +++ b/src/main/java/run/halo/app/repository/JournalCommentRepository.java @@ -7,22 +7,30 @@ import run.halo.app.model.projection.CommentChildrenCountProjection; import run.halo.app.model.projection.CommentCountProjection; import run.halo.app.repository.base.BaseCommentRepository; +import java.util.Collection; import java.util.List; /** * Journal comment repository. * * @author johnniang - * @date 19-4-24 + * @author ryanwang + * @date 2019-04-24 */ public interface JournalCommentRepository extends BaseCommentRepository { + /** + * Count the number of comments by post id. + * + * @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 JournalComment comment " + "where comment.postId in ?1 group by comment.postId") @NonNull @Override - List countByPostIds(@NonNull Iterable postIds); + List countByPostIds(@NonNull Collection postIds); @Query("select new run.halo.app.model.projection.CommentChildrenCountProjection(count(comment.id), comment.parentId) " + "from JournalComment comment " + @@ -30,5 +38,5 @@ public interface JournalCommentRepository extends BaseCommentRepository findDirectChildrenCount(@NonNull Iterable commentIds); + List findDirectChildrenCount(@NonNull Collection commentIds); } diff --git a/src/main/java/run/halo/app/repository/PostCategoryRepository.java b/src/main/java/run/halo/app/repository/PostCategoryRepository.java index c3da9cefd..a0fb5ba12 100644 --- a/src/main/java/run/halo/app/repository/PostCategoryRepository.java +++ b/src/main/java/run/halo/app/repository/PostCategoryRepository.java @@ -7,6 +7,7 @@ import run.halo.app.model.enums.PostStatus; import run.halo.app.model.projection.CategoryPostCountProjection; import run.halo.app.repository.base.BaseRepository; +import java.util.Collection; import java.util.List; import java.util.Set; @@ -58,7 +59,7 @@ public interface PostCategoryRepository extends BaseRepository findAllByPostIdIn(@NonNull Iterable postIds); + List findAllByPostIdIn(@NonNull Collection postIds); /** * Finds all post categories by post id. diff --git a/src/main/java/run/halo/app/repository/PostCommentRepository.java b/src/main/java/run/halo/app/repository/PostCommentRepository.java index 22c2500af..3e4d7543d 100644 --- a/src/main/java/run/halo/app/repository/PostCommentRepository.java +++ b/src/main/java/run/halo/app/repository/PostCommentRepository.java @@ -7,13 +7,15 @@ import run.halo.app.model.projection.CommentChildrenCountProjection; import run.halo.app.model.projection.CommentCountProjection; import run.halo.app.repository.base.BaseCommentRepository; +import java.util.Collection; import java.util.List; /** * PostComment repository. * * @author johnniang - * @date 3/21/19 + * @author ryanwang + * @date 2019-03-21 */ public interface PostCommentRepository extends BaseCommentRepository { @@ -22,7 +24,7 @@ public interface PostCommentRepository extends BaseCommentRepository countByPostIds(@NonNull Iterable postIds); + List countByPostIds(@NonNull Collection postIds); @Query("select new run.halo.app.model.projection.CommentChildrenCountProjection(count(comment.id), comment.parentId) " + "from PostComment comment " + @@ -30,5 +32,5 @@ public interface PostCommentRepository extends BaseCommentRepository findDirectChildrenCount(@NonNull Iterable commentIds); + List findDirectChildrenCount(@NonNull Collection commentIds); } diff --git a/src/main/java/run/halo/app/repository/PostTagRepository.java b/src/main/java/run/halo/app/repository/PostTagRepository.java index 1c5451ecd..24ca52cec 100644 --- a/src/main/java/run/halo/app/repository/PostTagRepository.java +++ b/src/main/java/run/halo/app/repository/PostTagRepository.java @@ -7,6 +7,7 @@ import run.halo.app.model.enums.PostStatus; import run.halo.app.model.projection.TagPostPostCountProjection; import run.halo.app.repository.base.BaseRepository; +import java.util.Collection; import java.util.List; import java.util.Set; @@ -76,7 +77,7 @@ public interface PostTagRepository extends BaseRepository { * @return a list of post tags */ @NonNull - List findAllByPostIdIn(@NonNull Iterable postIds); + List findAllByPostIdIn(@NonNull Collection postIds); /** * Deletes post tags by post id. @@ -104,7 +105,7 @@ public interface PostTagRepository extends BaseRepository { */ @Query("select new run.halo.app.model.projection.TagPostPostCountProjection(count(pt.postId), pt.tagId) from PostTag pt where pt.tagId in ?1 group by pt.tagId") @NonNull - List findPostCountByTagIds(@NonNull Iterable tagIds); + List findPostCountByTagIds(@NonNull Collection tagIds); /** * Finds post count of tag. diff --git a/src/main/java/run/halo/app/repository/SheetCommentRepository.java b/src/main/java/run/halo/app/repository/SheetCommentRepository.java index 4a858c768..2b6d4d32e 100644 --- a/src/main/java/run/halo/app/repository/SheetCommentRepository.java +++ b/src/main/java/run/halo/app/repository/SheetCommentRepository.java @@ -7,13 +7,15 @@ import run.halo.app.model.projection.CommentChildrenCountProjection; import run.halo.app.model.projection.CommentCountProjection; import run.halo.app.repository.base.BaseCommentRepository; +import java.util.Collection; import java.util.List; /** * Sheet comment repository. * * @author johnniang - * @date 19-4-24 + * @author ryanwang + * @date 2019-04-24 */ public interface SheetCommentRepository extends BaseCommentRepository { @@ -22,7 +24,7 @@ public interface SheetCommentRepository extends BaseCommentRepository countByPostIds(@NonNull Iterable postIds); + List countByPostIds(@NonNull Collection postIds); @Query("select new run.halo.app.model.projection.CommentChildrenCountProjection(count(comment.id), comment.parentId) " + "from SheetComment comment " + @@ -30,5 +32,5 @@ public interface SheetCommentRepository extends BaseCommentRepository findDirectChildrenCount(@NonNull Iterable commentIds); + List findDirectChildrenCount(@NonNull Collection commentIds); } diff --git a/src/main/java/run/halo/app/repository/TagRepository.java b/src/main/java/run/halo/app/repository/TagRepository.java index 77ac094c3..b25f2433f 100644 --- a/src/main/java/run/halo/app/repository/TagRepository.java +++ b/src/main/java/run/halo/app/repository/TagRepository.java @@ -32,6 +32,7 @@ public interface TagRepository extends BaseRepository { /** * Get tag by name + * * @param name name * @return Tag */ diff --git a/src/main/java/run/halo/app/repository/base/BaseCommentRepository.java b/src/main/java/run/halo/app/repository/base/BaseCommentRepository.java index 524508f01..a31f832ee 100644 --- a/src/main/java/run/halo/app/repository/base/BaseCommentRepository.java +++ b/src/main/java/run/halo/app/repository/base/BaseCommentRepository.java @@ -12,13 +12,15 @@ import run.halo.app.model.enums.CommentStatus; import run.halo.app.model.projection.CommentChildrenCountProjection; import run.halo.app.model.projection.CommentCountProjection; +import java.util.Collection; import java.util.List; /** * Base comment repository. * * @author johnniang - * @date 19-4-24 + * @author ryanwang + * @date 2019-04-24 */ @NoRepositoryBean public interface BaseCommentRepository extends BaseRepository, JpaSpecificationExecutor { @@ -41,7 +43,7 @@ public interface BaseCommentRepository extends Base * @return a list of comment */ @NonNull - List findAllByPostIdIn(@NonNull Iterable postIds); + List findAllByPostIdIn(@NonNull Collection postIds); /** * Finds all comments by post id. @@ -63,7 +65,7 @@ public interface BaseCommentRepository extends Base "where comment.postId in ?1 " + "group by comment.postId") @NonNull - List countByPostIds(@NonNull Iterable postIds); + List countByPostIds(@NonNull Collection postIds); /** * Counts by comment status. @@ -113,7 +115,7 @@ public interface BaseCommentRepository extends Base * @return a list of comment */ @NonNull - List findAllByStatusAndParentIdIn(@NonNull CommentStatus status, @NonNull Iterable parentIds); + List findAllByStatusAndParentIdIn(@NonNull CommentStatus status, @NonNull Collection parentIds); /** * Finds comments by post id, comment status and parent id. @@ -133,5 +135,5 @@ public interface BaseCommentRepository extends Base "where comment.parentId in ?1 " + "group by comment.parentId") @NonNull - List findDirectChildrenCount(@NonNull Iterable commentIds); + List findDirectChildrenCount(@NonNull Collection commentIds); } diff --git a/src/main/java/run/halo/app/repository/base/BaseRepository.java b/src/main/java/run/halo/app/repository/base/BaseRepository.java index 91948a579..cdcf079ef 100644 --- a/src/main/java/run/halo/app/repository/base/BaseRepository.java +++ b/src/main/java/run/halo/app/repository/base/BaseRepository.java @@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.repository.NoRepositoryBean; import org.springframework.lang.NonNull; +import java.util.Collection; import java.util.List; /** @@ -15,6 +16,8 @@ import java.util.List; * @param doamin type * @param id type * @author johnniang + * @author ryanwang + * @date 2019-03-15 */ @NoRepositoryBean public interface BaseRepository extends JpaRepository { @@ -27,7 +30,7 @@ public interface BaseRepository extends JpaRepository { * @return a list of domains */ @NonNull - List findAllByIdIn(@NonNull Iterable ids, @NonNull Sort sort); + List findAllByIdIn(@NonNull Collection ids, @NonNull Sort sort); /** * Finds all domain by domain id list. @@ -37,7 +40,7 @@ public interface BaseRepository extends JpaRepository { * @return a list of domains */ @NonNull - Page findAllByIdIn(@NonNull Iterable ids, @NonNull Pageable pageable); + Page findAllByIdIn(@NonNull Collection ids, @NonNull Pageable pageable); /** * Deletes by id list. @@ -45,6 +48,6 @@ public interface BaseRepository extends JpaRepository { * @param ids id list of domain must not be null * @return number of rows affected */ - long deleteByIdIn(@NonNull Iterable ids); + long deleteByIdIn(@NonNull Collection ids); } diff --git a/src/main/java/run/halo/app/repository/base/BaseRepositoryImpl.java b/src/main/java/run/halo/app/repository/base/BaseRepositoryImpl.java index 1f933f506..a426ba9de 100644 --- a/src/main/java/run/halo/app/repository/base/BaseRepositoryImpl.java +++ b/src/main/java/run/halo/app/repository/base/BaseRepositoryImpl.java @@ -17,6 +17,7 @@ import javax.persistence.EntityManager; import javax.persistence.TypedQuery; import javax.persistence.criteria.*; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; @@ -26,6 +27,8 @@ import java.util.List; * @param domain type * @param id type * @author johnniang + * @author ryanwang + * @date 2019-03-15 */ @Slf4j public class BaseRepositoryImpl extends SimpleJpaRepository implements BaseRepository { @@ -68,8 +71,8 @@ public class BaseRepositoryImpl extends SimpleJpaRepository findAllByIdIn(Iterable ids, Sort sort) { - Assert.notNull(ids, "The given Iterable of Id's must not be null!"); + public List findAllByIdIn(Collection ids, Sort sort) { + Assert.notNull(ids, "The given Collection of Id's must not be null!"); Assert.notNull(sort, "Sort info must nto be null"); log.debug("Customized findAllById method was invoked"); @@ -90,8 +93,8 @@ public class BaseRepositoryImpl extends SimpleJpaRepository findAllByIdIn(Iterable ids, Pageable pageable) { - Assert.notNull(ids, "The given Iterable of Id's must not be null!"); + public Page findAllByIdIn(Collection ids, Pageable pageable) { + Assert.notNull(ids, "The given Collection of Id's must not be null!"); Assert.notNull(pageable, "Page info must nto be null"); if (!ids.iterator().hasNext()) { @@ -119,7 +122,7 @@ public class BaseRepositoryImpl extends SimpleJpaRepository ids) { + public long deleteByIdIn(Collection ids) { log.debug("Customized deleteByIdIn method was invoked"); // Find all domains @@ -147,7 +150,7 @@ public class BaseRepositoryImpl extends SimpleJpaRepository entityInformation; @Nullable - ParameterExpression parameter; + ParameterExpression parameter; ByIdsSpecification(JpaEntityInformation entityInformation) { this.entityInformation = entityInformation; @@ -156,7 +159,7 @@ public class BaseRepositoryImpl extends SimpleJpaRepository root, CriteriaQuery query, CriteriaBuilder cb) { Path path = root.get(this.entityInformation.getIdAttribute()); - this.parameter = cb.parameter(Iterable.class); + this.parameter = cb.parameter(Collection.class); return path.in(this.parameter); } } diff --git a/src/main/java/run/halo/app/service/TraceService.java b/src/main/java/run/halo/app/service/TraceService.java index 915152a33..991437ee4 100644 --- a/src/main/java/run/halo/app/service/TraceService.java +++ b/src/main/java/run/halo/app/service/TraceService.java @@ -1,24 +1,24 @@ -package run.halo.app.service; - -import org.springframework.boot.actuate.trace.http.HttpTrace; -import org.springframework.lang.NonNull; - -import java.util.List; - -/** - * Trace service interface. - * - * @author johnniang - * @date 2019-06-18 - */ -public interface TraceService { - - /** - * Gets all http traces. - * - * @return - */ - @NonNull - List listHttpTraces(); - -} +//package run.halo.app.service; +// +//import org.springframework.boot.actuate.trace.http.HttpTrace; +//import org.springframework.lang.NonNull; +// +//import java.util.List; +// +///** +// * Trace service interface. +// * +// * @author johnniang +// * @date 2019-06-18 +// */ +//public interface TraceService { +// +// /** +// * Gets all http traces. +// * +// * @return +// */ +// @NonNull +// List listHttpTraces(); +// +//} diff --git a/src/main/java/run/halo/app/service/impl/TraceServiceImpl.java b/src/main/java/run/halo/app/service/impl/TraceServiceImpl.java index 0304eaa8d..a7045ce31 100644 --- a/src/main/java/run/halo/app/service/impl/TraceServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/TraceServiceImpl.java @@ -1,29 +1,29 @@ -package run.halo.app.service.impl; - -import org.springframework.boot.actuate.trace.http.HttpTrace; -import org.springframework.boot.actuate.trace.http.HttpTraceRepository; -import org.springframework.stereotype.Service; -import run.halo.app.service.TraceService; - -import java.util.List; - -/** - * TraceService implementation class. - * - * @author johnniang - * @date 2019-06-18 - */ -@Service -public class TraceServiceImpl implements TraceService { - - private final HttpTraceRepository httpTraceRepository; - - public TraceServiceImpl(HttpTraceRepository httpTraceRepository) { - this.httpTraceRepository = httpTraceRepository; - } - - @Override - public List listHttpTraces() { - return httpTraceRepository.findAll(); - } -} +//package run.halo.app.service.impl; +// +//import org.springframework.boot.actuate.trace.http.HttpTrace; +//import org.springframework.boot.actuate.trace.http.HttpTraceRepository; +//import org.springframework.stereotype.Service; +//import run.halo.app.service.TraceService; +// +//import java.util.List; +// +///** +// * TraceService implementation class. +// * +// * @author johnniang +// * @date 2019-06-18 +// */ +//@Service +//public class TraceServiceImpl implements TraceService { +// +// private final HttpTraceRepository httpTraceRepository; +// +// public TraceServiceImpl(HttpTraceRepository httpTraceRepository) { +// this.httpTraceRepository = httpTraceRepository; +// } +// +// @Override +// public List listHttpTraces() { +// return httpTraceRepository.findAll(); +// } +//} diff --git a/src/main/resources/application-dev.yaml b/src/main/resources/application-dev.yaml index cd848a3ff..8f731ed68 100755 --- a/src/main/resources/application-dev.yaml +++ b/src/main/resources/application-dev.yaml @@ -1,6 +1,6 @@ server: port: 8090 - use-forward-headers: true + forward-headers-strategy: native compression: enabled: false mime-types: application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain @@ -40,9 +40,6 @@ spring: multipart: max-file-size: 10240MB max-request-size: 10240MB - mvc: - favicon: - enabled: false cache: type: none logging: @@ -51,7 +48,8 @@ logging: org.hibernate: INFO org.hibernate.type.descriptor.sql.BasicBinder: INFO org.hibernate.type.descriptor.sql.BasicExtractor: INFO - path: ${user.home}/halo-dev/logs + file: + path: ${user.home}/halo-dev/logs halo: doc-disabled: false diff --git a/src/main/resources/application-test.yaml b/src/main/resources/application-test.yaml index 8d7a99b26..b349fbc00 100755 --- a/src/main/resources/application-test.yaml +++ b/src/main/resources/application-test.yaml @@ -1,6 +1,6 @@ server: port: 8090 - use-forward-headers: true + forward-headers-strategy: native compression: enabled: false mime-types: application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain @@ -39,16 +39,14 @@ spring: multipart: max-file-size: 10MB max-request-size: 10MB - mvc: - favicon: - enabled: false cache: type: none logging: level: run.halo.app: DEBUG org.hibernate: ERROR - path: ${user.home}/halo-test/logs + file: + path: ${user.home}/halo-test/logs halo: doc-disabled: false diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 250fd324a..53fedb793 100755 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -1,6 +1,6 @@ server: port: 8090 - use-forward-headers: true + forward-headers-strategy: native compression: enabled: false mime-types: application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain @@ -42,10 +42,8 @@ spring: multipart: max-file-size: 10240MB max-request-size: 10240MB - mvc: - favicon: - enabled: false logging: level: run.halo.app: INFO - path: ${user.home}/.halo/logs \ No newline at end of file + file: + path: ${user.home}/.halo/logs \ No newline at end of file