增加点播接口响应控制层方法

This commit is contained in:
龚皓 2024-10-18 14:42:29 +08:00
parent 7834169b50
commit 26e326dd1d
1 changed files with 44 additions and 0 deletions

View File

@ -14,6 +14,8 @@ class BoxApi {
private readonly apiAlgorithms: string = "/algorithms"; private readonly apiAlgorithms: string = "/algorithms";
private readonly apiResetUser: string = "/auth/resetuser"; private readonly apiResetUser: string = "/auth/resetuser";
private readonly apiResetPassword: string = "/auth/reset_password"; private readonly apiResetPassword: string = "/auth/reset_password";
private readonly getMinCamerasApi: string = "/camera/cameras/get_all";
private readonly getMinCamera: string = "/camera/cameras";
private readonly loginConfig: object = { private readonly loginConfig: object = {
headers: { headers: {
@ -210,6 +212,48 @@ class BoxApi {
return await this.getCamerasByUrl(url, token); return await this.getCamerasByUrl(url, token);
} }
public async getMinCameras(token: string | null = null): Promise<any> {
const url = `${this.getMinCamerasApi}`;
try {
const res = await this.axios.get(url, this._authHeader(token));
if (res.data.err.ec === 0) {
return res.data.ret;
} else {
throw new Error(res.data.err.msg);
}
} catch (error) {
throw error;
}
}
public async startCameraStream(token: string | null = null, cameraId: number): Promise<any> {
const url = `${this.getMinCamera}/${cameraId}/start_stream`;
try {
const res = await this.axios.post(url, this._authHeader(token));
if (res.data.err.ec === 0) {
return res.data.ret;
} else {
throw new Error(res.data.err.msg);
}
} catch (error) {
throw error;
}
}
public async stopCameraStream(token: string | null = null, cameraId: number): Promise<any> {
const url = `${this.getMinCamera}/${cameraId}/stop_stream`;
try {
const res = await this.axios.post(url, this._authHeader(token));
if (res.data.err.ec === 0) {
return res.data.ret;
} else {
throw new Error(res.data.err.dm);
}
} catch (error) {
throw error;
}
}
public async getEventsByUrl(url: string, token: string | null = null): Promise<any> { public async getEventsByUrl(url: string, token: string | null = null): Promise<any> {
try { try {
const res = await this.axios.get(url, this._authHeader(token)); const res = await this.axios.get(url, this._authHeader(token));