feat: 添加流水分析客户端(接口1-3)
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
package com.ruoyi.lsfx.client;
|
||||
|
||||
import com.ruoyi.lsfx.constants.LsfxConstants;
|
||||
import com.ruoyi.lsfx.domain.request.*;
|
||||
import com.ruoyi.lsfx.domain.response.*;
|
||||
import com.ruoyi.lsfx.util.HttpUtil;
|
||||
import com.ruoyi.lsfx.util.MD5Util;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流水分析平台客户端
|
||||
*/
|
||||
@Component
|
||||
public class LsfxAnalysisClient {
|
||||
|
||||
@Resource
|
||||
private HttpUtil httpUtil;
|
||||
|
||||
@Value("${lsfx.api.base-url}")
|
||||
private String baseUrl;
|
||||
|
||||
@Value("${lsfx.api.app-id}")
|
||||
private String appId;
|
||||
|
||||
@Value("${lsfx.api.app-secret}")
|
||||
private String appSecret;
|
||||
|
||||
@Value("${lsfx.api.client-id}")
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
* 获取Token
|
||||
*/
|
||||
public GetTokenResponse getToken(GetTokenRequest request) {
|
||||
String secretCode = MD5Util.generateSecretCode(
|
||||
request.getProjectNo(),
|
||||
request.getEntityName(),
|
||||
appSecret
|
||||
);
|
||||
request.setAppSecretCode(secretCode);
|
||||
request.setAppId(appId);
|
||||
|
||||
if (request.getAnalysisType() == null) {
|
||||
request.setAnalysisType(LsfxConstants.ANALYSIS_TYPE);
|
||||
}
|
||||
if (request.getRole() == null) {
|
||||
request.setRole(LsfxConstants.DEFAULT_ROLE);
|
||||
}
|
||||
|
||||
String url = baseUrl + "/account/common/getToken";
|
||||
return httpUtil.postJson(url, request, GetTokenResponse.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
public UploadFileResponse uploadFile(Integer groupId, Resource file) {
|
||||
String url = baseUrl + "/watson/api/project/remoteUploadSplitFile";
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("groupId", groupId);
|
||||
params.put("files", file);
|
||||
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put(LsfxConstants.HEADER_CLIENT_ID, clientId);
|
||||
|
||||
return httpUtil.uploadFile(url, params, headers, UploadFileResponse.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取行内流水
|
||||
*/
|
||||
public FetchInnerFlowResponse fetchInnerFlow(FetchInnerFlowRequest request) {
|
||||
String url = baseUrl + "/watson/api/project/getJZFileOrZjrcuFile";
|
||||
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put(LsfxConstants.HEADER_CLIENT_ID, clientId);
|
||||
|
||||
return httpUtil.postJson(url, request, headers, FetchInnerFlowResponse.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user