|
|
@@ -8,8 +8,6 @@ import cn.reghao.bnt.web.blog.service.CategoryService;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import org.springframework.http.MediaType;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.List;
|
|
|
@@ -19,8 +17,8 @@ import java.util.List;
|
|
|
* @date 2023-04-10 16:56:10
|
|
|
*/
|
|
|
@Tag(name = "博客文章分类接口")
|
|
|
-@Controller
|
|
|
-@RequestMapping("/bg/blog")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/blog/v2")
|
|
|
public class AdminCategoryController {
|
|
|
private final CategoryService categoryService;
|
|
|
|
|
|
@@ -30,35 +28,20 @@ public class AdminCategoryController {
|
|
|
|
|
|
@Operation(summary = "文章标签列表页面", description = "N")
|
|
|
@GetMapping("/tag/list")
|
|
|
- public String tagList(ModelMap model) {
|
|
|
+ public String tagList() {
|
|
|
List<CategoryCount> list = categoryService.findCategoryCountByPage(CategoryType.Tag.getValue(), true);
|
|
|
-
|
|
|
- model.put("category", false);
|
|
|
- model.put("tableName", "标签列表");
|
|
|
- model.put("list", list);
|
|
|
- return "/admin/blog/category/list";
|
|
|
+ return WebResult.success(list);
|
|
|
}
|
|
|
|
|
|
@Operation(summary = "文章分类列表页面", description = "N")
|
|
|
@GetMapping("/category/list")
|
|
|
- public String categoryList(ModelMap model) {
|
|
|
+ public String categoryList() {
|
|
|
List<CategoryCount> list = categoryService.findCategoryCountByPage(CategoryType.Category.getValue(), true);
|
|
|
-
|
|
|
- model.put("category", true);
|
|
|
- model.put("tableName", "分类列表");
|
|
|
- model.put("list", list);
|
|
|
- return "/admin/blog/category/list";
|
|
|
- }
|
|
|
-
|
|
|
- @Operation(summary = "添加文章分类页面", description = "N")
|
|
|
- @GetMapping("/category/add")
|
|
|
- public String addCategoryPage() {
|
|
|
- return "/admin/blog/category/view";
|
|
|
+ return WebResult.success(list);
|
|
|
}
|
|
|
|
|
|
@Operation(summary = "添加文章分类接口", description = "N")
|
|
|
@PostMapping(value = "/category/add", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- @ResponseBody
|
|
|
public String addCategory(String name) {
|
|
|
Result result = categoryService.add(name);
|
|
|
return WebResult.result(result);
|
|
|
@@ -66,7 +49,6 @@ public class AdminCategoryController {
|
|
|
|
|
|
@Operation(summary = "删除文章分类接口", description = "N")
|
|
|
@PostMapping(value = "/category/delete", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- @ResponseBody
|
|
|
public String delete(@RequestParam("id") List<Integer> ids) {
|
|
|
if (ids.size() != 1) {
|
|
|
return WebResult.failWithMsg("删除的分类/标签数量不为 1");
|