From e9c30cdcdc96cf91dea9f4215f4c390a0b14bcc9 Mon Sep 17 00:00:00 2001 From: wangqing <408564126@qq.com> Date: Wed, 24 Jul 2024 21:40:23 +0800 Subject: [PATCH] =?UTF-8?q?release-=E4=B8=93=E6=A0=8F=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../music/controller/CMSEssayController.java | 33 +++++++++++-------- .../music/controller/EssayController.java | 2 +- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/luoo_music/src/main/java/com/luoo/music/controller/CMSEssayController.java b/luoo_music/src/main/java/com/luoo/music/controller/CMSEssayController.java index c22c26f..d02293e 100644 --- a/luoo_music/src/main/java/com/luoo/music/controller/CMSEssayController.java +++ b/luoo_music/src/main/java/com/luoo/music/controller/CMSEssayController.java @@ -6,8 +6,7 @@ import api.PageResult; import api.Result; import com.luoo.music.pojo.Essay; import com.luoo.music.service.EssayService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.web.bind.annotation.*; @@ -26,11 +25,11 @@ public class CMSEssayController { private EssayService essayService; - @ApiOperation(value = "获取专栏文章列表",notes = "获取专栏文章列表,category=0代表全部文章, 1代表荐碟,2代表专访,3代表言之,4代表她说") + @ApiOperation(value = "1.获取专栏文章列表",notes = "获取专栏文章列表,category=0代表全部文章, 1代表荐碟,2代表专访,3代表言之,4代表她说") @GetMapping("/search/{category}/{page}/{size}") - public Result search(@PathVariable Integer category, @PathVariable int page, @PathVariable int size){ + public Result search(@ApiParam(value = "分类,category=0代表全部文章, 1代表荐碟,2代表专访,3代表言之,4代表她说", required = true) @PathVariable Integer category, @PathVariable int page, @PathVariable int size){ Page pageData = null; - if(category == 0){ + if(category == 0 || category == null){ pageData = essayService.search(page, size); }else{ pageData = essayService.getByCategory(category, page, size); @@ -40,15 +39,25 @@ public class CMSEssayController { @ApiOperation("添加专栏文章") + @GlobalInterceptor(checkAdminLogin = true) @PostMapping - public Result add(@RequestBody Essay essay) { + @ApiImplicitParams({ + @ApiImplicitParam(name = "essay", value = "专栏文章对象", required = true, dataType = "Essay", paramType = "body"), + @ApiImplicitParam(name = "Authorization", value = "authorization", required = true, dataType = "String", paramType = "header") + }) + public Result add(@RequestHeader(value="Authorization",required = true) String authorization , @RequestBody Essay essay) { essayService.add(essay); return Result.success(); } @ApiOperation("修改专栏文章") @PutMapping("/{id}") - public Result update(@PathVariable String id, @RequestBody Essay essay) { + @GlobalInterceptor(checkAdminLogin = true) + @ApiImplicitParams({ + @ApiImplicitParam(name = "essay", value = "专栏文章对象", required = true, dataType = "Essay", paramType = "body"), + @ApiImplicitParam(name = "Authorization", value = "authorization", required = true, dataType = "String", paramType = "header") + }) + public Result update(@RequestHeader(value="Authorization",required = true) String authorization ,@PathVariable String id, @RequestBody Essay essay) { essay.setId(id); essayService.update(essay); return Result.success(); @@ -56,17 +65,13 @@ public class CMSEssayController { @ApiOperation("删除专栏文章") @DeleteMapping("/{id}") - public Result delete(@PathVariable String id) { + @GlobalInterceptor(checkAdminLogin = true) + public Result delete(@RequestHeader(value="Authorization",required = true) String authorization,@PathVariable String id) { essayService.delete(id); return Result.success(); } -// @ApiOperation("批量删除专栏文章") -// @DeleteMapping -// public Result deleteBatch(@RequestBody String[] ids) { -// essayService.deleteBatch(ids); -// return Result.success(); -// } + @ApiOperation("根据ID获取专栏文章") @GetMapping("/{id}") diff --git a/luoo_music/src/main/java/com/luoo/music/controller/EssayController.java b/luoo_music/src/main/java/com/luoo/music/controller/EssayController.java index 1047304..a16bed1 100644 --- a/luoo_music/src/main/java/com/luoo/music/controller/EssayController.java +++ b/luoo_music/src/main/java/com/luoo/music/controller/EssayController.java @@ -25,7 +25,7 @@ public class EssayController { @Autowired private EssayService essayService; - @ApiOperation(value = "获取专栏文章列表",notes = "获取专栏文章列表,category=0代表全部文章, 1代表荐碟,2代表专访,3代表言之,4代表她说") + @ApiOperation(value = "1 获取专栏文章列表",notes = "获取专栏文章列表,category=0代表全部文章, 1代表荐碟,2代表专访,3代表言之,4代表她说") @GetMapping("/search/{category}/{page}/{size}") public Result search(@PathVariable Integer category, @PathVariable int page, @PathVariable int size){ Page pageData = null;