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;

    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;
    }

    /**
     * 接口状态
     * @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;
    }
}
