mirror of https://github.com/halo-dev/halo
Fix tag deletion bug
parent
cee5ccba69
commit
e92328911c
|
@ -85,7 +85,7 @@ public class HaloConfiguration {
|
||||||
|
|
||||||
logFilter.setOrder(Ordered.HIGHEST_PRECEDENCE + 9);
|
logFilter.setOrder(Ordered.HIGHEST_PRECEDENCE + 9);
|
||||||
logFilter.setFilter(new LogFilter());
|
logFilter.setFilter(new LogFilter());
|
||||||
logFilter.addUrlPatterns("/api/*");
|
logFilter.addUrlPatterns("/*");
|
||||||
|
|
||||||
return logFilter;
|
return logFilter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import run.halo.app.model.entity.Category;
|
import run.halo.app.model.entity.Category;
|
||||||
import run.halo.app.model.entity.Post;
|
import run.halo.app.model.entity.Post;
|
||||||
import run.halo.app.model.entity.PostCategory;
|
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
|
* @return a list of post category deleted
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@Transactional
|
||||||
List<PostCategory> removeByPostId(@NonNull Integer postId);
|
List<PostCategory> removeByPostId(@NonNull Integer postId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,5 +114,6 @@ public interface PostCategoryService extends CrudService<PostCategory, Integer>
|
||||||
* @return a list of post category deleted
|
* @return a list of post category deleted
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@Transactional
|
||||||
List<PostCategory> removeByCategoryId(@NonNull Integer categoryId);
|
List<PostCategory> removeByCategoryId(@NonNull Integer categoryId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package run.halo.app.service;
|
package run.halo.app.service;
|
||||||
|
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import run.halo.app.model.dto.TagWithCountOutputDTO;
|
import run.halo.app.model.dto.TagWithCountOutputDTO;
|
||||||
import run.halo.app.model.entity.Post;
|
import run.halo.app.model.entity.Post;
|
||||||
import run.halo.app.model.entity.PostTag;
|
import run.halo.app.model.entity.PostTag;
|
||||||
|
@ -113,6 +114,7 @@ public interface PostTagService extends CrudService<PostTag, Integer> {
|
||||||
* @return a list of post tag
|
* @return a list of post tag
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@Transactional
|
||||||
List<PostTag> removeByPostId(@NonNull Integer postId);
|
List<PostTag> removeByPostId(@NonNull Integer postId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,5 +124,6 @@ public interface PostTagService extends CrudService<PostTag, Integer> {
|
||||||
* @return a list of post tag
|
* @return a list of post tag
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@Transactional
|
||||||
List<PostTag> removeByTagId(@NonNull Integer tagId);
|
List<PostTag> removeByTagId(@NonNull Integer tagId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package run.halo.app.service.base;
|
package run.halo.app.service.base;
|
||||||
|
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import run.halo.app.exception.NotFoundException;
|
import run.halo.app.exception.NotFoundException;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
@ -124,6 +125,7 @@ public interface CrudService<DOMAIN, ID> {
|
||||||
* @return DOMAIN
|
* @return DOMAIN
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@Transactional
|
||||||
DOMAIN create(@NonNull DOMAIN domain);
|
DOMAIN create(@NonNull DOMAIN domain);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,6 +135,7 @@ public interface CrudService<DOMAIN, ID> {
|
||||||
* @return List
|
* @return List
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@Transactional
|
||||||
List<DOMAIN> createInBatch(@NonNull Collection<DOMAIN> domains);
|
List<DOMAIN> createInBatch(@NonNull Collection<DOMAIN> domains);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,6 +145,7 @@ public interface CrudService<DOMAIN, ID> {
|
||||||
* @return DOMAIN
|
* @return DOMAIN
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@Transactional
|
||||||
DOMAIN update(@NonNull DOMAIN domain);
|
DOMAIN update(@NonNull DOMAIN domain);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,6 +155,7 @@ public interface CrudService<DOMAIN, ID> {
|
||||||
* @return List
|
* @return List
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@Transactional
|
||||||
List<DOMAIN> updateInBatch(@NonNull Collection<DOMAIN> domains);
|
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
|
* @throws NotFoundException If the specified id does not exist
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@Transactional
|
||||||
DOMAIN removeById(@NonNull ID id);
|
DOMAIN removeById(@NonNull ID id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,6 +176,7 @@ public interface CrudService<DOMAIN, ID> {
|
||||||
* @return DOMAIN
|
* @return DOMAIN
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@Transactional
|
||||||
DOMAIN removeByIdOfNullable(@NonNull ID id);
|
DOMAIN removeByIdOfNullable(@NonNull ID id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,6 +184,7 @@ public interface CrudService<DOMAIN, ID> {
|
||||||
*
|
*
|
||||||
* @param domain domain
|
* @param domain domain
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
void remove(@NonNull DOMAIN domain);
|
void remove(@NonNull DOMAIN domain);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -184,6 +192,7 @@ public interface CrudService<DOMAIN, ID> {
|
||||||
*
|
*
|
||||||
* @param ids ids
|
* @param ids ids
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
void removeInBatch(@NonNull Collection<ID> ids);
|
void removeInBatch(@NonNull Collection<ID> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,10 +200,12 @@ public interface CrudService<DOMAIN, ID> {
|
||||||
*
|
*
|
||||||
* @param domains domains
|
* @param domains domains
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
void removeAll(@NonNull Collection<DOMAIN> domains);
|
void removeAll(@NonNull Collection<DOMAIN> domains);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove all
|
* Remove all
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
void removeAll();
|
void removeAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ public class PostCategoryServiceImpl extends AbstractCrudService<PostCategory, I
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PostCategory> removeByPostId(Integer postId) {
|
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);
|
return postCategoryRepository.deleteByPostId(postId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -443,7 +443,6 @@ public class PostServiceImpl extends AbstractCrudService<Post, Integer> implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
|
||||||
public Post removeById(Integer postId) {
|
public Post removeById(Integer postId) {
|
||||||
Assert.notNull(postId, "Post id must not be null");
|
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()))
|
postListVO.setTags(Optional.ofNullable(tagListMap.get(post.getId()))
|
||||||
.orElseGet(LinkedList::new)
|
.orElseGet(LinkedList::new)
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.map(tag -> new TagOutputDTO().<TagOutputDTO>convertFrom(tag))
|
.map(tag -> new TagOutputDTO().<TagOutputDTO>convertFrom(tag))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package run.halo.app.web.controller.content.api;
|
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.dto.CommentOutputDTO;
|
||||||
import run.halo.app.model.entity.User;
|
import run.halo.app.model.entity.User;
|
||||||
import run.halo.app.model.params.CommentParam;
|
import run.halo.app.model.params.CommentParam;
|
||||||
|
@ -43,6 +44,7 @@ public class CommentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
@ApiOperation("Comments a post")
|
||||||
public CommentOutputDTO comment(@RequestBody CommentParam commentParam, HttpServletRequest request) {
|
public CommentOutputDTO comment(@RequestBody CommentParam commentParam, HttpServletRequest request) {
|
||||||
// Get authentication
|
// Get authentication
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
|
Loading…
Reference in New Issue