bug修复
This commit is contained in:
+12
-4
@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Tag(name = "用户文章接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/article")
|
||||
@RequestMapping("/api/app/article")
|
||||
@RequiredArgsConstructor
|
||||
public class ArticleController {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ArticleController {
|
||||
}
|
||||
|
||||
@Operation(summary = "我的文章列表")
|
||||
@GetMapping("/my")
|
||||
@GetMapping("/mine")
|
||||
public ApiResult<PageResult<ArticleListVO>> listMyArticles(
|
||||
@AuthenticationPrincipal Long userId,
|
||||
@RequestParam(defaultValue = "1") int page,
|
||||
@@ -48,7 +48,7 @@ public class ArticleController {
|
||||
}
|
||||
|
||||
@Operation(summary = "移至回收站")
|
||||
@PostMapping("/{id}/recycle")
|
||||
@PutMapping("/{id}/recycle")
|
||||
public ApiResult<Void> moveToRecycleBin(
|
||||
@AuthenticationPrincipal Long userId,
|
||||
@PathVariable Long id) {
|
||||
@@ -57,7 +57,7 @@ public class ArticleController {
|
||||
}
|
||||
|
||||
@Operation(summary = "从回收站恢复")
|
||||
@PostMapping("/{id}/restore")
|
||||
@PutMapping("/{id}/restore")
|
||||
public ApiResult<Void> restoreArticle(
|
||||
@AuthenticationPrincipal Long userId,
|
||||
@PathVariable Long id) {
|
||||
@@ -73,4 +73,12 @@ public class ArticleController {
|
||||
articleService.deleteArticle(userId, id);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "点赞文章")
|
||||
@PostMapping("/{id}/like")
|
||||
public ApiResult<Boolean> toggleLike(
|
||||
@PathVariable Long id,
|
||||
@AuthenticationPrincipal Long userId) {
|
||||
return ApiResult.success(articleService.toggleLike(userId, id));
|
||||
}
|
||||
}
|
||||
|
||||
+4
-8
@@ -35,20 +35,16 @@ class AdminCategoryController {
|
||||
|
||||
@Operation(summary = "创建分类")
|
||||
@PostMapping
|
||||
public ApiResult<Category> createCategory(
|
||||
@RequestParam String name,
|
||||
@RequestParam(required = false) String description) {
|
||||
return ApiResult.success(categoryService.createCategory(name, description));
|
||||
public ApiResult<Category> createCategory(@RequestBody Category category) {
|
||||
return ApiResult.success(categoryService.createCategory(category.getName(), category.getDescription()));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新分类")
|
||||
@PutMapping("/{id}")
|
||||
public ApiResult<Void> updateCategory(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(required = false) String name,
|
||||
@RequestParam(required = false) String description,
|
||||
@RequestParam(required = false) Boolean enabled) {
|
||||
categoryService.updateCategory(id, name, description, enabled);
|
||||
@RequestBody Category category) {
|
||||
categoryService.updateCategory(id, category.getName(), category.getDescription(), category.getEnabled());
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
|
||||
-7
@@ -39,11 +39,4 @@ public class PublicArticleController {
|
||||
return ApiResult.success(articleService.getArticleDetail(id, userId));
|
||||
}
|
||||
|
||||
@Operation(summary = "点赞文章")
|
||||
@PostMapping("/{id}/like")
|
||||
public ApiResult<Boolean> toggleLike(
|
||||
@PathVariable Long id,
|
||||
@AuthenticationPrincipal Long userId) {
|
||||
return ApiResult.success(articleService.toggleLike(userId, id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package fun.nojava.module.blog.dto;
|
||||
|
||||
import fun.nojava.module.blog.entity.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -34,7 +35,7 @@ public class ArticleVO {
|
||||
|
||||
private String categoryName;
|
||||
|
||||
private List<String> tags;
|
||||
private List<Tag> tags;
|
||||
|
||||
private Long userId;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@TableName("article")
|
||||
@TableName("blog_article")
|
||||
public class Article {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@TableName("article_like")
|
||||
@TableName("blog_article_like")
|
||||
public class ArticleLike {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("article_tag")
|
||||
@TableName("blog_article_tag")
|
||||
public class ArticleTag {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@TableName("category")
|
||||
@TableName("blog_category")
|
||||
public class Category {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
|
||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@TableName("tag")
|
||||
@TableName("blog_tag")
|
||||
public class Tag {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
|
||||
+2
-2
@@ -280,11 +280,11 @@ public class ArticleServiceImpl implements ArticleService {
|
||||
User author = userMapper.selectById(article.getUserId());
|
||||
Category category = article.getCategoryId() != null ? categoryMapper.selectById(article.getCategoryId()) : null;
|
||||
|
||||
List<String> tags = articleTagMapper.selectList(
|
||||
List<Tag> tags = articleTagMapper.selectList(
|
||||
new LambdaQueryWrapper<ArticleTag>().eq(ArticleTag::getArticleId, article.getId())
|
||||
).stream().map(at -> {
|
||||
Tag tag = tagMapper.selectById(at.getTagId());
|
||||
return tag != null ? tag.getName() : null;
|
||||
return tag;
|
||||
}).filter(t -> t != null).toList();
|
||||
|
||||
return ArticleVO.builder()
|
||||
|
||||
Reference in New Issue
Block a user