mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-04 16:11:38 +08:00
引入Swagger
This commit is contained in:
@@ -4,6 +4,7 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import plus.bookshelf.Common.Enum.plus.bookshelf.TencentCloud.COS.CosProperties;
|
||||
|
@@ -0,0 +1,34 @@
|
||||
package plus.bookshelf.Config;
|
||||
|
||||
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 {
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("plus.bookshelf.Controller"))
|
||||
.paths(PathSelectors.any()).build();
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("书栖网 服务端接口文档")
|
||||
.description("RESTful API | bookshelf.plus")
|
||||
// .license("MIT")
|
||||
// .contact(new Contact("程序员小墨", "only4.work", "admin@only4.work"))
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -1,5 +1,8 @@
|
||||
package plus.bookshelf.Controller.Controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -11,6 +14,7 @@ import plus.bookshelf.Controller.VO.BookVO;
|
||||
import plus.bookshelf.Service.Model.BookModel;
|
||||
import plus.bookshelf.Service.Service.BookService;
|
||||
|
||||
@Api(value = "书籍")
|
||||
@Controller("book")
|
||||
@RequestMapping("/apiv1/book")
|
||||
public class BookController extends BaseController {
|
||||
@@ -18,6 +22,8 @@ public class BookController extends BaseController {
|
||||
@Autowired
|
||||
BookService bookService;
|
||||
|
||||
@ApiOperation(value = "获取书籍信息",notes = "获取书籍信息")
|
||||
// @ApiImplicitParam(name = "book", value = "图书详细实体", required = true, dataType = "Book")
|
||||
@RequestMapping(value = "get", method = {RequestMethod.GET})
|
||||
@ResponseBody
|
||||
public BookVO get(@RequestParam(value = "id") Integer id) {
|
||||
|
Reference in New Issue
Block a user