import { IData } from "../../tc/interface/IData";

// import { IData } from "../../tc/interface/IData";
/**
 *Created by cuiliqiang on 2018/3/12
 * 数据基类
 */

export class Data implements IData {
    private _success: boolean;
    private _message: string;
    private _code: any;
    private _timestamp:any;

    public update(data: any): void {
        this._success = data.success == undefined ? true : data.success;
        if (data.message) {
            this._message = data.message;
        } else if (data.desc) {
            this._message = data.desc;
        } else if (data.msg) {
            this._message = data.msg;
        }
        this._code = data.code;
        this._timestamp = data._timestamp;
    }


    /**
     * 接口状态
     * @returns {boolean}
     */
    public get success(): boolean {
        return this._success;
    }

    /**
     * 接口提示信息
     * @returns {string}
     */
    public get message(): string {
        return this._message;
    }

    /**
     * 状态码
     * @returns {string}
     */
    public get code(): any {
        return this._code;
    }

    public set code(data:any) {
        this._code = data;
    }
    /**
     * 接口时间
     * @returns {any}
     */
    public get getTimestamp(): any {
        return this._timestamp;
    }

    public set getTimestamp(data:any) {
        this._timestamp = data;
    }
}
