PageRepository.ets 1.45 KB
import { ResponseDTO, WDHttp } from 'wdNetwork';
import { NavigationBodyDTO } from './bean/NavigationBodyDTO';
import { PageDTO } from './bean/PageDTO';
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils } from '../network/HttpUrlUtils';
import { InteractDataDTO } from './bean/InteractDataDTO';

export class PageRepository {
  static fetchNavigationDataApi() {
    let url = HttpUrlUtils.getBottomNavGroupUrl();
    let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
    return WDHttp.get<ResponseDTO<NavigationBodyDTO>>(url, headers)
  };

  static fetchPageData(pageId: string, groupId: string, channelId: string, currentPage: number
                       , pageSize: number) {
    let url = HttpUrlUtils.getCompInfoUrl(pageId, groupId, channelId, currentPage, pageSize)
    let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
    return WDHttp.get<ResponseDTO<PageDTO>>(url, headers)
  };

  static fetchDetailData(relId: string, contentId: string, relType: string) {
    let url = HttpUrlUtils.getDetailInfoUrl(relId, contentId, relType)
    let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
    return WDHttp.get<ResponseDTO<string>>(url, headers)
  };

  static fetchInteractData(param: object) {
    let url = HttpUrlUtils.getInteractDataUrl()
    let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
    return WDHttp.post<ResponseDTO<InteractDataDTO[]>>(url, param, headers)
  };
}