import { IData } from 'duiba-tc';
/**
 *Created by cuiliqiang on 2018/3/12
 * 数据基类
 */

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

    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(): number {
        return this._code;
    }
}
