ContentDetailRequest.ets 11.2 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
import { Logger, ResourcesUtils, EmitterUtils, EmitterEventId } from 'wdKit';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { ContentDetailDTO, GetPullAddressBean, InteractDataDTO, PeopleShipNextListDTO } from 'wdBean';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';

const TAG = 'ContentDetailRequest';

const mock_switch = false;

export interface RmhPublishNextsParams {
  creatorId: string
  contentId: string
  contentType: number
  nextFlag: number
  pageSize: number
  refreshTime:number
}

export interface ContentDetailRequestParams {
  contentId: string
  relId: string
  relType: string
}

export interface contentsItem {
  contentId: string;
  contentRelId: string;
  contentType: number;
  relId: string;
  relType: string;
}

export interface batchContentDetailParams {
  contents: contentsItem[]
}

export interface recommentVideoListParams {
  pageSize: number;
  refreshCnt: number;
}

interface contentListItem {
  contentId: string;
  contentType: number;
  contentRelId?:string
}

export interface contentListParams {
  contentList: contentListItem[];
}

export interface getRecCompInfoParams {
  groupId: string;
  pageId: string;
  channelId: string;
  loadStrategy: string;
  channelStrategy: string;
  pageNum: number;
  pageSize: number;
  refreshTime: number;
}


// 为空的值不声明,需要时再加
export interface operDataListItem {
  objectId: string;
  objectType: string;
  relId: string;
  relType: string;
  channelId: string;
}

export interface compListItem {
  compStyle: string;
  compType: string;
  hasMore: number;
  recommend: number;
  operDataList: operDataListItem[];
}

export interface getRecCompInfoResult {
  blockDesc: string;
  id: number;
  name: string;
  pageId: string;
  pageNum: number;
  pageSize: number;
  recommend: number;
  totalCount: number;
  compList: compListItem[]
}

export interface IStatusContentList {
  contentId: string;

  // relType: string;
  contentType: string;
  contentRelId: string;
}

export interface batchLikeAndCollectParams {
  // userType: number;
  // userId: string;
  contentList: IStatusContentList[]
}

export interface batchLikeAndCollectResult {
  collectStatus: number;
  contentType: string;
  likeStatus: string;
  relType: string;
  contentId: string;
  contentRelId: string;
}

export interface postBatchAttentionStatusParamsItem {
  creatorId: string;
}

export interface postBatchAttentionStatusParams {
  creatorIds: postBatchAttentionStatusParamsItem[]
}

export interface postBatchAttentionStatusResult {
  creatorId: string;
  status: string;
  userId: string;
}


export interface postExecuteLikeParams {
  status: number;
  contentId: string;
  contentType: string;
  relType?: string;
  userName?: string;
  title?: string;
  contentRelId?: string;
  userHeaderUrl?: string;
  channelId?: string | number;
}

export interface postExecuteCollectRecordParamsItem {
  contentId: string;
  contentType: string;
  relType?: string;
  contentRelId?: string;
}

export interface postExecuteCollectRecordParams {
  status: string;
  contentList: postExecuteCollectRecordParamsItem[]
}

export interface postPointLevelOperateParams {
  operateType: number;
}

export interface postCommentPublishParams {
  targetId: string;
  keyArticle: string;
  commentPics: string;
  targetTitle: string;
  commentType: string;
  targetType: string;
  commentContent: string;
  parentId: string;
  rootCommentId: string;
}

export interface postInteractBrowsOperateParamsContent {
  browseTime: string;
  contentId: string;
  contentType: number;
}

export interface postInteractBrowsOperateParams {
  delStatus: number;
  contentList: postInteractBrowsOperateParamsContent[]
}

export interface postInteractAccentionOperateParams {
  attentionUserType: string;
  attentionUserId: string;
  attentionCreatorId: string;

  // userType: number;
  // userId: string;
  status: number;
}

export interface OperateRespDTO {
  ruleName: string;
  rulePoint: number;
  showToast: boolean;
}

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 getRmhPublishNextsUrl(creatorId: string,contentId: string, contentType: number, nextFlag: number, pageSize: number, refreshTime: number) { //params.creatorId,params.contentId, params.contentType, params.nextFlag, params.pageSize, params.refreshTime
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.PUBLISH_NEXT_PATH
    url = url + "?creatorId=" + creatorId
      + "&contentId=" + contentId
      + "&contentType=" + contentType
      + "&nextFlag=" + nextFlag
      + "&pageSize=" + pageSize
      + "&refreshTime=" + refreshTime;
    console.info(`cj2024 getRmhPublishNextsUrl url = ${url}`)
    return url;
  }


  static getLiveRoomPullStreamUrl(vliveId:string){
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.PULL_STREAM_PATH
    url = url +  vliveId
    return url;
  }

  static getLiveRoomPullStream(vliveId: string): Promise<ResponseDTO<GetPullAddressBean>> {
    let url = ContentDetailRequest.getLiveRoomPullStreamUrl(vliveId)
    return WDHttp.get<ResponseDTO<GetPullAddressBean>>(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)
    return WDHttp.get<ResponseDTO<ContentDetailDTO[]>>(url)
  }

  static getRmhPublishNexts(params: RmhPublishNextsParams): Promise<ResponseDTO<PeopleShipNextListDTO>> {
    // if (mock_switch) {
    //   return ContentDetailRequest.getContentDetailDataMock(getContext());
    // }
    let url = ContentDetailRequest.getRmhPublishNextsUrl(params.creatorId,params.contentId, params.contentType, params.nextFlag, params.pageSize, params.refreshTime)
    return WDHttp.get<ResponseDTO<PeopleShipNextListDTO>>(url)
  }



  /**
   * 查询沉浸式视频频道推荐楼层数据
   * @returns
   */
  static getRecCompInfo(params: getRecCompInfoParams): Promise<ResponseDTO<getRecCompInfoResult>> {
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.DISPLAY_REC_COMPINFO
    return WDHttp.request({
      url,
      method: 'GET',
      params,
      headers: HttpRequest.buildHeaderWithGlobalHeader()
    })
  }

  /**
   * 批量查询沉浸式视频详情
   * @returns
   */
  static batchContentDetail(params: batchContentDetailParams): Promise<ResponseDTO<ContentDetailDTO[]>> {
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH
    return WDHttp.request({
      url,
      method: 'POST',
      data: params,
      headers: HttpRequest.buildHeaderWithGlobalHeader()
    })
  }


  /**
   * 批量查询作品点赞、收藏、分享、阅读、评论数量
   * @returns
   */
  static getContentInteract(params: contentListParams): Promise<ResponseDTO<InteractDataDTO[]>> {
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_PATH
    return WDHttp.post(url, params)
  }

  /**
   * 批量查询作品查询点赞、收藏状态
   * @returns
   */
  static postBatchLikeAndCollectStatus(params: batchLikeAndCollectParams): Promise<ResponseDTO<batchLikeAndCollectResult[]>> {
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_STATUS
    return WDHttp.post(url, params)
  }

  /**
   * 批量查号主是否为用户关注
   * @returns
   */
  static postBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<ResponseDTO<postBatchAttentionStatusResult[]>> {
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH
    return WDHttp.post(url, params)
  }


  /**
   * 沉浸式視頻查詢近20条数据
   * @returns
   */

  static postRecommendVideoList(params: recommentVideoListParams): Promise<ResponseDTO<ContentDetailDTO[]>> {
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_VIDEOLIST
    return WDHttp.post(url, params)
  }

  /**
   * 用户点赞、取消点赞
   * @param params
   * @returns
   */
  static postExecuteLike(params: postExecuteLikeParams): Promise<ResponseDTO> {
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTELIKE
    return WDHttp.post(url, params)
  }

  /**
   * 用户收藏、取消收藏
   * @param params
   * @returns
   */
  static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> {
    let url = HttpUrlUtils.getExecuteCollcetUrl()
    return WDHttp.post(url, params)
  }

  /**
   *用户等级/积分-APP根据业务场景动态增减成长值(APP)
   * 操作类型:1阅读 2评论 3回复(积分任务同评论) 4分享 5点赞 6关注 7打开客户端 8上传头像 9打开推送开关
   */
  static postPointLevelOperate(params: postPointLevelOperateParams): Promise<ResponseDTO<OperateRespDTO>> {
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.USERPOINT_OPERATE
    return WDHttp.post(url, params)
  }

  /**
   * 评论发布
   */
  static postCommentPublish(params: postCommentPublishParams): Promise<ResponseDTO> {
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMMENT_PUBLISH
    return WDHttp.post(url, params)
  }


  /**
   * 浏览历史新增、删除接口
   */
  static postInteractBrowsOperate(params: postInteractBrowsOperateParams): Promise<ResponseDTO> {
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_BROWS_OPERATE
    return WDHttp.post(url, params)
  }

  /**
   * 关注号主
   */
  private static postInteractAccentionOperateInfo(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
    let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION
    return WDHttp.post(url, params)
  }

  /**
   * 关注号主
   */
  static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
    return new Promise<ResponseDTO>((success, error) => {
      Logger.debug(TAG, `postInteractAccentionOperate pageInfo start`);
      ContentDetailRequest.postInteractAccentionOperateInfo(params)
        .then((resDTO: ResponseDTO) => {
          if (!resDTO || resDTO.code != 0) {
            error(null)
            return
          }
          Logger.debug(TAG, "postInteractAccentionOperate then,navResDTO.timestamp:" + resDTO.timestamp);
          // 关注号后发送-更新关注页面
          EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
          success(resDTO);
        })
        .catch((err: Error) => {
          Logger.error(TAG,
            `postInteractAccentionOperate catch, error.name : ${err.name},  error.message:${err.message}`);
          error(err);
        })
    })
  }
}