瀏覽代碼

高速平台对接

pull/57/head
chenjiandong 1 年之前
父節點
當前提交
b74bb476c7
共有 7 個檔案被更改,包括 25 行新增8 行删除
  1. +12
    -1
      src/main/java/com/tuoheng/gateway/commons/CommonsConfig.java
  2. +2
    -3
      src/main/java/com/tuoheng/gateway/config/GatewayFilterConfig.java
  3. +4
    -1
      src/main/java/com/tuoheng/gateway/utils/GatewayUrlPathUtil.java
  4. +2
    -1
      src/main/resources/application-dev.yml
  5. +2
    -1
      src/main/resources/application-local.yml
  6. +1
    -0
      src/main/resources/application-prod.yml
  7. +2
    -1
      src/main/resources/application-test.yml

+ 12
- 1
src/main/java/com/tuoheng/gateway/commons/CommonsConfig.java 查看文件

@@ -14,13 +14,24 @@ import org.springframework.context.annotation.Configuration;
public class CommonsConfig {

/**
* 图片域名
* 河湖长权限接口地址
*/
public static String hhzPermissionUrl;

/**
* 高速权限接口地址
*/
public static String freewayPermissionUrl;


@Value("${tuoheng.hhz-admin-perUrl}")
public void setPermissionUrl(String url) {
hhzPermissionUrl = url;
}

@Value("${tuoheng.hhz-admin-perUrl}")
public void setFreewayPermissionUrl(String url) {
freewayPermissionUrl = url;
}

}

+ 2
- 3
src/main/java/com/tuoheng/gateway/config/GatewayFilterConfig.java 查看文件

@@ -59,13 +59,12 @@ public class GatewayFilterConfig implements GlobalFilter, Ordered {
}
//header里封装 Client-Id 信息
String clientId = getClientId(exchange);
log.info("clientId is :{}", clientId);
if(!StringUtils.isEmpty(clientId)){
log.info("clientId is :{}", clientId);
String requestUrl = exchange.getRequest().getPath().value();
log.info("requestUrl is :{}", requestUrl);
//去除gateway path 前缀
String apiUrl = requestUrl.replace(GatewayUrlPathUtil.getPathByClientId(clientId),"");
log.info("apiUrl is :{}", apiUrl);
log.info("requestUrl is :{}; apiUrl is :{}", requestUrl, apiUrl);
List<Integer> roleIds = GatewayUrlPathUtil.getRoleIdByApiUrlPermission(clientId, apiUrl, token);
log.info("roleIds is :{}", roleIds);
//return invalidClientIdMono(exchange);

+ 4
- 1
src/main/java/com/tuoheng/gateway/utils/GatewayUrlPathUtil.java 查看文件

@@ -65,8 +65,11 @@ public class GatewayUrlPathUtil {
if(clientId.equals(HHZ_ADMIN) || clientId.equals(HHZ_MP)){
url = CommonsConfig.hhzPermissionUrl;
}
if(clientId.equals(FREEWAY_ADMIN) || clientId.equals(FREEWAY_MP)){
url = CommonsConfig.freewayPermissionUrl;
}
log.info("getRoleIdByApiUrlPermission - url:{}", url);
if(StringUtils.isNotBlank(url)){
log.info("getRoleIdByApiUrlPermission - url:{}", url);
HttpHeaders resultRequestHeader = new HttpHeaders();
resultRequestHeader.add("Authorization", "Bearer " + token);
JSONObject json = new JSONObject();

+ 2
- 1
src/main/resources/application-dev.yml 查看文件

@@ -193,4 +193,5 @@ security:

# 获取 apiUrl 可访问的 roleIdList
tuoheng:
hhz-admin-perUrl: http://192.168.11.11:9055/permission/getRoleIdList
hhz-admin-perUrl: http://192.168.11.11:9055/permission/getRoleIdList
freeway-admin-perUrl: http://192.168.11.11:9117/permission/getRoleIdList

+ 2
- 1
src/main/resources/application-local.yml 查看文件

@@ -192,4 +192,5 @@ security:

# 获取 apiUrl 可访问的 roleIdList
tuoheng:
hhz-admin-perUrl: http://127.0.0.1:9055/api/permission/getRoleIdList
hhz-admin-perUrl: http://127.0.0.1:9055/api/permission/getRoleIdList
freeway-admin-perUrl:

+ 1
- 0
src/main/resources/application-prod.yml 查看文件

@@ -186,3 +186,4 @@ security:
# 获取 apiUrl 可访问的 roleIdList
tuoheng:
hhz-admin-perUrl: https://hhz.t-aaron.com/permission/getRoleIdList
freeway-admin-perUrl:

+ 2
- 1
src/main/resources/application-test.yml 查看文件

@@ -186,4 +186,5 @@ security:

# 获取 apiUrl 可访问的 roleIdList
tuoheng:
hhz-admin-perUrl: http://172.15.1.21:9055/permission/getRoleIdList
hhz-admin-perUrl: http://172.15.1.21:9055/permission/getRoleIdList
freeway-admin-perUrl:

Loading…
取消
儲存