LikeModel.ets 784 Bytes
import { HashMap } from '@kit.ArkTS';
import { Logger } from 'wdKit/Index';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';

export class LikeModel {
  executeLike(data: Record<string, string>) {
    let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();

    return new Promise<object>((success, fail) => {
      HttpRequest.post<ResponseDTO<object>>(HttpUrlUtils.executeLike(), data, headers).then((data: ResponseDTO<object>) => {
        if (data.code != 0) {
          fail(data.message)
          return
        }
        success(data)
      }, (error: Error) => {
        fail(error.message)
        Logger.debug("LoginViewModel:error ", error.toString())
      })
    })
  }
}