查询会话列表

This commit is contained in:
lqyan
2024-02-03 13:39:34 +08:00
parent f113b988ba
commit fe225c6ba8
5 changed files with 79 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
package com.jhinno.sdk.openapi.api.app;
/**
* 关于会话请求路径的path
*
* @author yanlongqi
* @date 2024/2/1 16:27
*/
@@ -10,4 +12,9 @@ public class AppPathConstant {
* 申请会话
*/
public static final String APPS_START_PATH = "/ws/api/apps/{appId}/start";
/**
* 查询会列表
*/
public static final String APPS_SESSIONS_ALL_PATH = "/ws/api/apps/sessions/all";
}

View File

@@ -1,6 +1,8 @@
package com.jhinno.sdk.openapi.api.app;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 启动会话的请求参数
@@ -21,7 +23,7 @@ public class AppStartRequest {
/**
* 工作路径
* 工作路径(会话启动的路径)
*/
private String cwd;

View File

@@ -10,6 +10,7 @@ import com.jhinno.sdk.openapi.client.JHApiClient;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.Map;
/**
* @author yanlongqi
@@ -48,4 +49,37 @@ public class JHAppApiExecution extends JHApiExecution {
return data.get(0);
}
/**
* 使用默认参数启动应用
*
* @param username 用户名
* @param appId 应用id
* @return JHClient协议链接
*/
public AppStartedInfo desktopStart(String username, String appId) {
return this.desktopStart(username, appId, new AppStartRequest());
}
/**
* 查询当前用户的会话列表(管理员则查看所有用户的会话)
* <p>
* 注:开启密集后,仅能查看自己的会话和比自己密级低的会话
* </p>
*
* @return 会话列表
*/
public List<Map<String, Object>> getDesktopList(String username) {
ResponseResult<List<Map<String, Object>>> result = jhApiClient.get(
AppPathConstant.APPS_SESSIONS_ALL_PATH,
getHeaders(username),
new TypeReference<ResponseResult<List<Map<String, Object>>>>() {
});
if (StringUtils.equals(result.getResult(), CommonConstant.FAILED)) {
throw new ServiceException(AppPathConstant.APPS_SESSIONS_ALL_PATH, result.getCode(), result.getMessage());
}
return result.getData();
}
}