diff --git a/src/main/java/run/halo/app/config/HaloConfiguration.java b/src/main/java/run/halo/app/config/HaloConfiguration.java index e38808822..949593d73 100644 --- a/src/main/java/run/halo/app/config/HaloConfiguration.java +++ b/src/main/java/run/halo/app/config/HaloConfiguration.java @@ -85,7 +85,7 @@ public class HaloConfiguration { logFilter.setOrder(Ordered.HIGHEST_PRECEDENCE + 9); logFilter.setFilter(new LogFilter()); - logFilter.addUrlPatterns("/api/*"); + logFilter.addUrlPatterns("/*"); return logFilter; } diff --git a/src/main/java/run/halo/app/service/PostCategoryService.java b/src/main/java/run/halo/app/service/PostCategoryService.java index f7536a9ff..c07acfb6c 100644 --- a/src/main/java/run/halo/app/service/PostCategoryService.java +++ b/src/main/java/run/halo/app/service/PostCategoryService.java @@ -4,6 +4,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; +import org.springframework.transaction.annotation.Transactional; import run.halo.app.model.entity.Category; import run.halo.app.model.entity.Post; import run.halo.app.model.entity.PostCategory; @@ -103,6 +104,7 @@ public interface PostCategoryService extends CrudService * @return a list of post category deleted */ @NonNull + @Transactional List removeByPostId(@NonNull Integer postId); /** @@ -112,5 +114,6 @@ public interface PostCategoryService extends CrudService * @return a list of post category deleted */ @NonNull + @Transactional List removeByCategoryId(@NonNull Integer categoryId); } diff --git a/src/main/java/run/halo/app/service/PostTagService.java b/src/main/java/run/halo/app/service/PostTagService.java index 15e48d11b..b8fe335dc 100644 --- a/src/main/java/run/halo/app/service/PostTagService.java +++ b/src/main/java/run/halo/app/service/PostTagService.java @@ -1,5 +1,6 @@ package run.halo.app.service; +import org.springframework.transaction.annotation.Transactional; import run.halo.app.model.dto.TagWithCountOutputDTO; import run.halo.app.model.entity.Post; import run.halo.app.model.entity.PostTag; @@ -113,6 +114,7 @@ public interface PostTagService extends CrudService { * @return a list of post tag */ @NonNull + @Transactional List removeByPostId(@NonNull Integer postId); /** @@ -122,5 +124,6 @@ public interface PostTagService extends CrudService { * @return a list of post tag */ @NonNull + @Transactional List removeByTagId(@NonNull Integer tagId); } diff --git a/src/main/java/run/halo/app/service/base/CrudService.java b/src/main/java/run/halo/app/service/base/CrudService.java index 3cb50d852..7aa3069c8 100644 --- a/src/main/java/run/halo/app/service/base/CrudService.java +++ b/src/main/java/run/halo/app/service/base/CrudService.java @@ -1,5 +1,6 @@ package run.halo.app.service.base; +import org.springframework.transaction.annotation.Transactional; import run.halo.app.exception.NotFoundException; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -124,6 +125,7 @@ public interface CrudService { * @return DOMAIN */ @NonNull + @Transactional DOMAIN create(@NonNull DOMAIN domain); /** @@ -133,6 +135,7 @@ public interface CrudService { * @return List */ @NonNull + @Transactional List createInBatch(@NonNull Collection domains); /** @@ -142,6 +145,7 @@ public interface CrudService { * @return DOMAIN */ @NonNull + @Transactional DOMAIN update(@NonNull DOMAIN domain); /** @@ -151,6 +155,7 @@ public interface CrudService { * @return List */ @NonNull + @Transactional List updateInBatch(@NonNull Collection domains); /** @@ -161,6 +166,7 @@ public interface CrudService { * @throws NotFoundException If the specified id does not exist */ @NonNull + @Transactional DOMAIN removeById(@NonNull ID id); /** @@ -170,6 +176,7 @@ public interface CrudService { * @return DOMAIN */ @Nullable + @Transactional DOMAIN removeByIdOfNullable(@NonNull ID id); /** @@ -177,6 +184,7 @@ public interface CrudService { * * @param domain domain */ + @Transactional void remove(@NonNull DOMAIN domain); /** @@ -184,6 +192,7 @@ public interface CrudService { * * @param ids ids */ + @Transactional void removeInBatch(@NonNull Collection ids); /** @@ -191,10 +200,12 @@ public interface CrudService { * * @param domains domains */ + @Transactional void removeAll(@NonNull Collection domains); /** * Remove all */ + @Transactional void removeAll(); } diff --git a/src/main/java/run/halo/app/service/impl/PostCategoryServiceImpl.java b/src/main/java/run/halo/app/service/impl/PostCategoryServiceImpl.java index cedff1871..2ae3771a0 100644 --- a/src/main/java/run/halo/app/service/impl/PostCategoryServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/PostCategoryServiceImpl.java @@ -171,7 +171,7 @@ public class PostCategoryServiceImpl extends AbstractCrudService removeByPostId(Integer postId) { - Assert.notNull(postId, "Post id must not be null"); + Assert.notNull(postId, "PoremoveByIdst id must not be null"); return postCategoryRepository.deleteByPostId(postId); } diff --git a/src/main/java/run/halo/app/service/impl/PostServiceImpl.java b/src/main/java/run/halo/app/service/impl/PostServiceImpl.java index 88c08405d..64b267412 100644 --- a/src/main/java/run/halo/app/service/impl/PostServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/PostServiceImpl.java @@ -443,7 +443,6 @@ public class PostServiceImpl extends AbstractCrudService implemen } @Override - @Transactional public Post removeById(Integer postId) { Assert.notNull(postId, "Post id must not be null"); @@ -501,6 +500,7 @@ public class PostServiceImpl extends AbstractCrudService implemen postListVO.setTags(Optional.ofNullable(tagListMap.get(post.getId())) .orElseGet(LinkedList::new) .stream() + .filter(Objects::nonNull) .map(tag -> new TagOutputDTO().convertFrom(tag)) .collect(Collectors.toList())); diff --git a/src/main/java/run/halo/app/web/controller/content/api/CommentController.java b/src/main/java/run/halo/app/web/controller/content/api/CommentController.java index 052e464e5..9de5331e5 100644 --- a/src/main/java/run/halo/app/web/controller/content/api/CommentController.java +++ b/src/main/java/run/halo/app/web/controller/content/api/CommentController.java @@ -1,5 +1,6 @@ package run.halo.app.web.controller.content.api; +import io.swagger.annotations.ApiOperation; import run.halo.app.model.dto.CommentOutputDTO; import run.halo.app.model.entity.User; import run.halo.app.model.params.CommentParam; @@ -43,6 +44,7 @@ public class CommentController { } @PostMapping + @ApiOperation("Comments a post") public CommentOutputDTO comment(@RequestBody CommentParam commentParam, HttpServletRequest request) { // Get authentication Authentication authentication = SecurityContextHolder.getContext().getAuthentication();