From 6bc5954cfec1b36f7344a331877d417fc709e278 Mon Sep 17 00:00:00 2001 From: moec42frf <3378620026@qq.com> Date: Sun, 30 Apr 2023 09:20:13 +0800 Subject: [PATCH] ADD file via upload --- .../controller/admin/AdminController.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 blogserver/src/main/java/org/sang/controller/admin/AdminController.java diff --git a/blogserver/src/main/java/org/sang/controller/admin/AdminController.java b/blogserver/src/main/java/org/sang/controller/admin/AdminController.java new file mode 100644 index 0000000..0d2763f --- /dev/null +++ b/blogserver/src/main/java/org/sang/controller/admin/AdminController.java @@ -0,0 +1,41 @@ +package org.sang.controller.admin; + +import org.sang.bean.Article; +import org.sang.bean.RespBean; +import org.sang.service.ArticleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 超级管理员专属Controller + */ +@RestController +@RequestMapping("/admin") +public class AdminController { + @Autowired + ArticleService articleService; + + @RequestMapping(value = "/article/all", method = RequestMethod.GET) + public Map getArticleByStateByAdmin(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "count", defaultValue = "6") Integer count, String keywords) { + List
articles = articleService.getArticleByState(-2, page, count, keywords); + Map map = new HashMap<>(); + map.put("articles", articles); + map.put("totalCount", articleService.getArticleCountByState(1, null, keywords)); + return map; + } + + @RequestMapping(value = "/article/dustbin", method = RequestMethod.PUT) + public RespBean updateArticleState(Long[] aids, Integer state) { + if (articleService.updateArticleState(aids, state) == aids.length) { + return new RespBean("success", "删除成功!"); + } + return new RespBean("error", "删除失败!"); + } +}