package com.zswc.creativity.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.zswc.creativity.config.ConfigMMKV;
import com.ysnows.base.inter.IModel;
import com.ysnows.base.inter.IUser;
import com.ysnows.base.utils.MMKVManager;

import org.jetbrains.annotations.Nullable;

public class User implements IUser, Parcelable, IModel {

    public String accountName;
    public String create_at;
    public String examples_number;
    public String group;
    public String headimg;
    public String id;
    public String invite_address;
    public String invite_code;
    public String invite_img;
    public String is_auth;
    public String is_deleted;
    public String is_money_status;
    public String is_open_official_DDC;
    public String is_order_no_paid;
    public String is_password;
    public String is_sign;
    public String lottery_number;
    public String lucky_number;
    public String money;
    public String integral;
    public String name;
    public String phone;
    public String snap_card;
    public String status;
    public String update_at;
    public String vip;
    public String vip_name;
    public String wallet_address;
    public String zfb_account;
    public String zfb_real_name;
    public String offline_account;
    public String openid;
    public String true_name;
    public String true_phone;
    public String id_card;



    public User() {
    }


    protected User(Parcel in) {
        accountName = in.readString();
        create_at = in.readString();
        examples_number = in.readString();
        group = in.readString();
        headimg = in.readString();
        id = in.readString();
        invite_address = in.readString();
        invite_code = in.readString();
        invite_img = in.readString();
        is_auth = in.readString();
        is_deleted = in.readString();
        is_money_status = in.readString();
        is_open_official_DDC = in.readString();
        is_order_no_paid = in.readString();
        is_password = in.readString();
        is_sign = in.readString();
        lottery_number = in.readString();
        lucky_number = in.readString();
        money = in.readString();
        integral = in.readString();
        name = in.readString();
        phone = in.readString();
        snap_card = in.readString();
        status = in.readString();
        update_at = in.readString();
        vip = in.readString();
        vip_name = in.readString();
        wallet_address = in.readString();
        zfb_account = in.readString();
        zfb_real_name = in.readString();
        offline_account = in.readString();
        openid = in.readString();
        true_name = in.readString();
        true_phone = in.readString();
        id_card = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(accountName);
        dest.writeString(create_at);
        dest.writeString(examples_number);
        dest.writeString(group);
        dest.writeString(headimg);
        dest.writeString(id);
        dest.writeString(invite_address);
        dest.writeString(invite_code);
        dest.writeString(invite_img);
        dest.writeString(is_auth);
        dest.writeString(is_deleted);
        dest.writeString(is_money_status);
        dest.writeString(is_open_official_DDC);
        dest.writeString(is_order_no_paid);
        dest.writeString(is_password);
        dest.writeString(is_sign);
        dest.writeString(lottery_number);
        dest.writeString(lucky_number);
        dest.writeString(money);
        dest.writeString(integral);
        dest.writeString(name);
        dest.writeString(phone);
        dest.writeString(snap_card);
        dest.writeString(status);
        dest.writeString(update_at);
        dest.writeString(vip);
        dest.writeString(vip_name);
        dest.writeString(wallet_address);
        dest.writeString(zfb_account);
        dest.writeString(zfb_real_name);
        dest.writeString(offline_account);
        dest.writeString(openid);
        dest.writeString(true_name);
        dest.writeString(true_phone);
        dest.writeString(id_card);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<User> CREATOR = new Creator<User>() {
        @Override
        public User createFromParcel(Parcel in) {
            return new User(in);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };

    @Override
    public boolean save() {
        return MMKVManager.instance().encode(ConfigMMKV.USER, this);
    }

    public static boolean isLogin() {
        return get() != null;
    }


    @Nullable
    public static User get() {
        return MMKVManager.instance().decodeParcelable(ConfigMMKV.USER, User.class);
    }




    @androidx.annotation.Nullable
    @Override
    public String avatar() {
        return headimg;
    }
}
