ContentDetailRequest.ets
3.1 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
import { Logger, ResourcesUtils } from 'wdKit';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { ContentDetailDTO, InteractDataDTO } from 'wdBean';
import HashMap from '@ohos.util.HashMap';
const TAG = 'ContentDetailRequest';
const mock_switch = false;
export interface ContentDetailRequestParams {
contentId: string
relId: string
relType: string
}
export interface recommentVideoListParame {
pageSize: number;
refreshCnt: number;
}
interface contentListItem {
contentId: string;
contentType: number;
}
export interface contentListParams {
contentList: contentListItem[];
}
export class ContentDetailRequest {
static getContentDetailDataMock(context: Context): Promise<ResponseDTO<ContentDetailDTO[]>> {
Logger.info(TAG, `getContentDetailDataMock start`);
return ResourcesUtils.getResourcesJson<ResponseDTO<ContentDetailDTO[]>>(context, 'content_detail2.json')
}
// /**
// * 现网-新闻内容详情域名
// */
// static readonly HOST2: string = "https://pdapis.pdnews.cn";
/**
* 新闻内容详情【get】接口
*/
// static readonly CONTENT_DETAIL_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail";
static getContentDetailUrl(contentId: string, relId: string, relType: string) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH
url = url + "?&contentId=" + contentId
+ "&relId=" + relId
+ "&relType=" + relType;
return url;
}
static getContentDetail(params: ContentDetailRequestParams): Promise<ResponseDTO<ContentDetailDTO[]>> {
if (mock_switch) {
return ContentDetailRequest.getContentDetailDataMock(getContext());
}
let url = ContentDetailRequest.getContentDetailUrl(params.contentId, params.relId, params.relType)
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<ContentDetailDTO[]>>(url, headers)
}
/**
*
* @returns
*/
static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
}
/**
*
* @returns
*/
static postBatchLikeAndCollectStatus() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_STATUS
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post(url, headers)
}
/**
*
* @returns
*/
static postBatchAttentionStatus() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post(url, headers)
}
/**
* 沉浸式視頻查詢近20条数据
* @returns
*/
static postRecommendVideoList(params: recommentVideoListParame): Promise<ResponseDTO<ContentDetailDTO[]>> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_VIDEOLIST
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.post0(url, params, headers)
}
}