package com.rc.httpcore.vo.response;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

/**
 * 签到验证 Response
 *
 * @author ReiChin_
 */
public class SignInCheckResp implements Parcelable {

    public String code; // 验证码
    public List<String> message; // 验证信息
    public SingInUser singInUser; // 签到用户信息
    public SingInViolation singInViolation; // 签到违规信息
    public boolean state;
    public String subId;
    public List<String> tips; // 一般提示信息

    public SignInCheckResp() {
    }

    protected SignInCheckResp(Parcel in) {
        code = in.readString();
        message = in.createStringArrayList();
        singInUser = in.readParcelable(SingInUser.class.getClassLoader());
        singInViolation = in.readParcelable(SingInViolation.class.getClassLoader());
        state = in.readByte() != 0;
        subId = in.readString();
        tips = in.createStringArrayList();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(code);
        dest.writeStringList(message);
        dest.writeParcelable(singInUser, flags);
        dest.writeParcelable(singInViolation, flags);
        dest.writeByte((byte) (state ? 1 : 0));
        dest.writeString(subId);
        dest.writeStringList(tips);
    }

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

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

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

    public static class SingInUser implements Parcelable {
        public String deptId; // 部门id
        public String expirationDate; // 失效时间
        public String nickName; // 用户姓名
        public String type; // 用户类型
        public String userId; // 用户id
        public String userName; // 用户账户
        public String avatar; // 用户头像

        public SingInUser() {
        }

        protected SingInUser(Parcel in) {
            deptId = in.readString();
            expirationDate = in.readString();
            nickName = in.readString();
            type = in.readString();
            userId = in.readString();
            userName = in.readString();
            avatar = in.readString();
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(deptId);
            dest.writeString(expirationDate);
            dest.writeString(nickName);
            dest.writeString(type);
            dest.writeString(userId);
            dest.writeString(userName);
            dest.writeString(avatar);
        }

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

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

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

    public static class SingInViolation implements Parcelable {
        public String createTime; // 违约时间
        public String subjectName; // 实验室名称
        public String violationContent; // 违规内容

        public SingInViolation() {
        }

        protected SingInViolation(Parcel in) {
            createTime = in.readString();
            subjectName = in.readString();
            violationContent = in.readString();
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(createTime);
            dest.writeString(subjectName);
            dest.writeString(violationContent);
        }

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

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

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

}
