Skip to content

Commit 97ec0d8

Browse files
committed
集成swagger
1 parent c454b80 commit 97ec0d8

46 files changed

Lines changed: 13451 additions & 18 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,42 @@
9696
</properties>
9797
<!--版本变量设置 end-->
9898

99+
<repositories>
100+
<repository>
101+
<id>jcenter-release</id>
102+
<name>jcenter</name>
103+
<url>http://oss.jfrog.org/artifactory/oss-release-local/</url>
104+
</repository>
105+
</repositories>
99106

100107
<!--架包依赖 start-->
101108
<dependencies>
102109

110+
111+
<dependency>
112+
<groupId>com.mangofactory</groupId>
113+
<artifactId>swagger-springmvc</artifactId>
114+
<version>1.0.1</version>
115+
</dependency>
116+
<dependency>
117+
<groupId>com.google.guava</groupId>
118+
<artifactId>guava</artifactId>
119+
<version>15.0</version>
120+
</dependency>
121+
<dependency>
122+
<groupId>com.fasterxml.jackson.core</groupId>
123+
<artifactId>jackson-annotations</artifactId>
124+
<version>2.4.4</version>
125+
</dependency>
126+
<dependency>
127+
<groupId>com.fasterxml.jackson.core</groupId>
128+
<artifactId>jackson-databind</artifactId>
129+
</dependency>
130+
<dependency>
131+
<groupId>com.fasterxml.jackson.core</groupId>
132+
<artifactId>jackson-core</artifactId>
133+
<version>2.4.4</version>
134+
</dependency>
103135
<!-- ############################################################### Spring 相关包 start ############################################################### -->
104136
<!--spring 源码包下载地址:https://github.com/spring-projects/spring-framework/releases-->
105137
<!--http://takeme.iteye.com/blog/1977585-->
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.config;
2+
import com.mangofactory.swagger.configuration.SpringSwaggerConfig;
3+
import com.mangofactory.swagger.models.dto.ApiInfo;
4+
import com.mangofactory.swagger.paths.SwaggerPathProvider;
5+
import com.mangofactory.swagger.plugin.EnableSwagger;
6+
import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.context.annotation.ComponentScan;
10+
import org.springframework.context.annotation.Configuration;
11+
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
12+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
13+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
14+
15+
@Configuration
16+
@EnableWebMvc
17+
@EnableSwagger
18+
@ComponentScan(basePackages ={"com.youmeek.ssm.module.user.controller"})
19+
public class MySwaggerConfig extends WebMvcConfigurerAdapter {
20+
private SpringSwaggerConfig springSwaggerConfig;
21+
22+
@Autowired
23+
public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig) {
24+
this.springSwaggerConfig = springSwaggerConfig;
25+
}
26+
/**
27+
* 链式编程 来定制API样式
28+
* 后续会加上分组信息
29+
* @return
30+
*/
31+
@Bean
32+
public SwaggerSpringMvcPlugin customImplementation(){
33+
return new SwaggerSpringMvcPlugin(this.springSwaggerConfig)
34+
.apiInfo(apiInfo())
35+
.includePatterns(".*")
36+
// .pathProvider(new GtPaths())
37+
.apiVersion("0.0.1")
38+
.swaggerGroup("user");
39+
}
40+
private ApiInfo apiInfo() {
41+
ApiInfo apiInfo = new ApiInfo(
42+
"bugkillers-back API",
43+
"bugkillers 后台API文档",
44+
"<a href='http://127.0.0.1:9081/api' '='' style='color: rgb(59, 115, 175); text-decoration: none; border-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: inherit !important; background: none !important;'>http://127.0.0.1:9081/api",
45+
"bugkillers@163.com",
46+
"My License",
47+
"My Apps API License URL");
48+
return apiInfo;
49+
}
50+
@Override
51+
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
52+
configurer.enable();
53+
}
54+
55+
class GtPaths extends SwaggerPathProvider{
56+
@Override
57+
protected String applicationPath() {
58+
return "/restapi";
59+
}
60+
@Override
61+
protected String getDocumentationPath() {
62+
return "/restapi";
63+
}
64+
}
65+
66+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.generator.mapper;
2+
3+
import com.generator.pojo.SysUser;
4+
5+
public interface SysUserMapper {
6+
/**
7+
* This method was generated by MyBatis Generator.
8+
* This method corresponds to the database table sys_user
9+
*
10+
* @mbggenerated
11+
*/
12+
int deleteByPrimaryKey(Long sysUserId);
13+
14+
/**
15+
* This method was generated by MyBatis Generator.
16+
* This method corresponds to the database table sys_user
17+
*
18+
* @mbggenerated
19+
*/
20+
int insert(SysUser record);
21+
22+
/**
23+
* This method was generated by MyBatis Generator.
24+
* This method corresponds to the database table sys_user
25+
*
26+
* @mbggenerated
27+
*/
28+
int insertSelective(SysUser record);
29+
30+
/**
31+
* This method was generated by MyBatis Generator.
32+
* This method corresponds to the database table sys_user
33+
*
34+
* @mbggenerated
35+
*/
36+
SysUser selectByPrimaryKey(Long sysUserId);
37+
38+
/**
39+
* This method was generated by MyBatis Generator.
40+
* This method corresponds to the database table sys_user
41+
*
42+
* @mbggenerated
43+
*/
44+
int updateByPrimaryKeySelective(SysUser record);
45+
46+
/**
47+
* This method was generated by MyBatis Generator.
48+
* This method corresponds to the database table sys_user
49+
*
50+
* @mbggenerated
51+
*/
52+
int updateByPrimaryKey(SysUser record);
53+
}

0 commit comments

Comments
 (0)