mirror of
https://github.com/yanlongqi/jhinno-openapi-java-sdk.git
synced 2026-03-22 06:15:10 +08:00
refactor: 优化API执行器架构和HTTP客户端配置
引入JHApiExecutionAbstract抽象类统一管理API执行器,所有执行器从实现JHApiExecution接口改为继承该抽象类,简化代码结构并提高可扩展性。同时优化HTTP客户端配置的灵活性,支持按需配置超时和连接参数。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
package com.jhinno.sdk.openapi.example.api.extend;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.jhinno.sdk.openapi.JHApiExecution;
|
||||
import com.jhinno.sdk.openapi.api.JHRequestExecution;
|
||||
import com.jhinno.sdk.openapi.JHApiExecutionAbstract;
|
||||
import com.jhinno.sdk.openapi.api.ResponseResult;
|
||||
import com.jhinno.sdk.openapi.client.JHApiClient;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -12,44 +11,22 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class JHFileApiExtendExecution implements JHApiExecution {
|
||||
public class JHFileApiExtendExecution extends JHApiExecutionAbstract {
|
||||
|
||||
private JHRequestExecution execution;
|
||||
public static String GET_FILE_ENV_PATH = "/appform/ws/api/files/path/{env}";
|
||||
|
||||
@Override
|
||||
public void init(JHRequestExecution execution) {
|
||||
this.execution = execution;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除作业
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param jobId 作业ID
|
||||
*/
|
||||
public void deleteJob(String username, String jobId) {
|
||||
execution.delete("/appform/ws/api/jobs/" + jobId, username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取集群的应用的CPU核数和排队作业数
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param jobQueue 队列,没有要求就填写normal
|
||||
* @param jobPlatform 作业查询条件,如:type==LINUX64
|
||||
* @param appName 应用ID,如:common_sub
|
||||
* @return
|
||||
*/
|
||||
public JobTooltipDTO getJobTooltipInfo(String username, String jobQueue, String jobPlatform, String appName) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("jobQueue", jobQueue);
|
||||
params.put("jobPlatform", jobPlatform);
|
||||
params.put("isTestApp", false);
|
||||
params.put("appName", appName);
|
||||
String path = JHApiClient.getUrl("/appform/ws/api/jobs/tooltip", params);
|
||||
return execution.get(path, username, new TypeReference<ResponseResult<JobTooltipDTO>>() {
|
||||
public FilePath getFileEnvPath(String username, FileEnvType env, FileSystemType type) {
|
||||
Map<String, Object> params = new HashMap<>(1);
|
||||
if (StringUtils.isNotBlank(type.getType())) {
|
||||
params.put("type", type.getType());
|
||||
}
|
||||
String url = JHApiClient.getUrl(GET_FILE_ENV_PATH.replace("{env}", env.getEnv()), params);
|
||||
return execution.get(url, username, new TypeReference<ResponseResult<FilePath>>() {
|
||||
});
|
||||
}
|
||||
|
||||
public FilePath getFileHomeEnvPath(String username, FileSystemType type) {
|
||||
return getFileEnvPath(username, FileEnvType.HOME_ENV, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user