配置接口注解和文档说明
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.jnssd.config;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
@@ -39,9 +40,10 @@ public class SwaggerOpenApiConfig {
|
||||
.select()
|
||||
// 扫描特定包
|
||||
// 扫描所有有注解的api,用这种方式更灵活
|
||||
// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||
//.apis(RequestHandlerSelectors.any())
|
||||
.apis(RequestHandlerSelectors.basePackage("com.jnssd"))
|
||||
// 扫描指定包下的
|
||||
// .apis(RequestHandlerSelectors.basePackage("com.jnssd"))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.securitySchemes(initSecuritySchemeList())
|
||||
@@ -51,7 +53,7 @@ public class SwaggerOpenApiConfig {
|
||||
public ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("Swagger项目测试")
|
||||
.description("novel项目接口文档")
|
||||
.description("Swagger项目接口文档")
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -59,14 +61,14 @@ public class SwaggerOpenApiConfig {
|
||||
|
||||
List<SecurityScheme> list = new ArrayList<>();
|
||||
list.add(httpAuthenticationScheme());
|
||||
// list.add(securitySchemeApiKey());
|
||||
// list.add(securitySchemeOpenIdConnect());
|
||||
//
|
||||
// // 配置oauth2的几种模式
|
||||
// list.add(securitySchemeOauth2ClientCredentials());
|
||||
// list.add(securitySchemeOauth2implicit());
|
||||
// list.add(securitySchemeOauth2Password());
|
||||
// list.add(securitySchemeOauth2AuthorizationCode());
|
||||
list.add(securitySchemeApiKey());
|
||||
list.add(securitySchemeOpenIdConnect());
|
||||
|
||||
// 配置oauth2的几种模式
|
||||
list.add(securitySchemeOauth2ClientCredentials());
|
||||
list.add(securitySchemeOauth2implicit());
|
||||
list.add(securitySchemeOauth2Password());
|
||||
list.add(securitySchemeOauth2AuthorizationCode());
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.jnssd.controller;
|
||||
|
||||
import com.jnssd.model.Menu;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -20,6 +18,7 @@ import java.util.Objects;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/menu")
|
||||
@Api(tags = "菜单")
|
||||
public class MenuController {
|
||||
|
||||
final static String SUCCESS_TEXT = "操作成功!";
|
||||
@@ -28,12 +27,14 @@ public class MenuController {
|
||||
List<Menu> list = new java.util.ArrayList<>();
|
||||
|
||||
@GetMapping("/")
|
||||
@ApiOperation(value = "获取所有菜单", notes = "获取所有菜单")
|
||||
public ResponseEntity<List<Menu>> getAll() {
|
||||
return ResponseEntity.ok(list);
|
||||
}
|
||||
|
||||
// 添加方法
|
||||
@PostMapping("add")
|
||||
@ApiOperation(value = "添加菜单", notes = "添加菜单")
|
||||
public ResponseEntity<String> add(Menu entity) {
|
||||
try {
|
||||
entity.setId(list.size() + 1);
|
||||
@@ -46,7 +47,8 @@ public class MenuController {
|
||||
}
|
||||
|
||||
// 添加方法
|
||||
@PostMapping("update")
|
||||
@PutMapping("update")
|
||||
@ApiOperation(value = "修改菜单", notes = "修改菜单")
|
||||
public ResponseEntity<Object> update(Menu entity) {
|
||||
try {
|
||||
// 修改list下面的数据
|
||||
@@ -59,7 +61,8 @@ public class MenuController {
|
||||
}
|
||||
|
||||
// 删除方法
|
||||
@PostMapping("delete")
|
||||
@DeleteMapping("delete")
|
||||
@ApiOperation(value = "删除菜单", notes = "删除菜单")
|
||||
public ResponseEntity<String> delete(Menu entity) {
|
||||
try {
|
||||
boolean result = list.removeIf(e -> Objects.equals(e.getId(), entity.getId()));
|
||||
@@ -70,7 +73,8 @@ public class MenuController {
|
||||
}
|
||||
|
||||
// 查询方法
|
||||
@PostMapping("query")
|
||||
@GetMapping("query")
|
||||
@ApiOperation(value = "查询菜单", notes = "查询菜单")
|
||||
public ResponseEntity<Object> query(Integer id) {
|
||||
try {
|
||||
Menu menu = (Menu) list.stream().filter(e -> Objects.equals(e.getId(), id));
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.jnssd.controller;
|
||||
|
||||
import com.jnssd.model.Role;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -18,7 +17,8 @@ import java.util.Objects;
|
||||
* @since 2023-10-12 16:32:38
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/Role")
|
||||
@RequestMapping("/role")
|
||||
@Api(tags = "角色")
|
||||
public class RoleController {
|
||||
|
||||
final static String SUCCESS_TEXT = "操作成功!";
|
||||
@@ -27,12 +27,14 @@ public class RoleController {
|
||||
List<Role> list = new java.util.ArrayList<>();
|
||||
|
||||
@GetMapping("/")
|
||||
@ApiOperation(value = "获取所有角色", notes = "获取所有角色")
|
||||
public ResponseEntity<List<Role>> getAll() {
|
||||
return ResponseEntity.ok(list);
|
||||
}
|
||||
|
||||
// 添加方法
|
||||
@PostMapping("add")
|
||||
@ApiOperation(value = "添加角色", notes = "添加角色")
|
||||
public ResponseEntity<String> add(Role entity) {
|
||||
try {
|
||||
entity.setId(list.size() + 1);
|
||||
@@ -45,7 +47,8 @@ public class RoleController {
|
||||
}
|
||||
|
||||
// 添加方法
|
||||
@PostMapping("update")
|
||||
@PutMapping("update")
|
||||
@ApiOperation(value = "修改角色", notes = "修改角色")
|
||||
public ResponseEntity<Object> update(Role entity) {
|
||||
try {
|
||||
// 修改list下面的数据
|
||||
@@ -58,7 +61,8 @@ public class RoleController {
|
||||
}
|
||||
|
||||
// 删除方法
|
||||
@PostMapping("delete")
|
||||
@DeleteMapping("delete")
|
||||
@ApiOperation(value = "删除角色", notes = "删除角色")
|
||||
public ResponseEntity<String> delete(Role entity) {
|
||||
try {
|
||||
boolean result = list.removeIf(e -> Objects.equals(e.getId(), entity.getId()));
|
||||
@@ -69,7 +73,8 @@ public class RoleController {
|
||||
}
|
||||
|
||||
// 查询方法
|
||||
@PostMapping("query")
|
||||
@GetMapping("query")
|
||||
@ApiOperation(value = "查询角色", notes = "查询角色")
|
||||
public ResponseEntity<Object> query(Integer id) {
|
||||
try {
|
||||
Role role = (Role) list.stream().filter(e -> Objects.equals(e.getId(), id));
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.jnssd.controller;
|
||||
|
||||
import com.jnssd.model.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -19,6 +18,7 @@ import java.util.Objects;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
@Api(tags = "用户")
|
||||
public class UserController {
|
||||
|
||||
final static String SUCCESS_TEXT = "操作成功!";
|
||||
@@ -27,12 +27,14 @@ public class UserController {
|
||||
List<User> list = new java.util.ArrayList<>();
|
||||
|
||||
@GetMapping("/")
|
||||
@ApiOperation(value = "获取所有用户", notes = "获取所有用户")
|
||||
public ResponseEntity<List<User>> getAll() {
|
||||
return ResponseEntity.ok(list);
|
||||
}
|
||||
|
||||
// 添加方法
|
||||
@PostMapping("add")
|
||||
@ApiOperation(value = "添加用户", notes = "添加用户")
|
||||
public ResponseEntity<String> add(User entity) {
|
||||
try {
|
||||
entity.setId(list.size() + 1);
|
||||
@@ -45,7 +47,8 @@ public class UserController {
|
||||
}
|
||||
|
||||
// 添加方法
|
||||
@PostMapping("update")
|
||||
@PutMapping("update")
|
||||
@ApiOperation(value = "修改用户", notes = "修改用户")
|
||||
public ResponseEntity<Object> update(User entity) {
|
||||
try {
|
||||
// 修改list下面的数据
|
||||
@@ -58,7 +61,8 @@ public class UserController {
|
||||
}
|
||||
|
||||
// 删除方法
|
||||
@PostMapping("delete")
|
||||
@DeleteMapping("delete")
|
||||
@ApiOperation(value = "删除用户", notes = "删除用户")
|
||||
public ResponseEntity<String> delete(User entity) {
|
||||
try {
|
||||
boolean result = list.removeIf(e -> Objects.equals(e.getId(), entity.getId()));
|
||||
@@ -69,7 +73,8 @@ public class UserController {
|
||||
}
|
||||
|
||||
// 查询方法
|
||||
@PostMapping("query")
|
||||
@GetMapping("query")
|
||||
@ApiOperation(value = "查询用户", notes = "查询用户")
|
||||
public ResponseEntity<Object> query(Integer id) {
|
||||
try {
|
||||
User user = (User) list.stream().filter(e -> Objects.equals(e.getId(), id));
|
||||
|
||||
Reference in New Issue
Block a user