diff --git a/pom.xml b/pom.xml
index 4e2d6b1..6ade2b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,6 +23,7 @@
1.3.3
3.8.1
1.2.58
+ 2.9.2
@@ -120,6 +121,7 @@
jedis
+
com.auth0
java-jwt
@@ -132,6 +134,27 @@
fastjson
${fastjson.version}
+
+
+
+ io.springfox
+ springfox-swagger2
+ ${swagger.version}
+
+
+
+
+ io.swagger
+ swagger-annotations
+ 1.5.21
+
+
+
+
+ io.springfox
+ springfox-swagger-ui
+ ${swagger.version}
+
diff --git a/src/main/java/com/wayn/framework/config/SwaggerConfig.java b/src/main/java/com/wayn/framework/config/SwaggerConfig.java
new file mode 100644
index 0000000..2d5b662
--- /dev/null
+++ b/src/main/java/com/wayn/framework/config/SwaggerConfig.java
@@ -0,0 +1,54 @@
+package com.wayn.framework.config;
+
+import io.swagger.annotations.ApiOperation;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+
+ /**
+ * 创建API
+ */
+ @Bean
+ public Docket createRestApi() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
+ .apiInfo(apiInfo())
+ // 设置哪些接口暴露给Swagger展示
+ .select()
+ // 扫描所有有注解的api,用这种方式更灵活
+ .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
+ // 扫描指定包中的swagger注解
+ //.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
+ // 扫描所有 .apis(RequestHandlerSelectors.any())
+ .paths(PathSelectors.any())
+ .build();
+ }
+
+ /**
+ * 添加摘要信息
+ */
+ private ApiInfo apiInfo() {
+ // 用ApiInfoBuilder进行定制
+ return new ApiInfoBuilder()
+ // 设置标题
+ .title("标题:wayn_admin管理系统_接口文档")
+ // 描述
+ .description("描述:用于查看后台管理系统api接口")
+ // 作者信息
+ .contact(new Contact(WaynConfig.getName(), null, WaynConfig.getEmail()))
+ // 版本
+ .version("版本号:" + WaynConfig.getVersion())
+ .build();
+ }
+}
diff --git a/src/main/java/com/wayn/framework/config/WaynConfig.java b/src/main/java/com/wayn/framework/config/WaynConfig.java
index 60da4b0..4e2b963 100644
--- a/src/main/java/com/wayn/framework/config/WaynConfig.java
+++ b/src/main/java/com/wayn/framework/config/WaynConfig.java
@@ -14,15 +14,15 @@ public class WaynConfig {
/**
* 项目名称
*/
- private String name;
+ private static String name;
/**
* 项目版本
*/
- private String version;
+ private static String version;
/**
* 联系邮件
*/
- private String email;
+ private static String email;
public static String getUploadDir() {
return uploadDir;
@@ -31,4 +31,28 @@ public class WaynConfig {
public void setUploadDir(String uploadDir) {
WaynConfig.uploadDir = uploadDir;
}
+
+ public static String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ WaynConfig.name = name;
+ }
+
+ public static String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ WaynConfig.version = version;
+ }
+
+ public static String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ WaynConfig.email = email;
+ }
}
diff --git a/src/main/java/com/wayn/project/system/controller/RoleController.java b/src/main/java/com/wayn/project/system/controller/RoleController.java
index 65087be..1a49f13 100644
--- a/src/main/java/com/wayn/project/system/controller/RoleController.java
+++ b/src/main/java/com/wayn/project/system/controller/RoleController.java
@@ -7,6 +7,8 @@ import com.wayn.common.util.R;
import com.wayn.common.util.SecurityUtils;
import com.wayn.project.system.domain.SysRole;
import com.wayn.project.system.service.IRoleService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -14,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
+@Api(value = "角色接口")
@RestController
@RequestMapping("system/role")
public class RoleController extends BaseController {
@@ -21,13 +24,14 @@ public class RoleController extends BaseController {
@Autowired
private IRoleService iRoleService;
-
+ @ApiOperation(value = "角色列表", notes = "角色列表")
@GetMapping("/list")
public R list(SysRole role) {
Page page = getPage();
return R.success().add("page", iRoleService.listPage(page, role));
}
+ @ApiOperation(value = "保存用户", notes = "保存用户")
@PostMapping
public R addRole(@Validated @RequestBody SysRole role) {
if (SysConstants.NOT_UNIQUE.equals(iRoleService.checkRoleNameUnique(role))) {
@@ -40,6 +44,7 @@ public class RoleController extends BaseController {
return R.result(iRoleService.insertRoleAndMenu(role));
}
+ @ApiOperation(value = "更新用户", notes = "更新用户")
@PutMapping
public R updateRole(@Validated @RequestBody SysRole role) {
iRoleService.checkRoleAllowed(role);
@@ -52,6 +57,7 @@ public class RoleController extends BaseController {
return R.result(iRoleService.updateRoleAndMenu(role));
}
+ @ApiOperation(value = "更新用户状态", notes = "更新用户状态")
@PutMapping("changeStatus")
public R changeStatus(@RequestBody SysRole role) {
iRoleService.checkRoleAllowed(role);
@@ -59,14 +65,15 @@ public class RoleController extends BaseController {
return R.result(iRoleService.updateById(role));
}
-
+ @ApiOperation("获取角色详细")
@GetMapping("/{roleId}")
public R getRole(@PathVariable Long roleId) {
return R.success().add("data", iRoleService.getById(roleId));
}
+ @ApiOperation("删除角色")
@DeleteMapping("/{roleIds}")
- public R getRole(@PathVariable List roleIds) {
+ public R deleteRole(@PathVariable List roleIds) {
return R.success().add("data", iRoleService.deleteRoleByIds(roleIds));
}
}
diff --git a/src/main/java/com/wayn/project/system/domain/SysRole.java b/src/main/java/com/wayn/project/system/domain/SysRole.java
index 1892157..9a5146d 100644
--- a/src/main/java/com/wayn/project/system/domain/SysRole.java
+++ b/src/main/java/com/wayn/project/system/domain/SysRole.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.wayn.common.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -14,6 +15,7 @@ import java.util.List;
* 角色表 sys_role
*/
@Data
+@ApiModel("角色实体")
@EqualsAndHashCode(callSuper = true)
public class SysRole extends BaseEntity {