Commit 3599e8fe authored by 郭人方's avatar 郭人方

docs:LDP框架filter修改说明文档。

parent 7ab34708
# LDP 框架filter添加前端标识说明
表:ldp_uaa_app_client添加字段front_app_id
添加脚本:V1.1.7__alter_ldp_uaa_app_client.sql
依赖包:
<dependency>
<groupId>com.sinra.ldp</groupId>
<artifactId>base-api</artifactId>
<version>${ldp.version}</version>
</dependency>
```java
/**
* service-uaa 添加接口 ,类:AppClientRest.java 根据frontAppId 获取信息
*
* @param frontAppId
* @return
*/
@GetMapping("/getByFrontAppId")
public List<LdpUaaAppClient> getByFrontAppId(String frontAppId) {
List<LdpUaaAppClient> ldpUaaAppClient = appClientService.getByFrontAppId(StringUtils.EMPTY,frontAppId);
return ldpUaaAppClient;
}
// Sql 脚本:
<query id="select_app_client_list_by_frontappid" author="machao" remark="通过frontappid获取UAA客户端信息" >
<sql>
<![CDATA[
SELECT
c.app_id,
c.front_app_id,
c.auth_realm
FROM
ldp_uaa_app_client c
JOIN ldp_uaa_auth_realm r ON c.auth_realm = r.id
WHERE
c.status=1
AND c.del_flag=0
AND c.front_app_id = :frontAppId #
]]>
</sql>
</query>
```
```java
/**
* 使用地方 LoginForwordFilter.java line 191 ~ 205
* @param tokenStr token字符
* @return
*/
RouteApp getRouteApp(String frontappId) {
RouteApp routeApp = ldpUaaProperties.getRouteApps().
stream().filter(appinfo -> (appinfo.getId() != null && frontappId.indexOf(appinfo.getId()) >= 0)).findFirst().get();
if (null == routeApp) {
ResponseEntity<Map> responseEntity = restTemplate.getForEntity("http://mcs-service/uaa/backend/client/getByFrontAppId?frontAppId=" + frontappId, Map.class);
System.out.println(responseEntity.getBody());
if (responseEntity.getStatusCode() == HttpStatus.OK
&& CommonConstants.SUCCESS.equals(responseEntity.getBody().get("code"))) {
if (null != responseEntity.getBody().get("data")) {
List list = (ArrayList) responseEntity.getBody().get("data");
LinkedHashMap<String, String> map = (LinkedHashMap) list.get(0);
routeApp.setId(map.get("frontAppId"));
routeApp.setRealmcode(map.get("authRealm"));
routeApp.setClientid(map.get("appId"));
}
}
}
return routeApp;
}
```
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment