Browse Source

高速平台对接

pull/57/head
chenjiandong 1 year ago
parent
commit
b74bb476c7
7 changed files with 25 additions and 8 deletions
  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 View File

public class CommonsConfig { public class CommonsConfig {


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


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


@Value("${tuoheng.hhz-admin-perUrl}") @Value("${tuoheng.hhz-admin-perUrl}")
public void setPermissionUrl(String url) { public void setPermissionUrl(String url) {
hhzPermissionUrl = 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 View File

} }
//header里封装 Client-Id 信息 //header里封装 Client-Id 信息
String clientId = getClientId(exchange); String clientId = getClientId(exchange);
log.info("clientId is :{}", clientId);
if(!StringUtils.isEmpty(clientId)){ if(!StringUtils.isEmpty(clientId)){
log.info("clientId is :{}", clientId);
String requestUrl = exchange.getRequest().getPath().value(); String requestUrl = exchange.getRequest().getPath().value();
log.info("requestUrl is :{}", requestUrl);
//去除gateway path 前缀 //去除gateway path 前缀
String apiUrl = requestUrl.replace(GatewayUrlPathUtil.getPathByClientId(clientId),""); 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); List<Integer> roleIds = GatewayUrlPathUtil.getRoleIdByApiUrlPermission(clientId, apiUrl, token);
log.info("roleIds is :{}", roleIds); log.info("roleIds is :{}", roleIds);
//return invalidClientIdMono(exchange); //return invalidClientIdMono(exchange);

+ 4
- 1
src/main/java/com/tuoheng/gateway/utils/GatewayUrlPathUtil.java View File

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

+ 2
- 1
src/main/resources/application-dev.yml View File



# 获取 apiUrl 可访问的 roleIdList # 获取 apiUrl 可访问的 roleIdList
tuoheng: 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 View File



# 获取 apiUrl 可访问的 roleIdList # 获取 apiUrl 可访问的 roleIdList
tuoheng: 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 View File

# 获取 apiUrl 可访问的 roleIdList # 获取 apiUrl 可访问的 roleIdList
tuoheng: tuoheng:
hhz-admin-perUrl: https://hhz.t-aaron.com/permission/getRoleIdList hhz-admin-perUrl: https://hhz.t-aaron.com/permission/getRoleIdList
freeway-admin-perUrl:

+ 2
- 1
src/main/resources/application-test.yml View File



# 获取 apiUrl 可访问的 roleIdList # 获取 apiUrl 可访问的 roleIdList
tuoheng: 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…
Cancel
Save