feat: 实现可编辑已有的实验

This commit is contained in:
2025-08-13 16:11:06 +08:00
parent 76342553ad
commit 7a59c29e06
7 changed files with 578 additions and 593 deletions

View File

@@ -299,7 +299,7 @@ export class VideoStreamClient {
return Promise.resolve<boolean>(null as any);
}
setVideoStreamEnable(enable: boolean | undefined, cancelToken?: CancelToken): Promise<FileResponse | null> {
setVideoStreamEnable(enable: boolean | undefined, cancelToken?: CancelToken): Promise<any> {
let url_ = this.baseUrl + "/api/VideoStream/SetVideoStreamEnable?";
if (enable === null)
throw new Error("The parameter 'enable' cannot be null.");
@@ -308,11 +308,10 @@ export class VideoStreamClient {
url_ = url_.replace(/[?&]$/, "");
let options_: AxiosRequestConfig = {
responseType: "blob",
method: "POST",
url: url_,
headers: {
"Accept": "application/octet-stream"
"Accept": "application/json"
},
cancelToken
};
@@ -328,7 +327,7 @@ export class VideoStreamClient {
});
}
protected processSetVideoStreamEnable(response: AxiosResponse): Promise<FileResponse | null> {
protected processSetVideoStreamEnable(response: AxiosResponse): Promise<any> {
const status = response.status;
let _headers: any = {};
if (response.headers && typeof response.headers === "object") {
@@ -338,22 +337,27 @@ export class VideoStreamClient {
}
}
}
if (status === 200 || status === 206) {
const contentDisposition = response.headers ? response.headers["content-disposition"] : undefined;
let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
if (fileName) {
fileName = decodeURIComponent(fileName);
} else {
fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
}
return Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] }), headers: _headers });
if (status === 200) {
const _responseText = response.data;
let result200: any = null;
let resultData200 = _responseText;
result200 = resultData200 !== undefined ? resultData200 : <any>null;
return Promise.resolve<any>(result200);
} else if (status === 500) {
const _responseText = response.data;
let result500: any = null;
let resultData500 = _responseText;
result500 = resultData500 !== undefined ? resultData500 : <any>null;
return throwException("A server side error occurred.", status, _responseText, _headers, result500);
} else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve<FileResponse | null>(null as any);
return Promise.resolve<any>(null as any);
}
/**
@@ -2505,7 +2509,7 @@ export class ExamClient {
* 获取所有实验列表
* @return 实验列表
*/
getExamList( cancelToken?: CancelToken): Promise<ExamSummary[]> {
getExamList( cancelToken?: CancelToken): Promise<ExamInfo[]> {
let url_ = this.baseUrl + "/api/Exam/list";
url_ = url_.replace(/[?&]$/, "");
@@ -2529,7 +2533,7 @@ export class ExamClient {
});
}
protected processGetExamList(response: AxiosResponse): Promise<ExamSummary[]> {
protected processGetExamList(response: AxiosResponse): Promise<ExamInfo[]> {
const status = response.status;
let _headers: any = {};
if (response.headers && typeof response.headers === "object") {
@@ -2546,12 +2550,12 @@ export class ExamClient {
if (Array.isArray(resultData200)) {
result200 = [] as any;
for (let item of resultData200)
result200!.push(ExamSummary.fromJS(item));
result200!.push(ExamInfo.fromJS(item));
}
else {
result200 = <any>null;
}
return Promise.resolve<ExamSummary[]>(result200);
return Promise.resolve<ExamInfo[]>(result200);
} else if (status === 401) {
const _responseText = response.data;
@@ -2568,7 +2572,7 @@ export class ExamClient {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve<ExamSummary[]>(null as any);
return Promise.resolve<ExamInfo[]>(null as any);
}
/**
@@ -2657,8 +2661,8 @@ export class ExamClient {
* @param request 创建实验请求
* @return 创建结果
*/
createExam(request: CreateExamRequest, cancelToken?: CancelToken): Promise<ExamInfo> {
let url_ = this.baseUrl + "/api/Exam";
createExam(request: ExamDto, cancelToken?: CancelToken): Promise<ExamInfo> {
let url_ = this.baseUrl + "/api/Exam/create";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(request);
@@ -2740,6 +2744,95 @@ export class ExamClient {
}
return Promise.resolve<ExamInfo>(null as any);
}
/**
* 更新实验信息
* @param request 更新实验请求
* @return 更新结果
*/
updateExam(request: ExamDto, cancelToken?: CancelToken): Promise<ExamInfo> {
let url_ = this.baseUrl + "/api/Exam/update";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(request);
let options_: AxiosRequestConfig = {
data: content_,
method: "POST",
url: url_,
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
},
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.processUpdateExam(_response);
});
}
protected processUpdateExam(response: AxiosResponse): Promise<ExamInfo> {
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;
let result200: any = null;
let resultData200 = _responseText;
result200 = ExamInfo.fromJS(resultData200);
return Promise.resolve<ExamInfo>(result200);
} else if (status === 400) {
const _responseText = response.data;
let result400: any = null;
let resultData400 = _responseText;
result400 = ProblemDetails.fromJS(resultData400);
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
} else if (status === 401) {
const _responseText = response.data;
let result401: any = null;
let resultData401 = _responseText;
result401 = ProblemDetails.fromJS(resultData401);
return throwException("A server side error occurred.", status, _responseText, _headers, result401);
} else if (status === 403) {
const _responseText = response.data;
let result403: any = null;
let resultData403 = _responseText;
result403 = ProblemDetails.fromJS(resultData403);
return throwException("A server side error occurred.", status, _responseText, _headers, result403);
} else if (status === 404) {
const _responseText = response.data;
let result404: any = null;
let resultData404 = _responseText;
result404 = ProblemDetails.fromJS(resultData404);
return throwException("A server side error occurred.", status, _responseText, _headers, result404);
} 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<ExamInfo>(null as any);
}
}
export class HdmiVideoStreamClient {
@@ -7802,94 +7895,7 @@ export interface IChannelCaptureData {
data: string;
}
/** 实验简要信息类(用于列表显示) */
export class ExamSummary implements IExamSummary {
/** 实验的唯一标识符 */
id!: string;
/** 实验名称 */
name!: string;
/** 实验创建时间 */
createdTime!: Date;
/** 实验最后更新时间 */
updatedTime!: Date;
/** 实验标签 */
tags!: string[];
/** 实验难度1-5 */
difficulty!: number;
/** 普通用户是否可见 */
isVisibleToUsers!: boolean;
constructor(data?: IExamSummary) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
(<any>this)[property] = (<any>data)[property];
}
}
if (!data) {
this.tags = [];
}
}
init(_data?: any) {
if (_data) {
this.id = _data["id"];
this.name = _data["name"];
this.createdTime = _data["createdTime"] ? new Date(_data["createdTime"].toString()) : <any>undefined;
this.updatedTime = _data["updatedTime"] ? new Date(_data["updatedTime"].toString()) : <any>undefined;
if (Array.isArray(_data["tags"])) {
this.tags = [] as any;
for (let item of _data["tags"])
this.tags!.push(item);
}
this.difficulty = _data["difficulty"];
this.isVisibleToUsers = _data["isVisibleToUsers"];
}
}
static fromJS(data: any): ExamSummary {
data = typeof data === 'object' ? data : {};
let result = new ExamSummary();
result.init(data);
return result;
}
toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["id"] = this.id;
data["name"] = this.name;
data["createdTime"] = this.createdTime ? this.createdTime.toISOString() : <any>undefined;
data["updatedTime"] = this.updatedTime ? this.updatedTime.toISOString() : <any>undefined;
if (Array.isArray(this.tags)) {
data["tags"] = [];
for (let item of this.tags)
data["tags"].push(item);
}
data["difficulty"] = this.difficulty;
data["isVisibleToUsers"] = this.isVisibleToUsers;
return data;
}
}
/** 实验简要信息类(用于列表显示) */
export interface IExamSummary {
/** 实验的唯一标识符 */
id: string;
/** 实验名称 */
name: string;
/** 实验创建时间 */
createdTime: Date;
/** 实验最后更新时间 */
updatedTime: Date;
/** 实验标签 */
tags: string[];
/** 实验难度1-5 */
difficulty: number;
/** 普通用户是否可见 */
isVisibleToUsers: boolean;
}
/** 实验信息类 */
/** 实验信息 */
export class ExamInfo implements IExamInfo {
/** 实验的唯一标识符 */
id!: string;
@@ -7962,7 +7968,7 @@ export class ExamInfo implements IExamInfo {
}
}
/** 实验信息 */
/** 实验信息 */
export interface IExamInfo {
/** 实验的唯一标识符 */
id: string;
@@ -7982,9 +7988,9 @@ export interface IExamInfo {
isVisibleToUsers: boolean;
}
/** 创建实验请求类 */
export class CreateExamRequest implements ICreateExamRequest {
/** 实验ID */
/** 统一的实验数据传输对象 */
export class ExamDto implements IExamDto {
/** 实验的唯一标识符 */
id!: string;
/** 实验名称 */
name!: string;
@@ -7997,7 +8003,7 @@ export class CreateExamRequest implements ICreateExamRequest {
/** 普通用户是否可见 */
isVisibleToUsers!: boolean;
constructor(data?: ICreateExamRequest) {
constructor(data?: IExamDto) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
@@ -8024,9 +8030,9 @@ export class CreateExamRequest implements ICreateExamRequest {
}
}
static fromJS(data: any): CreateExamRequest {
static fromJS(data: any): ExamDto {
data = typeof data === 'object' ? data : {};
let result = new CreateExamRequest();
let result = new ExamDto();
result.init(data);
return result;
}
@@ -8047,9 +8053,9 @@ export class CreateExamRequest implements ICreateExamRequest {
}
}
/** 创建实验请求类 */
export interface ICreateExamRequest {
/** 实验ID */
/** 统一的实验数据传输对象 */
export interface IExamDto {
/** 实验的唯一标识符 */
id: string;
/** 实验名称 */
name: string;