export type Payload<T = unknown, R = unknown> = {
    req?: T,
    rsp?: R
}

/**
 * 请求参数
 */
export interface RequestParams<T, R> {
    data?: T;
    success?: (res: R) => void;
    fail?: (err: string) => void;
    complete?: () => void;
}

/**
 * Http请求参数
 */
export type HttpParams<T extends Payload = object> = RequestParams<T['req'], HttpResponse<T['rsp']>>

/**
 * Http请求参数
 */
export type CommonParams<T extends Payload = object> = RequestParams<T['req'], T['rsp']>

/**
 * Http响应结果
 */
export interface HttpResponse<T> {
    code: ResultCode;
    msg: string;
    total: number;
    data: T;
}

/**
 * Http响应结果状态码
 */
export enum ResultCode {
    Success = 200, //成功
    Error = 101, //发生错误
    Fail = 102, //失败
    Warning = 103, //非法请求
    Unauthorized = 201, //授权失败
    ParameterError = 202, //参数错误
    InvalidToken = 203, //令牌无效
    InvalidSign = 204, //签名无效
}