增加swagger-bootstrap-ui依赖,生成接口文档

This commit is contained in:
hupeng committed 2019-09-08 10:25:04 +08:00
1 parent d1959f2f7a
commit 1296549d1d
5 files changed
+94 -44

No files matched your search

+12 -1
View File
@@ -61,12 +61,23 @@
<artifactId>springfox-swagger2</artifactId> <artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version> <version>2.9.2</version>
</dependency> </dependency>
<!--防止进入swagger页面报类型转换错误,排除2.9.2中的引用,手动增加1.5.21版本-->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.21</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
</dependency>
<dependency> <dependency>
<groupId>wiki.xsx</groupId> <groupId>wiki.xsx</groupId>
<artifactId>spring-boot-starter-fast-redis</artifactId> <artifactId>spring-boot-starter-fast-redis</artifactId>
<version>1.5.2</version> <version>1.5.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.xiaoymin</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId> <artifactId>swagger-bootstrap-ui</artifactId>
@@ -1,41 +1,41 @@
//package com.ruoyi.app.common.config; package com.ruoyi.app.common.config;
//
//import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
//import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.service.ApiInfo; import springfox.documentation.service.ApiInfo;
//import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
//
///** /**
// * @ClassName SwaggerConfiguration * @ClassName SwaggerConfiguration
// * @Author hupeng <610796224@qq.com> * @Author hupeng <610796224@qq.com>
// * @Date 2019/6/28 * @Date 2019/6/28
// **/ **/
//
//@Configuration @Configuration
//@EnableSwagger2 @EnableSwagger2
//public class SwaggerConfiguration { public class SwaggerConfiguration {
// @Bean @Bean
// public Docket createRestApi() { public Docket createRestApi() {
// return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
// .apiInfo(apiInfo()) .apiInfo(apiInfo())
// .select() .select()
// .apis(RequestHandlerSelectors.basePackage("com.yixiang.security.modular")) .apis(RequestHandlerSelectors.basePackage("com.ruoyi.app.modular"))
// .paths(PathSelectors.any()) .paths(PathSelectors.any())
// .build(); .build();
// } }
//
// private ApiInfo apiInfo() { private ApiInfo apiInfo() {
// return new ApiInfoBuilder() return new ApiInfoBuilder()
// .title("旅游系统API") .title("供货商城API")
// .description("旅游系统API") .description("供货商城API")
// .termsOfServiceUrl("http://localhost:8009/") .termsOfServiceUrl("http://localhost:8009/")
// .contact("610896224@qq.com") .contact("610896224@qq.com")
// .version("1.0") .version("1.0")
// .build(); .build();
// } }
//} }
@@ -9,6 +9,8 @@ import com.ruoyi.app.common.persistence.model.StoreMember;
import com.ruoyi.app.modular.member.service.IMemberService; import com.ruoyi.app.modular.member.service.IMemberService;
import com.ruoyi.app.modular.member.service.vo.LoginVO; import com.ruoyi.app.modular.member.service.vo.LoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@@ -25,7 +27,7 @@ import java.util.HashMap;
//@RequestMapping(value = "/") //@RequestMapping(value = "/")
@RestController @RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) @RequiredArgsConstructor(onConstructor = @__(@Autowired))
//@Api(value = "认证授权模块", tags = "认证授权模块", description = "认证授权模块") @Api(value = "认证授权模块", tags = "认证授权模块", description = "认证授权模块")
public class AuthController { public class AuthController {
private final UserOperator userOperator; private final UserOperator userOperator;
private final JwtOperator operator; private final JwtOperator operator;
@@ -49,7 +51,7 @@ public class AuthController {
* @return token字符串 * @return token字符串
*/ */
@PostMapping("/oauth/access_token") @PostMapping("/oauth/access_token")
// @ApiOperation(value = "获取token",notes = "获取token") @ApiOperation(value = "获取token",notes = "获取token")
public R loginReturnToken(@Validated @RequestBody LoginVO loginVO) { public R loginReturnToken(@Validated @RequestBody LoginVO loginVO) {
Boolean isProduct = false; Boolean isProduct = false;
String openid = null; String openid = null;
@@ -9,9 +9,14 @@ import com.ruoyi.app.modular.shop.service.dto.NewsDTO;
import com.ruoyi.app.modular.shop.service.impl.AdServiceImpl; import com.ruoyi.app.modular.shop.service.impl.AdServiceImpl;
import com.ruoyi.app.modular.shop.service.impl.GoodsServiceImpl; import com.ruoyi.app.modular.shop.service.impl.GoodsServiceImpl;
import com.ruoyi.app.modular.shop.service.impl.NewsServiceImpl; import com.ruoyi.app.modular.shop.service.impl.NewsServiceImpl;
import com.ruoyi.app.modular.shop.service.vo.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; import java.util.HashMap;
@@ -27,13 +32,16 @@ import java.util.Map;
@RestController @RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) @RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(value = "首页模块", tags = "首页模块", description = "首页模块")
public class IndexController { public class IndexController {
private final UserOperator userOperator; private final UserOperator userOperator;
private final GoodsServiceImpl goodsService; private final GoodsServiceImpl goodsService;
private final NewsServiceImpl newsService; private final NewsServiceImpl newsService;
private final AdServiceImpl adService; private final AdServiceImpl adService;
@GetMapping("/shop/index-list") @GetMapping("/shop/index-list")
@ApiOperation(value = "首页信息",notes = "首页信息")
public R index(){ public R index(){
int userId = userOperator.getUser().getId(); int userId = userOperator.getUser().getId();
@@ -51,4 +59,12 @@ public class IndexController {
return R.success(map); return R.success(map);
//return null; //return null;
} }
@GetMapping("/shop/news-lists")
public R news(@Validated @RequestBody PageVO pageVO){
List<NewsDTO> newsList = newsService.getList(pageVO.getPage(),pageVO.getLimit());
return R.success(newsList);
}
} }
@@ -0,0 +1,21 @@
package com.ruoyi.app.modular.shop.service.vo;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
@Data
public class PageVO {
//@NotBlank(message = "code必传")
@Min(message = "page为数值其值必须大于1",value = 1)
private int page;
@Min(message = "limit为数值其值必须大于1",value = 1)
private int limit;
}