feat: 替换swagger2为OpenAPI3
This commit is contained in:
+11
-12
@@ -10,6 +10,8 @@ import com.central.common.annotation.LoginUser;
|
||||
import com.central.common.constant.CommonConstant;
|
||||
import com.central.common.context.LoginUserContextHolder;
|
||||
import com.central.common.model.*;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -18,14 +20,11 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.central.user.service.ISysMenuService;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @author 作者 owen E-mail: 624191343@qq.com
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "菜单模块api")
|
||||
@Tag(name = "菜单模块api")
|
||||
@Slf4j
|
||||
@RequestMapping("/menus")
|
||||
public class SysMenuController {
|
||||
@@ -61,7 +60,7 @@ public class SysMenuController {
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@ApiOperation(value = "删除菜单")
|
||||
@Operation(summary = "删除菜单")
|
||||
@DeleteMapping("/{id}")
|
||||
public Result delete(@PathVariable Long id) {
|
||||
try {
|
||||
@@ -73,7 +72,7 @@ public class SysMenuController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据roleId获取对应的菜单")
|
||||
@Operation(summary = "根据roleId获取对应的菜单")
|
||||
@GetMapping("/{roleId}/menus")
|
||||
public List<Map<String, Object>> findMenusByRoleId(@PathVariable Long roleId) {
|
||||
Set<Long> roleIds = new HashSet<>();
|
||||
@@ -101,7 +100,7 @@ public class SysMenuController {
|
||||
return authTrees;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据roleCodes获取对应的权限")
|
||||
@Operation(summary = "根据roleCodes获取对应的权限")
|
||||
@SuppressWarnings("unchecked")
|
||||
@Cacheable(value = "menu", key ="#roleCodes")
|
||||
@GetMapping("/{roleCodes}")
|
||||
@@ -117,21 +116,21 @@ public class SysMenuController {
|
||||
/**
|
||||
* 给角色分配菜单
|
||||
*/
|
||||
@ApiOperation(value = "角色分配菜单")
|
||||
@Operation(summary = "角色分配菜单")
|
||||
@PostMapping("/granted")
|
||||
public Result setMenuToRole(@RequestBody SysMenu sysMenu) {
|
||||
menuService.setMenuToRole(sysMenu.getRoleId(), sysMenu.getMenuIds());
|
||||
return Result.succeed("操作成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询所有菜单")
|
||||
@Operation(summary = "查询所有菜单")
|
||||
@GetMapping("/findAlls")
|
||||
public PageResult<SysMenu> findAlls() {
|
||||
List<SysMenu> list = menuService.findAll();
|
||||
return PageResult.<SysMenu>builder().data(list).code(0).count((long) list.size()).build();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取菜单以及顶级菜单")
|
||||
@Operation(summary = "获取菜单以及顶级菜单")
|
||||
@GetMapping("/findOnes")
|
||||
public PageResult<SysMenu> findOnes() {
|
||||
List<SysMenu> list = menuService.findOnes();
|
||||
@@ -144,7 +143,7 @@ public class SysMenuController {
|
||||
* @param menu
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "新增菜单")
|
||||
@Operation(summary = "新增菜单")
|
||||
@PostMapping("saveOrUpdate")
|
||||
public Result saveOrUpdate(@RequestBody SysMenu menu) {
|
||||
try {
|
||||
@@ -165,7 +164,7 @@ public class SysMenuController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/current")
|
||||
@ApiOperation(value = "查询当前用户菜单")
|
||||
@Operation(summary = "查询当前用户菜单")
|
||||
public List<SysMenu> findMyMenu(@LoginUser SysUser user) {
|
||||
List<SysRole> roles = user.getRoles();
|
||||
if (CollectionUtil.isEmpty(roles)) {
|
||||
|
||||
+6
-7
@@ -3,6 +3,8 @@ package com.central.user.controller;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
@@ -18,16 +20,13 @@ import com.central.common.model.Result;
|
||||
import com.central.common.model.SysRole;
|
||||
import com.central.user.service.ISysRoleService;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @author 作者 owen E-mail: 624191343@qq.com
|
||||
* 角色管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "角色模块api")
|
||||
@Tag(name = "角色模块api")
|
||||
public class SysRoleController {
|
||||
@Autowired
|
||||
private ISysRoleService sysRoleService;
|
||||
@@ -37,7 +36,7 @@ public class SysRoleController {
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "后台管理查询角色")
|
||||
@Operation(summary = "后台管理查询角色")
|
||||
@GetMapping("/roles")
|
||||
public PageResult<SysRole> findRoles(@RequestParam Map<String, Object> params) {
|
||||
return sysRoleService.findRoles(params);
|
||||
@@ -47,7 +46,7 @@ public class SysRoleController {
|
||||
* 用户管理查询所有角色
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "后台管理查询角色")
|
||||
@Operation(summary = "后台管理查询角色")
|
||||
@GetMapping("/allRoles")
|
||||
public Result<List<SysRole>> findAll() {
|
||||
List<SysRole> result = sysRoleService.findAll();
|
||||
@@ -71,7 +70,7 @@ public class SysRoleController {
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@ApiOperation(value = "后台管理删除角色")
|
||||
@Operation(summary = "后台管理删除角色")
|
||||
@DeleteMapping("/roles/{id}")
|
||||
public Result deleteRole(@PathVariable Long id) {
|
||||
try {
|
||||
|
||||
+25
-24
@@ -18,6 +18,11 @@ import com.central.search.model.LogicDelDto;
|
||||
import com.central.search.model.SearchDto;
|
||||
import com.central.user.model.SysUserExcel;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -27,10 +32,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.central.user.service.ISysUserService;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -42,7 +43,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "用户模块api")
|
||||
@Tag(name = "用户模块api")
|
||||
public class SysUserController {
|
||||
private static final String ADMIN_CHANGE_MSG = "超级管理员不给予修改";
|
||||
|
||||
@@ -62,7 +63,7 @@ public class SysUserController {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "根据access_token当前登录用户")
|
||||
@Operation(summary = "根据access_token当前登录用户")
|
||||
@GetMapping("/users/current")
|
||||
public Result<LoginAppUser> getLoginAppUser(@LoginUser(isFull = true) SysUser user) {
|
||||
return Result.succeed(appUserService.getLoginAppUser(user));
|
||||
@@ -72,7 +73,7 @@ public class SysUserController {
|
||||
* 查询用户实体对象SysUser
|
||||
*/
|
||||
@GetMapping(value = "/users/name/{username}")
|
||||
@ApiOperation(value = "根据用户名查询用户实体")
|
||||
@Operation(summary = "根据用户名查询用户实体")
|
||||
@Cacheable(value = "user", key = "#username")
|
||||
public SysUser selectByUsername(@PathVariable String username) {
|
||||
return appUserService.selectByUsername(username);
|
||||
@@ -82,7 +83,7 @@ public class SysUserController {
|
||||
* 查询用户登录对象LoginAppUser
|
||||
*/
|
||||
@GetMapping(value = "/users-anon/login", params = "username")
|
||||
@ApiOperation(value = "根据用户名查询用户")
|
||||
@Operation(summary = "根据用户名查询用户")
|
||||
public LoginAppUser findByUsername(String username) {
|
||||
return appUserService.findByUsername(username);
|
||||
}
|
||||
@@ -93,7 +94,7 @@ public class SysUserController {
|
||||
* @param mobile 手机号
|
||||
*/
|
||||
@GetMapping(value = "/users-anon/mobile", params = "mobile")
|
||||
@ApiOperation(value = "根据手机号查询用户")
|
||||
@Operation(summary = "根据手机号查询用户")
|
||||
public SysUser findByMobile(String mobile) {
|
||||
return appUserService.findByMobile(mobile);
|
||||
}
|
||||
@@ -104,7 +105,7 @@ public class SysUserController {
|
||||
* @param openId openId
|
||||
*/
|
||||
@GetMapping(value = "/users-anon/openId", params = "openId")
|
||||
@ApiOperation(value = "根据OpenId查询用户")
|
||||
@Operation(summary = "根据OpenId查询用户")
|
||||
public SysUser findByOpenId(String openId) {
|
||||
return appUserService.findByOpenId(openId);
|
||||
}
|
||||
@@ -154,10 +155,10 @@ public class SysUserController {
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "用户查询列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer")
|
||||
@Operation(summary = "用户查询列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "limit",description = "分页结束位置",required = true,in= ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping("/users")
|
||||
public PageResult<SysUser> findUsers(@RequestParam Map<String, Object> params) {
|
||||
@@ -170,11 +171,11 @@ public class SysUserController {
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "修改用户状态")
|
||||
@Operation(summary = "修改用户状态")
|
||||
@GetMapping("/users/updateEnabled")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "用户id", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "enabled", value = "是否启用", required = true, dataType = "Boolean")
|
||||
@Parameters({
|
||||
@Parameter(name = "id",description = "用户id",required = true,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "enabled",description = "是否启用",required = true,in= ParameterIn.QUERY)
|
||||
})
|
||||
public Result updateEnabled(@RequestParam Map<String, Object> params) {
|
||||
Long id = MapUtils.getLong(params, "id");
|
||||
@@ -273,11 +274,11 @@ public class SysUserController {
|
||||
return Result.succeed("导入数据成功,一共【"+rowNum+"】行");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户全文搜索列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "queryStr", value = "搜索关键字", dataType = "String")
|
||||
@Operation(summary = "用户全文搜索列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "limit",description = "分页结束位置",required = true,in= ParameterIn.QUERY),
|
||||
@Parameter(name = "queryStr",description = "搜索关键字",in= ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping("/users/search")
|
||||
public PageResult<JsonNode> search(SearchDto searchDto) {
|
||||
@@ -292,7 +293,7 @@ public class SysUserController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/users/roleUser/{username}")
|
||||
@ApiOperation(value = "查询用户-带角色信息")
|
||||
@Operation(summary = "查询用户-带角色信息")
|
||||
@Cacheable(value = "userRoles", key = "#username")
|
||||
public SysUser selectRoleUser(@PathVariable("username") String username){
|
||||
SysUser sysUser = selectByUsername(username);
|
||||
|
||||
@@ -13,13 +13,26 @@ mybatis-plus:
|
||||
db-config:
|
||||
id-type: auto
|
||||
|
||||
springdoc:
|
||||
swagger-ui:
|
||||
path: /swagger-ui.html
|
||||
tags-sorter: alpha
|
||||
operations-sorter: alpha
|
||||
api-docs:
|
||||
path: /v3/api-docs
|
||||
group-configs:
|
||||
- group: 'user'
|
||||
paths-to-match: '/**'
|
||||
packages-to-scan: com.central.user.controller
|
||||
default-flat-param-object: true
|
||||
|
||||
knife4j:
|
||||
enable: true
|
||||
setting:
|
||||
language: zh_cn
|
||||
swagger-model-name: 用户中心接口文档
|
||||
|
||||
zlt:
|
||||
swagger:
|
||||
enabled: true
|
||||
title: 用户中心
|
||||
description: 用户中心接口文档
|
||||
version: 1.0
|
||||
base-package: com.central.user.controller
|
||||
cache-manager:
|
||||
configs:
|
||||
- key: menu
|
||||
|
||||
Reference in New Issue
Block a user