提交 e9232891 编写于 作者: J johnniang

Fix tag deletion bug

上级 cee5ccba
......@@ -85,7 +85,7 @@ public class HaloConfiguration {
logFilter.setOrder(Ordered.HIGHEST_PRECEDENCE + 9);
logFilter.setFilter(new LogFilter());
logFilter.addUrlPatterns("/api/*");
logFilter.addUrlPatterns("/*");
return logFilter;
}
......
......@@ -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<PostCategory, Integer>
* @return a list of post category deleted
*/
@NonNull
@Transactional
List<PostCategory> removeByPostId(@NonNull Integer postId);
/**
......@@ -112,5 +114,6 @@ public interface PostCategoryService extends CrudService<PostCategory, Integer>
* @return a list of post category deleted
*/
@NonNull
@Transactional
List<PostCategory> removeByCategoryId(@NonNull Integer categoryId);
}
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<PostTag, Integer> {
* @return a list of post tag
*/
@NonNull
@Transactional
List<PostTag> removeByPostId(@NonNull Integer postId);
/**
......@@ -122,5 +124,6 @@ public interface PostTagService extends CrudService<PostTag, Integer> {
* @return a list of post tag
*/
@NonNull
@Transactional
List<PostTag> removeByTagId(@NonNull Integer tagId);
}
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<DOMAIN, ID> {
* @return DOMAIN
*/
@NonNull
@Transactional
DOMAIN create(@NonNull DOMAIN domain);
/**
......@@ -133,6 +135,7 @@ public interface CrudService<DOMAIN, ID> {
* @return List
*/
@NonNull
@Transactional
List<DOMAIN> createInBatch(@NonNull Collection<DOMAIN> domains);
/**
......@@ -142,6 +145,7 @@ public interface CrudService<DOMAIN, ID> {
* @return DOMAIN
*/
@NonNull
@Transactional
DOMAIN update(@NonNull DOMAIN domain);
/**
......@@ -151,6 +155,7 @@ public interface CrudService<DOMAIN, ID> {
* @return List
*/
@NonNull
@Transactional
List<DOMAIN> updateInBatch(@NonNull Collection<DOMAIN> domains);
/**
......@@ -161,6 +166,7 @@ public interface CrudService<DOMAIN, ID> {
* @throws NotFoundException If the specified id does not exist
*/
@NonNull
@Transactional
DOMAIN removeById(@NonNull ID id);
/**
......@@ -170,6 +176,7 @@ public interface CrudService<DOMAIN, ID> {
* @return DOMAIN
*/
@Nullable
@Transactional
DOMAIN removeByIdOfNullable(@NonNull ID id);
/**
......@@ -177,6 +184,7 @@ public interface CrudService<DOMAIN, ID> {
*
* @param domain domain
*/
@Transactional
void remove(@NonNull DOMAIN domain);
/**
......@@ -184,6 +192,7 @@ public interface CrudService<DOMAIN, ID> {
*
* @param ids ids
*/
@Transactional
void removeInBatch(@NonNull Collection<ID> ids);
/**
......@@ -191,10 +200,12 @@ public interface CrudService<DOMAIN, ID> {
*
* @param domains domains
*/
@Transactional
void removeAll(@NonNull Collection<DOMAIN> domains);
/**
* Remove all
*/
@Transactional
void removeAll();
}
......@@ -171,7 +171,7 @@ public class PostCategoryServiceImpl extends AbstractCrudService<PostCategory, I
@Override
public List<PostCategory> 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);
}
......
......@@ -443,7 +443,6 @@ public class PostServiceImpl extends AbstractCrudService<Post, Integer> 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<Post, Integer> implemen
postListVO.setTags(Optional.ofNullable(tagListMap.get(post.getId()))
.orElseGet(LinkedList::new)
.stream()
.filter(Objects::nonNull)
.map(tag -> new TagOutputDTO().<TagOutputDTO>convertFrom(tag))
.collect(Collectors.toList()));
......
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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册