feat: 完成数码管websocket通信
This commit is contained in:
226
src/APIClient.ts
226
src/APIClient.ts
@@ -1675,6 +1675,54 @@ export class DataClient {
|
||||
}
|
||||
return Promise.resolve<number>(null as any);
|
||||
}
|
||||
|
||||
addEmptyBoard( cancelToken?: CancelToken): Promise<void> {
|
||||
let url_ = this.baseUrl + "/api/Data/AddEmptyBoard";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
let options_: AxiosRequestConfig = {
|
||||
method: "POST",
|
||||
url: url_,
|
||||
headers: {
|
||||
},
|
||||
cancelToken
|
||||
};
|
||||
|
||||
return this.instance.request(options_).catch((_error: any) => {
|
||||
if (isAxiosError(_error) && _error.response) {
|
||||
return _error.response;
|
||||
} else {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processAddEmptyBoard(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processAddEmptyBoard(response: AxiosResponse): Promise<void> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
for (const k in response.headers) {
|
||||
if (response.headers.hasOwnProperty(k)) {
|
||||
_headers[k] = response.headers[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status === 200) {
|
||||
const _responseText = response.data;
|
||||
return Promise.resolve<void>(null as any);
|
||||
|
||||
} else if (status === 500) {
|
||||
const _responseText = response.data;
|
||||
return throwException("A server side error occurred.", status, _responseText, _headers);
|
||||
|
||||
} else if (status !== 200 && status !== 204) {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<void>(null as any);
|
||||
}
|
||||
}
|
||||
|
||||
export class DDSClient {
|
||||
@@ -2840,7 +2888,7 @@ export class ExamClient {
|
||||
* @param file (optional) 提交的文件
|
||||
* @return 提交结果
|
||||
*/
|
||||
submitCommit(examId: string, file: FileParameter | undefined, cancelToken?: CancelToken): Promise<Commit> {
|
||||
commit(examId: string, file: FileParameter | undefined, cancelToken?: CancelToken): Promise<ResourceInfo> {
|
||||
let url_ = this.baseUrl + "/api/Exam/commit/{examId}";
|
||||
if (examId === undefined || examId === null)
|
||||
throw new Error("The parameter 'examId' must be defined.");
|
||||
@@ -2870,11 +2918,11 @@ export class ExamClient {
|
||||
throw _error;
|
||||
}
|
||||
}).then((_response: AxiosResponse) => {
|
||||
return this.processSubmitCommit(_response);
|
||||
return this.processCommit(_response);
|
||||
});
|
||||
}
|
||||
|
||||
protected processSubmitCommit(response: AxiosResponse): Promise<Commit> {
|
||||
protected processCommit(response: AxiosResponse): Promise<ResourceInfo> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
@@ -2888,8 +2936,8 @@ export class ExamClient {
|
||||
const _responseText = response.data;
|
||||
let result201: any = null;
|
||||
let resultData201 = _responseText;
|
||||
result201 = Commit.fromJS(resultData201);
|
||||
return Promise.resolve<Commit>(result201);
|
||||
result201 = ResourceInfo.fromJS(resultData201);
|
||||
return Promise.resolve<ResourceInfo>(result201);
|
||||
|
||||
} else if (status === 400) {
|
||||
const _responseText = response.data;
|
||||
@@ -2920,7 +2968,7 @@ export class ExamClient {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<Commit>(null as any);
|
||||
return Promise.resolve<ResourceInfo>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2928,7 +2976,7 @@ export class ExamClient {
|
||||
* @param examId 实验ID
|
||||
* @return 提交记录列表
|
||||
*/
|
||||
getCommitsByExamId(examId: string, cancelToken?: CancelToken): Promise<Commit[]> {
|
||||
getCommitsByExamId(examId: string, cancelToken?: CancelToken): Promise<ResourceInfo[]> {
|
||||
let url_ = this.baseUrl + "/api/Exam/commits/{examId}";
|
||||
if (examId === undefined || examId === null)
|
||||
throw new Error("The parameter 'examId' must be defined.");
|
||||
@@ -2955,7 +3003,7 @@ export class ExamClient {
|
||||
});
|
||||
}
|
||||
|
||||
protected processGetCommitsByExamId(response: AxiosResponse): Promise<Commit[]> {
|
||||
protected processGetCommitsByExamId(response: AxiosResponse): Promise<ResourceInfo[]> {
|
||||
const status = response.status;
|
||||
let _headers: any = {};
|
||||
if (response.headers && typeof response.headers === "object") {
|
||||
@@ -2972,12 +3020,12 @@ export class ExamClient {
|
||||
if (Array.isArray(resultData200)) {
|
||||
result200 = [] as any;
|
||||
for (let item of resultData200)
|
||||
result200!.push(Commit.fromJS(item));
|
||||
result200!.push(ResourceInfo.fromJS(item));
|
||||
}
|
||||
else {
|
||||
result200 = <any>null;
|
||||
}
|
||||
return Promise.resolve<Commit[]>(result200);
|
||||
return Promise.resolve<ResourceInfo[]>(result200);
|
||||
|
||||
} else if (status === 400) {
|
||||
const _responseText = response.data;
|
||||
@@ -3008,7 +3056,7 @@ export class ExamClient {
|
||||
const _responseText = response.data;
|
||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
}
|
||||
return Promise.resolve<Commit[]>(null as any);
|
||||
return Promise.resolve<ResourceInfo[]>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6562,7 +6610,7 @@ export class ResourceClient {
|
||||
* @param file (optional) 资源文件
|
||||
* @return 添加结果
|
||||
*/
|
||||
addResource(resourceType: string | undefined, resourcePurpose: string | undefined, examID: string | null | undefined, file: FileParameter | undefined, cancelToken?: CancelToken): Promise<ResourceInfo> {
|
||||
addResource(resourceType: string | undefined, resourcePurpose: ResourcePurpose | undefined, examID: string | null | undefined, file: FileParameter | undefined, cancelToken?: CancelToken): Promise<ResourceInfo> {
|
||||
let url_ = this.baseUrl + "/api/Resource";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
@@ -6659,7 +6707,7 @@ export class ResourceClient {
|
||||
* @param resourcePurpose (optional) 资源用途(可选)
|
||||
* @return 资源列表
|
||||
*/
|
||||
getResourceList(examId: string | null | undefined, resourceType: string | null | undefined, resourcePurpose: string | null | undefined, cancelToken?: CancelToken): Promise<ResourceInfo[]> {
|
||||
getResourceList(examId: string | null | undefined, resourceType: string | null | undefined, resourcePurpose: ResourcePurpose | null | undefined, cancelToken?: CancelToken): Promise<ResourceInfo[]> {
|
||||
let url_ = this.baseUrl + "/api/Resource?";
|
||||
if (examId !== undefined && examId !== null)
|
||||
url_ += "examId=" + encodeURIComponent("" + examId) + "&";
|
||||
@@ -8330,18 +8378,24 @@ export interface IExamDto {
|
||||
isVisibleToUsers: boolean;
|
||||
}
|
||||
|
||||
export class Commit implements ICommit {
|
||||
/** 资源的唯一标识符 */
|
||||
/** 资源信息类 */
|
||||
export class ResourceInfo implements IResourceInfo {
|
||||
/** 资源ID */
|
||||
id!: string;
|
||||
/** 上传资源的用户ID */
|
||||
userID!: string;
|
||||
/** 所属实验ID */
|
||||
/** 资源名称 */
|
||||
name!: string;
|
||||
/** 资源类型 */
|
||||
type!: string;
|
||||
/** 资源用途(template/user) */
|
||||
purpose!: ResourcePurpose;
|
||||
/** 上传时间 */
|
||||
uploadTime!: Date;
|
||||
/** 所属实验ID(可选) */
|
||||
examID?: string | undefined;
|
||||
type!: CommitType;
|
||||
resourceID!: string;
|
||||
createdAt!: Date;
|
||||
/** MIME类型 */
|
||||
mimeType?: string | undefined;
|
||||
|
||||
constructor(data?: ICommit) {
|
||||
constructor(data?: IResourceInfo) {
|
||||
if (data) {
|
||||
for (var property in data) {
|
||||
if (data.hasOwnProperty(property))
|
||||
@@ -8353,17 +8407,18 @@ export class Commit implements ICommit {
|
||||
init(_data?: any) {
|
||||
if (_data) {
|
||||
this.id = _data["id"];
|
||||
this.userID = _data["userID"];
|
||||
this.examID = _data["examID"];
|
||||
this.name = _data["name"];
|
||||
this.type = _data["type"];
|
||||
this.resourceID = _data["resourceID"];
|
||||
this.createdAt = _data["createdAt"] ? new Date(_data["createdAt"].toString()) : <any>undefined;
|
||||
this.purpose = _data["purpose"];
|
||||
this.uploadTime = _data["uploadTime"] ? new Date(_data["uploadTime"].toString()) : <any>undefined;
|
||||
this.examID = _data["examID"];
|
||||
this.mimeType = _data["mimeType"];
|
||||
}
|
||||
}
|
||||
|
||||
static fromJS(data: any): Commit {
|
||||
static fromJS(data: any): ResourceInfo {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
let result = new Commit();
|
||||
let result = new ResourceInfo();
|
||||
result.init(data);
|
||||
return result;
|
||||
}
|
||||
@@ -8371,31 +8426,38 @@ export class Commit implements ICommit {
|
||||
toJSON(data?: any) {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
data["id"] = this.id;
|
||||
data["userID"] = this.userID;
|
||||
data["examID"] = this.examID;
|
||||
data["name"] = this.name;
|
||||
data["type"] = this.type;
|
||||
data["resourceID"] = this.resourceID;
|
||||
data["createdAt"] = this.createdAt ? this.createdAt.toISOString() : <any>undefined;
|
||||
data["purpose"] = this.purpose;
|
||||
data["uploadTime"] = this.uploadTime ? this.uploadTime.toISOString() : <any>undefined;
|
||||
data["examID"] = this.examID;
|
||||
data["mimeType"] = this.mimeType;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
export interface ICommit {
|
||||
/** 资源的唯一标识符 */
|
||||
/** 资源信息类 */
|
||||
export interface IResourceInfo {
|
||||
/** 资源ID */
|
||||
id: string;
|
||||
/** 上传资源的用户ID */
|
||||
userID: string;
|
||||
/** 所属实验ID */
|
||||
/** 资源名称 */
|
||||
name: string;
|
||||
/** 资源类型 */
|
||||
type: string;
|
||||
/** 资源用途(template/user) */
|
||||
purpose: ResourcePurpose;
|
||||
/** 上传时间 */
|
||||
uploadTime: Date;
|
||||
/** 所属实验ID(可选) */
|
||||
examID?: string | undefined;
|
||||
type: CommitType;
|
||||
resourceID: string;
|
||||
createdAt: Date;
|
||||
/** MIME类型 */
|
||||
mimeType?: string | undefined;
|
||||
}
|
||||
|
||||
export enum CommitType {
|
||||
Homework = 0,
|
||||
Project = 1,
|
||||
Markdown = 2,
|
||||
export enum ResourcePurpose {
|
||||
Template = 0,
|
||||
User = 1,
|
||||
Homework = 2,
|
||||
}
|
||||
|
||||
export class HdmiVideoStreamEndpoint implements IHdmiVideoStreamEndpoint {
|
||||
@@ -8913,82 +8975,6 @@ export interface IOscilloscopeDataResponse {
|
||||
waveformData: string;
|
||||
}
|
||||
|
||||
/** 资源信息类 */
|
||||
export class ResourceInfo implements IResourceInfo {
|
||||
/** 资源ID */
|
||||
id!: string;
|
||||
/** 资源名称 */
|
||||
name!: string;
|
||||
/** 资源类型 */
|
||||
type!: string;
|
||||
/** 资源用途(template/user) */
|
||||
purpose!: string;
|
||||
/** 上传时间 */
|
||||
uploadTime!: Date;
|
||||
/** 所属实验ID(可选) */
|
||||
examID?: string | undefined;
|
||||
/** MIME类型 */
|
||||
mimeType?: string | undefined;
|
||||
|
||||
constructor(data?: IResourceInfo) {
|
||||
if (data) {
|
||||
for (var property in data) {
|
||||
if (data.hasOwnProperty(property))
|
||||
(<any>this)[property] = (<any>data)[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(_data?: any) {
|
||||
if (_data) {
|
||||
this.id = _data["id"];
|
||||
this.name = _data["name"];
|
||||
this.type = _data["type"];
|
||||
this.purpose = _data["purpose"];
|
||||
this.uploadTime = _data["uploadTime"] ? new Date(_data["uploadTime"].toString()) : <any>undefined;
|
||||
this.examID = _data["examID"];
|
||||
this.mimeType = _data["mimeType"];
|
||||
}
|
||||
}
|
||||
|
||||
static fromJS(data: any): ResourceInfo {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
let result = new ResourceInfo();
|
||||
result.init(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
toJSON(data?: any) {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
data["id"] = this.id;
|
||||
data["name"] = this.name;
|
||||
data["type"] = this.type;
|
||||
data["purpose"] = this.purpose;
|
||||
data["uploadTime"] = this.uploadTime ? this.uploadTime.toISOString() : <any>undefined;
|
||||
data["examID"] = this.examID;
|
||||
data["mimeType"] = this.mimeType;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/** 资源信息类 */
|
||||
export interface IResourceInfo {
|
||||
/** 资源ID */
|
||||
id: string;
|
||||
/** 资源名称 */
|
||||
name: string;
|
||||
/** 资源类型 */
|
||||
type: string;
|
||||
/** 资源用途(template/user) */
|
||||
purpose: string;
|
||||
/** 上传时间 */
|
||||
uploadTime: Date;
|
||||
/** 所属实验ID(可选) */
|
||||
examID?: string | undefined;
|
||||
/** MIME类型 */
|
||||
mimeType?: string | undefined;
|
||||
}
|
||||
|
||||
/** Package options which to send address to read or write */
|
||||
export class SendAddrPackOptions implements ISendAddrPackOptions {
|
||||
/** 突发类型 */
|
||||
|
||||
Reference in New Issue
Block a user