index.ts
3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import { ProfileRecord } from '../device/model/deviceConfigModel';
import {
CreateOtaPackageParams,
DefaultDeviceProfileInfo,
DeviceProfileRecord,
GetDeviceProfileInfosParams,
GetOtaPackagesParams,
OtaRecordDatum,
TBResponse,
UploadOtaPackagesParams,
} from './model';
import { defHttp } from '/@/utils/http/axios';
enum Api {
GET_OTA_PACKAGES = '/otaPackages',
CREATE_OTA_PACKAGES = '/otaPackage',
UPLOAD_OTA_PACKAGES = '/otaPackage',
DELETE_OTA_PACKAGES = '/otaPackage',
GET_DEVICE_PROFILE_INFO_DEFAULT = '/deviceProfileInfo/default',
GET_OTA_PACKAGE_INFO = '/otaPackage/info',
DOWNLOAD_PACKAGE = '/otaPackage',
GET_DEVICE_PROFILE_INFO_BY_ID = '/deviceProfileInfo',
GET_DEVICE_PROFILE_INFOS = '/deviceProfileInfos',
}
/**
* @description 获取ota包列表
* @param params
* @returns
*/
export const getOtaPackagesList = (params: GetOtaPackagesParams) => {
return defHttp.get<TBResponse<OtaRecordDatum>>(
{
url: Api.GET_OTA_PACKAGES,
params,
},
{
joinPrefix: false,
}
);
};
/**
* @description 创建ota包
* @param params
* @returns
*/
export const createOtaPackage = (params: CreateOtaPackageParams) => {
return defHttp.post<OtaRecordDatum>(
{
url: Api.CREATE_OTA_PACKAGES,
params,
},
{ joinPrefix: false }
);
};
/**
* @description 上传ota包
* @param param
* @returns
*/
export const uploadOtaPackages = (params: UploadOtaPackagesParams) => {
return defHttp.post(
{
url: `${Api.UPLOAD_OTA_PACKAGES}/${params.otaPackageId}?checksumAlgorithm=${
params.checksumAlgorithm
}${params.checksum ? `&checksum=${params.checksum}` : ''}`,
params: params.file,
},
{ joinPrefix: false }
);
};
/**
* @description 获取设备默认信息
* @returns
*/
export const getDefaultDeviceProfile = () => {
return defHttp.get<DefaultDeviceProfileInfo>(
{
url: Api.GET_DEVICE_PROFILE_INFO_DEFAULT,
},
{
joinPrefix: false,
}
);
};
export const deleteOtaPackage = (id: string) => {
return defHttp.delete(
{
url: `${Api.DELETE_OTA_PACKAGES}/${id}`,
},
{ joinPrefix: false }
);
};
export const getOtaPackageInfo = (id: string) => {
return defHttp.get<OtaRecordDatum>(
{
url: `${Api.GET_OTA_PACKAGE_INFO}/${id}`,
},
{
joinPrefix: false,
}
);
};
export const downloadPackage = (id: string) => {
return defHttp.get({ url: `${Api.DOWNLOAD_PACKAGE}/${id}/download` }, { joinPrefix: false });
};
export const getDeviceProfileInfos = (params: GetDeviceProfileInfosParams) => {
const { page = 0, pageSize = 10, sortOrder = 'ASC', sortProperty = 'name', textSearch } = params;
return defHttp.get<TBResponse<DeviceProfileRecord>>(
{
url: `${Api.GET_DEVICE_PROFILE_INFOS}`,
params: {
page,
pageSize,
sortOrder,
sortProperty,
textSearch,
},
},
{ joinPrefix: false }
);
};
export const getDeviceProfileInfoById = (id: string) => {
return defHttp.get<ProfileRecord>(
{
url: `${Api.GET_DEVICE_PROFILE_INFO_BY_ID}/${id}`,
},
{ joinPrefix: false }
);
};