Skip to content

Commit 0287117

Browse files
authored
Merge pull request zhoutaoo#149 from zhoutaoo/dev
Dev To Master
2 parents 330e7e0 + 5caf628 commit 0287117

File tree

12 files changed

+67
-36
lines changed

12 files changed

+67
-36
lines changed

auth/authentication-server/src/main/java/com/springboot/cloud/auth/authentication/config/ResourceServerConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public void configure(HttpSecurity http) throws Exception {
3333
http.csrf().disable();
3434
http.authorizeRequests()
3535
.antMatchers("/actuator/**").permitAll()
36+
.antMatchers("/v2/api-docs").permitAll()
3637
.anyRequest().authenticated();
3738
}
3839

demos/producer/src/main/java/com/springboot/cloud/demos/producer/rest/ProductController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ public Result add(@Valid @RequestBody ProductForm productForm) {
3232
}
3333

3434
@ApiOperation(value = "删除产品", notes = "根据url的id来指定删除对象")
35-
@ApiImplicitParam(paramType = "path", name = "id", value = "产品ID", required = true, dataType = "long")
35+
@ApiImplicitParam(paramType = "path", name = "id", value = "产品ID", required = true, dataType = "string")
3636
@DeleteMapping(value = "/{id}")
3737
public Result delete(@PathVariable String id) {
3838
return Result.success(productService.delete(id));
3939
}
4040

4141
@ApiOperation(value = "修改产品", notes = "修改指定产品信息")
4242
@ApiImplicitParams({
43-
@ApiImplicitParam(name = "id", value = "产品ID", required = true, dataType = "long"),
43+
@ApiImplicitParam(name = "id", value = "产品ID", required = true, dataType = "string"),
4444
@ApiImplicitParam(name = "productForm", value = "产品实体", required = true, dataType = "ProductForm")
4545
})
4646
@PutMapping(value = "/{id}")
@@ -51,7 +51,7 @@ public Result update(@PathVariable String id, @Valid @RequestBody ProductForm pr
5151
}
5252

5353
@ApiOperation(value = "获取产品", notes = "获取指定产品信息")
54-
@ApiImplicitParam(paramType = "path", name = "id", value = "产品ID", required = true, dataType = "long")
54+
@ApiImplicitParam(paramType = "path", name = "id", value = "产品ID", required = true, dataType = "string")
5555
@GetMapping(value = "/{id}")
5656
public Result get(@PathVariable String id) {
5757
log.info("get with id:{}", id);

gateway/gateway-admin/src/main/java/com/springboot/cloud/gateway/admin/rest/GatewayRouteController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public Result add(@Valid @RequestBody GatewayRouteForm gatewayRoutForm) {
3333
}
3434

3535
@ApiOperation(value = "删除网关路由", notes = "根据url的id来指定删除对象")
36-
@ApiImplicitParam(paramType = "path", name = "id", value = "网关路由ID", required = true, dataType = "long")
36+
@ApiImplicitParam(paramType = "path", name = "id", value = "网关路由ID", required = true, dataType = "string")
3737
@DeleteMapping(value = "/{id}")
3838
public Result delete(@PathVariable String id) {
3939
return Result.success(gatewayRoutService.delete(id));
4040
}
4141

4242
@ApiOperation(value = "修改网关路由", notes = "修改指定网关路由信息")
4343
@ApiImplicitParams({
44-
@ApiImplicitParam(name = "id", value = "网关路由ID", required = true, dataType = "long"),
44+
@ApiImplicitParam(name = "id", value = "网关路由ID", required = true, dataType = "string"),
4545
@ApiImplicitParam(name = "gatewayRoutForm", value = "网关路由实体", required = true, dataType = "GatewayRouteForm")
4646
})
4747
@PutMapping(value = "/{id}")
@@ -52,7 +52,7 @@ public Result update(@PathVariable String id, @Valid @RequestBody GatewayRouteFo
5252
}
5353

5454
@ApiOperation(value = "获取网关路由", notes = "根据id获取指定网关路由信息")
55-
@ApiImplicitParam(paramType = "path", name = "id", value = "网关路由ID", required = true, dataType = "long")
55+
@ApiImplicitParam(paramType = "path", name = "id", value = "网关路由ID", required = true, dataType = "string")
5656
@GetMapping(value = "/{id}")
5757
public Result get(@PathVariable String id) {
5858
log.info("get with id:{}", id);

gateway/gateway-web/src/main/java/com/springboot/cloud/gateway/config/SwaggerProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@AllArgsConstructor
1818
@Slf4j
1919
public class SwaggerProvider implements SwaggerResourcesProvider {
20-
private static final String API_URI = "/v2/api-docs";
20+
public static final String API_URI = "/v2/api-docs";
2121

2222
@Autowired
2323
private final RouteService routeService;
@@ -38,8 +38,8 @@ public List<SwaggerResource> get() {
3838
private SwaggerResource swaggerResource(String name, String location) {
3939
SwaggerResource swaggerResource = new SwaggerResource();
4040
swaggerResource.setName(name);
41-
swaggerResource.setLocation(location);
4241
swaggerResource.setSwaggerVersion("2.0");
42+
swaggerResource.setUrl(location);
4343
return swaggerResource;
4444
}
4545
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.springboot.cloud.gateway.filter;
2+
3+
import com.springboot.cloud.gateway.config.SwaggerProvider;
4+
import lombok.extern.slf4j.Slf4j;
5+
import org.apache.commons.lang3.StringUtils;
6+
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
7+
import org.springframework.cloud.gateway.filter.GlobalFilter;
8+
import org.springframework.core.Ordered;
9+
import org.springframework.http.server.reactive.ServerHttpRequest;
10+
import org.springframework.web.server.ServerWebExchange;
11+
import reactor.core.publisher.Mono;
12+
13+
//@Component
14+
@Slf4j
15+
public class SwaggerHeaderFilter implements GlobalFilter, Ordered {
16+
17+
private static final String HEADER_NAME = "X-Forwarded-Prefix";
18+
19+
@Override
20+
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
21+
ServerHttpRequest request = exchange.getRequest();
22+
String path = request.getURI().getPath();
23+
if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) {
24+
return chain.filter(exchange);
25+
}
26+
String basePath = path.substring(0, path.lastIndexOf(SwaggerProvider.API_URI));
27+
log.info("basePath: {}", basePath);
28+
ServerHttpRequest newRequest = request.mutate().header(HEADER_NAME, basePath).build();
29+
ServerWebExchange newExchange = exchange.mutate().request(newRequest).build();
30+
return chain.filter(newExchange);
31+
}
32+
33+
@Override
34+
public int getOrder() {
35+
return -200;
36+
}
37+
}

gateway/gateway-web/src/main/resources/application.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ spring:
1111
lettuce:
1212
pool:
1313
max-active: 300
14-
datasource:
15-
driver-class-name: com.mysql.jdbc.Driver
16-
url: jdbc:${DATASOURCE_DBTYPE:mysql}://${DATASOURCE_HOST:localhost}:${DATASOURCE_PORT:3306}/sc_gateway?characterEncoding=UTF-8&useUnicode=true&useSSL=false
17-
username: ${DATASOURCE_USERNAME:root}
18-
password: ${DATASOURCE_PASSWORD:root123}
1914

2015
zipkin:
2116
enabled: true
@@ -45,6 +40,7 @@ spring:
4540
redis-rate-limiter.burstCapacity: 10 #令牌桶的容积
4641
rate-limiter: "#{@defaultRedisRateLimiter}" #SPEL表达式去的对应的bean
4742
key-resolver: "#{@apiKeyResolver}" #SPEL表达式去的对应的bean
43+
4844
feign:
4945
sentinel:
5046
enabled: true

pom.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<dependency>
2929
<groupId>org.springframework.boot</groupId>
3030
<artifactId>spring-boot-dependencies</artifactId>
31-
<version>2.1.4.RELEASE</version>
31+
<version>2.1.10.RELEASE</version>
3232
<type>pom</type>
3333
<scope>import</scope>
3434
</dependency>
@@ -82,9 +82,6 @@
8282
<snapshots>
8383
<enabled>true</enabled>
8484
</snapshots>
85-
<releases>
86-
<enabled>false</enabled>
87-
</releases>
8885
</repository>
8986
</repositories>
9087

sysadmin/organization/src/main/java/com/springboot/cloud/sysadmin/organization/rest/GroupController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ public Result add(@Valid @RequestBody GroupForm groupForm) {
3131
}
3232

3333
@ApiOperation(value = "删除用户组", notes = "根据url的id来指定删除对象")
34-
@ApiImplicitParam(paramType = "path", name = "id", value = "用户组ID", required = true, dataType = "long")
34+
@ApiImplicitParam(paramType = "path", name = "id", value = "用户组ID", required = true, dataType = "string")
3535
@DeleteMapping(value = "/{id}")
3636
public Result delete(@PathVariable String id) {
3737
return Result.success(groupService.delete(id));
3838
}
3939

4040
@ApiOperation(value = "修改用户组", notes = "修改指定用户组信息")
4141
@ApiImplicitParams({
42-
@ApiImplicitParam(name = "id", value = "用户组ID", required = true, dataType = "long"),
42+
@ApiImplicitParam(name = "id", value = "用户组ID", required = true, dataType = "string"),
4343
@ApiImplicitParam(name = "groupForm", value = "用户组实体", required = true, dataType = "GroupForm")
4444
})
4545
@PutMapping(value = "/{id}")
@@ -50,7 +50,7 @@ public Result update(@PathVariable String id, @Valid @RequestBody GroupForm grou
5050
}
5151

5252
@ApiOperation(value = "获取用户组", notes = "获取指定用户组信息")
53-
@ApiImplicitParam(paramType = "path", name = "id", value = "用户组ID", required = true, dataType = "long")
53+
@ApiImplicitParam(paramType = "path", name = "id", value = "用户组ID", required = true, dataType = "string")
5454
@GetMapping(value = "/{id}")
5555
public Result get(@PathVariable String id) {
5656
log.debug("get with id:{}", id);
@@ -82,7 +82,7 @@ public Result search(@Valid @RequestBody GroupQueryForm groupQueryForm) {
8282
}
8383

8484
@ApiOperation(value = "根据父id查询用户组", notes = "根据父id查询用户组列表")
85-
@ApiImplicitParam(paramType = "path", name = "id", value = "用户组父ID", required = true, dataType = "long")
85+
@ApiImplicitParam(paramType = "path", name = "id", value = "用户组父ID", required = true, dataType = "string")
8686
@GetMapping(value = "/parent/{id}")
8787
public Result search(@PathVariable String id) {
8888
log.debug("query with parent id:{}", id);

sysadmin/organization/src/main/java/com/springboot/cloud/sysadmin/organization/rest/MenuController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ public Result add(@Valid @RequestBody MenuForm menuForm) {
3232
}
3333

3434
@ApiOperation(value = "删除菜单", notes = "根据url的id来指定删除对象")
35-
@ApiImplicitParam(paramType = "path", name = "id", value = "菜单ID", required = true, dataType = "long")
35+
@ApiImplicitParam(paramType = "path", name = "id", value = "菜单ID", required = true, dataType = "string")
3636
@DeleteMapping(value = "/{id}")
3737
public Result delete(@PathVariable String id) {
3838
return Result.success(menuService.delete(id));
3939
}
4040

4141
@ApiOperation(value = "修改菜单", notes = "修改指定菜单信息")
4242
@ApiImplicitParams({
43-
@ApiImplicitParam(name = "id", value = "菜单ID", required = true, dataType = "long"),
43+
@ApiImplicitParam(name = "id", value = "菜单ID", required = true, dataType = "string"),
4444
@ApiImplicitParam(name = "menuForm", value = "菜单实体", required = true, dataType = "MenuForm")
4545
})
4646
@PutMapping(value = "/{id}")
@@ -51,7 +51,7 @@ public Result update(@PathVariable String id, @Valid @RequestBody MenuForm menuF
5151
}
5252

5353
@ApiOperation(value = "获取菜单", notes = "获取指定菜单信息")
54-
@ApiImplicitParam(paramType = "path", name = "id", value = "菜单ID", required = true, dataType = "long")
54+
@ApiImplicitParam(paramType = "path", name = "id", value = "菜单ID", required = true, dataType = "string")
5555
@GetMapping(value = "/{id}")
5656
public Result get(@PathVariable String id) {
5757
log.debug("get with id:{}", id);
@@ -82,7 +82,7 @@ public Result search(@Valid @RequestBody MenuQueryForm menuQueryForm) {
8282
}
8383

8484
@ApiOperation(value = "根据父id查询菜单", notes = "根据父id查询菜单列表")
85-
@ApiImplicitParam(paramType = "path", name = "id", value = "菜单父ID", required = true, dataType = "long")
85+
@ApiImplicitParam(paramType = "path", name = "id", value = "菜单父ID", required = true, dataType = "string")
8686
@GetMapping(value = "/parent/{id}")
8787
public Result search(@PathVariable String id) {
8888
log.debug("query with parent id:{}", id);

sysadmin/organization/src/main/java/com/springboot/cloud/sysadmin/organization/rest/PositionController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ public Result add(@Valid @RequestBody PositionForm positionForm) {
3131
}
3232

3333
@ApiOperation(value = "删除职位", notes = "根据url的id来指定删除对象")
34-
@ApiImplicitParam(paramType = "path", name = "id", value = "职位ID", required = true, dataType = "long")
34+
@ApiImplicitParam(paramType = "path", name = "id", value = "职位ID", required = true, dataType = "string")
3535
@DeleteMapping(value = "/{id}")
3636
public Result delete(@PathVariable String id) {
3737
return Result.success(positionService.delete(id));
3838
}
3939

4040
@ApiOperation(value = "修改职位", notes = "修改指定职位信息")
4141
@ApiImplicitParams({
42-
@ApiImplicitParam(name = "id", value = "职位ID", required = true, dataType = "long"),
42+
@ApiImplicitParam(name = "id", value = "职位ID", required = true, dataType = "string"),
4343
@ApiImplicitParam(name = "positionForm", value = "职位实体", required = true, dataType = "PositionForm")
4444
})
4545
@PutMapping(value = "/{id}")
@@ -50,7 +50,7 @@ public Result update(@PathVariable String id, @Valid @RequestBody PositionForm p
5050
}
5151

5252
@ApiOperation(value = "获取职位", notes = "获取指定职位信息")
53-
@ApiImplicitParam(paramType = "path", name = "id", value = "职位ID", required = true, dataType = "long")
53+
@ApiImplicitParam(paramType = "path", name = "id", value = "职位ID", required = true, dataType = "string")
5454
@GetMapping(value = "/{id}")
5555
public Result get(@PathVariable String id) {
5656
log.debug("get with id:{}", id);

0 commit comments

Comments
 (0)