管理端接口swagger注释

This commit is contained in:
linfeng 2022-11-16 10:40:39 +08:00
parent 6be54a5966
commit 57f93b6144
5 changed files with 63 additions and 72 deletions

View File

@ -45,8 +45,8 @@ public class SwaggerConfig implements WebMvcConfigurer {
private ApiInfo apiInfo(){ private ApiInfo apiInfo(){
return new ApiInfoBuilder() return new ApiInfoBuilder()
.title("林风社交论坛项目接口文档") .title("林风社交论坛开源版接口文档")
.description("林风社交论坛项目开源版接口文档 演示地址 https://www.linfeng.tech") .description("林风社交论坛项目开源版接口文档 官网 https://net.linfeng.tech")
.contact(new Contact("linfeng","http:localhost:8080/doc.html","linfengtech001@163.com")) .contact(new Contact("linfeng","http:localhost:8080/doc.html","linfengtech001@163.com"))
.version("1.0") .version("1.0")
.build(); .build();

View File

@ -15,13 +15,11 @@ package io.linfeng.modules.admin.controller;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.linfeng.modules.admin.entity.CommentEntity; import io.linfeng.modules.admin.entity.CommentEntity;
import io.linfeng.modules.admin.service.CommentService; import io.linfeng.modules.admin.service.CommentService;
@ -32,22 +30,23 @@ import io.linfeng.common.utils.R;
/** /**
* *
*评论管理 * 评论管理
* @author linfeng * @author linfeng
* @email 2445465217@qq.com * @email 2445465217@qq.com
* @date 2022-01-24 21:29:22 * @date 2022-01-24 21:29:22
*/ */
@Api(tags = "管理端——评论管理")
@RestController @RestController
@RequestMapping("admin/comment") @RequestMapping("admin/comment")
public class CommentController { public class CommentController {
@Autowired @Autowired
private CommentService commentService; private CommentService commentService;
/**
* 列表
*/ @GetMapping("/list")
@RequestMapping("/list")
@RequiresPermissions("admin:comment:list") @RequiresPermissions("admin:comment:list")
@ApiOperation("评论列表")
public R list(@RequestParam Map<String, Object> params){ public R list(@RequestParam Map<String, Object> params){
PageUtils page = commentService.queryPage(params); PageUtils page = commentService.queryPage(params);
@ -55,44 +54,40 @@ public class CommentController {
} }
/**
* 信息 @GetMapping("/info/{id}")
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("admin:comment:info") @RequiresPermissions("admin:comment:info")
@ApiOperation("评论详情")
public R info(@PathVariable("id") Long id){ public R info(@PathVariable("id") Long id){
CommentEntity comment = commentService.getById(id); CommentEntity comment = commentService.getById(id);
return R.ok().put("comment", comment); return R.ok().put("comment", comment);
} }
/**
* 保存 @PostMapping("/save")
*/
@RequestMapping("/save")
@RequiresPermissions("admin:comment:save") @RequiresPermissions("admin:comment:save")
@ApiOperation("评论保存")
public R save(@RequestBody CommentEntity comment){ public R save(@RequestBody CommentEntity comment){
commentService.save(comment); commentService.save(comment);
return R.ok(); return R.ok();
} }
/**
* 修改 @PostMapping("/update")
*/
@RequestMapping("/update")
@RequiresPermissions("admin:comment:update") @RequiresPermissions("admin:comment:update")
@ApiOperation("评论修改")
public R update(@RequestBody CommentEntity comment){ public R update(@RequestBody CommentEntity comment){
commentService.updateById(comment); commentService.updateById(comment);
return R.ok(); return R.ok();
} }
/**
* 删除 @PostMapping("/delete")
*/
@RequestMapping("/delete")
@RequiresPermissions("admin:comment:delete") @RequiresPermissions("admin:comment:delete")
@ApiOperation("评论删除")
public R delete(@RequestBody Long[] ids){ public R delete(@RequestBody Long[] ids){
commentService.deleteByAdmin(Arrays.asList(ids)); commentService.deleteByAdmin(Arrays.asList(ids));
return R.ok(); return R.ok();

View File

@ -15,13 +15,11 @@ package io.linfeng.modules.admin.controller;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.linfeng.modules.admin.entity.LinkEntity; import io.linfeng.modules.admin.entity.LinkEntity;
import io.linfeng.modules.admin.service.LinkService; import io.linfeng.modules.admin.service.LinkService;
@ -31,23 +29,23 @@ import io.linfeng.common.utils.R;
/** /**
* * 管理端轮播图管理
* *
* @author linfeng * @author linfeng
* @email 2445465217@qq.com * @email 2445465217@qq.com
* @date 2022-01-26 14:05:38 * @date 2022-01-26 14:05:38
*/ */
@Api(tags = "管理端——轮播图管理")
@RestController @RestController
@RequestMapping("admin/link") @RequestMapping("admin/link")
public class LinkController { public class LinkController {
@Autowired @Autowired
private LinkService linkService; private LinkService linkService;
/**
* 列表 @GetMapping("/list")
*/
@RequestMapping("/list")
@RequiresPermissions("admin:link:list") @RequiresPermissions("admin:link:list")
@ApiOperation("轮播图列表")
public R list(@RequestParam Map<String, Object> params){ public R list(@RequestParam Map<String, Object> params){
PageUtils page = linkService.queryPage(params); PageUtils page = linkService.queryPage(params);
@ -55,44 +53,40 @@ public class LinkController {
} }
/**
* 信息 @GetMapping("/info/{id}")
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("admin:link:info") @RequiresPermissions("admin:link:info")
@ApiOperation("轮播图信息")
public R info(@PathVariable("id") Integer id){ public R info(@PathVariable("id") Integer id){
LinkEntity link = linkService.getById(id); LinkEntity link = linkService.getById(id);
return R.ok().put("link", link); return R.ok().put("link", link);
} }
/**
* 保存 @PostMapping("/save")
*/
@RequestMapping("/save")
@RequiresPermissions("admin:link:save") @RequiresPermissions("admin:link:save")
@ApiOperation("轮播图保存")
public R save(@RequestBody LinkEntity link){ public R save(@RequestBody LinkEntity link){
linkService.save(link); linkService.save(link);
return R.ok(); return R.ok();
} }
/**
* 修改 @PostMapping("/update")
*/
@RequestMapping("/update")
@RequiresPermissions("admin:link:update") @RequiresPermissions("admin:link:update")
@ApiOperation("轮播图修改")
public R update(@RequestBody LinkEntity link){ public R update(@RequestBody LinkEntity link){
linkService.updateById(link); linkService.updateById(link);
return R.ok(); return R.ok();
} }
/**
* 删除 @PostMapping("/delete")
*/
@RequestMapping("/delete")
@RequiresPermissions("admin:link:delete") @RequiresPermissions("admin:link:delete")
@ApiOperation("轮播图删除")
public R delete(@RequestBody Integer[] ids){ public R delete(@RequestBody Integer[] ids){
linkService.removeByIds(Arrays.asList(ids)); linkService.removeByIds(Arrays.asList(ids));

View File

@ -15,6 +15,8 @@ package io.linfeng.modules.admin.controller;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -28,22 +30,22 @@ import io.linfeng.common.utils.R;
/** /**
* *
*帖子管理 * 帖子管理
* @author linfeng * @author linfeng
* @email 2445465217@qq.com * @email 2445465217@qq.com
* @date 2022-01-23 20:49:55 * @date 2022-01-23 20:49:55
*/ */
@Api(tags = "管理端——帖子管理")
@RestController @RestController
@RequestMapping("admin/post") @RequestMapping("admin/post")
public class PostController { public class PostController {
@Autowired @Autowired
private PostService postService; private PostService postService;
/**
* 列表 @GetMapping("/list")
*/
@RequestMapping("/list")
@RequiresPermissions("admin:post:list") @RequiresPermissions("admin:post:list")
@ApiOperation("帖子列表")
public R list(@RequestParam Map<String, Object> params){ public R list(@RequestParam Map<String, Object> params){
PageUtils page = postService.queryPage(params); PageUtils page = postService.queryPage(params);
@ -51,44 +53,40 @@ public class PostController {
} }
/**
* 信息 @GetMapping("/info/{id}")
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("admin:post:info") @RequiresPermissions("admin:post:info")
@ApiOperation("帖子信息")
public R info(@PathVariable("id") Integer id){ public R info(@PathVariable("id") Integer id){
PostEntity post = postService.getById(id); PostEntity post = postService.getById(id);
return R.ok().put("post", post); return R.ok().put("post", post);
} }
/**
* 保存
*/
@PostMapping("/save") @PostMapping("/save")
@RequiresPermissions("admin:post:save") @RequiresPermissions("admin:post:save")
@ApiOperation("帖子保存")
public R save(@RequestBody PostEntity post){ public R save(@RequestBody PostEntity post){
postService.save(post); postService.save(post);
return R.ok(); return R.ok();
} }
/**
* 修改
*/
@PostMapping("/update") @PostMapping("/update")
@RequiresPermissions("admin:post:update") @RequiresPermissions("admin:post:update")
@ApiOperation("帖子修改")
public R update(@RequestBody PostEntity post){ public R update(@RequestBody PostEntity post){
postService.updateById(post); postService.updateById(post);
return R.ok(); return R.ok();
} }
/**
* 删除
*/
@PostMapping("/delete") @PostMapping("/delete")
@RequiresPermissions("admin:post:delete") @RequiresPermissions("admin:post:delete")
@ApiOperation("帖子删除")
public R delete(@RequestBody Integer[] ids){ public R delete(@RequestBody Integer[] ids){
postService.deleteByAdmin(Arrays.asList(ids)); postService.deleteByAdmin(Arrays.asList(ids));
return R.ok(); return R.ok();

View File

@ -14,6 +14,8 @@ package io.linfeng.modules.admin.controller;
import io.linfeng.common.utils.R; import io.linfeng.common.utils.R;
import io.linfeng.modules.admin.service.AppUserService; import io.linfeng.modules.admin.service.AppUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -27,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
*/ */
@RestController @RestController
@RequestMapping("admin/statistics") @RequestMapping("admin/statistics")
@Api(tags = "管理端——数据统计")
public class StatisticController { public class StatisticController {
@Autowired @Autowired
@ -34,6 +37,7 @@ public class StatisticController {
@GetMapping("/home") @GetMapping("/home")
@ApiOperation("后台前端首页数据统计")
public R index() { public R index() {
return R.ok().put("result", userService.indexDate()); return R.ok().put("result", userService.indexDate());