LiveModel.ets
1.24 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
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { Logger } from 'wdKit';
import { LiveDetailsBean } from 'wdBean/Index';
const TAG = 'LiveModel'
export class LiveModel {
/**
* 直播内容详情
* @param contentId
* @param relId 关系id
* @param relType 关系类型;1.频道关系;2.专题关系;
* @returns
*/
static getLiveDetails(contentId: string, relId: string, relType: string) {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<Array<LiveDetailsBean>>((success, fail) => {
HttpRequest.get<ResponseDTO<Array<LiveDetailsBean>>>(
HttpUrlUtils.getLiveDetailsUrl() + `?relId=${relId}&relType=${relType}&contentId=${contentId}`,
headers).then((data: ResponseDTO<Array<LiveDetailsBean>>) => {
if (!data || !data.data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data)
}, (error: Error) => {
fail(error.message)
Logger.debug(TAG + ":error ", error.toString())
})
})
}
}