package com.stu.assistant.uitls;

import android.util.Log;

import com.stu.assistant.bean.UserInfoBean;
import com.stu.assistant.constants.ConstansUserManager;

import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.SaveListener;

public class SaveUserData {
    public void saveData(){
        StringBuilder stringBuilder = new StringBuilder();
        UserInfoBean userInfoBean = new UserInfoBean();
        userInfoBean.setUsername("100");
        userInfoBean.setPassword("123456");
        userInfoBean.setNickName("管理员");
        userInfoBean.setUserLevel(ConstansUserManager.Level_1);
        userInfoBean.setUserType(ConstansUserManager.UserType_1);
        userInfoBean.setEvaluate("");

        userInfoBean.signUp(new SaveListener<UserInfoBean>() {
            @Override
            public void done(UserInfoBean objectId, BmobException e) {
                stringBuilder.append("添加管理员");
                if (e == null) {
                    stringBuilder.append("objectId:" + objectId);
                } else {
                    stringBuilder.append("创建数据失败:" + e.getMessage());
                }
                stringBuilder.append(",");
            }
        });


        UserInfoBean userInfoBean2 = new UserInfoBean();
        userInfoBean2.setUsername("201");
        userInfoBean2.setPassword("123456");
        userInfoBean2.setNickName("部门管理员");
        userInfoBean2.setUserLevel(ConstansUserManager.Level_2);
        userInfoBean2.setUserType(ConstansUserManager.UserType_1);
        userInfoBean2.setEvaluate("");
        userInfoBean2.signUp(new SaveListener<UserInfoBean>() {
            @Override
            public void done(UserInfoBean objectId, BmobException e) {
                stringBuilder.append("部门管理员");
                if (e == null) {
                    stringBuilder.append("objectId:" + objectId);
                } else {
                    stringBuilder.append("创建数据失败:" + e.getMessage());
                }
                stringBuilder.append(",");
            }
        });

        UserInfoBean userInfoBean3 = new UserInfoBean();
        userInfoBean3.setUsername(ConstansUserManager.Level_3+"1");
        userInfoBean3.setPassword("123456");
        userInfoBean3.setNickName("学生1");
        userInfoBean3.setUserLevel(ConstansUserManager.Level_3);
        userInfoBean3.setUserType(ConstansUserManager.UserType_2);
        userInfoBean3.setEvaluate("");
        userInfoBean3.signUp(new SaveListener<UserInfoBean>() {
            @Override
            public void done(UserInfoBean objectId, BmobException e) {
                stringBuilder.append("维修员1");
                if (e == null) {
                    stringBuilder.append("objectId:" + objectId);
                } else {
                    stringBuilder.append("创建数据失败:" + e.getMessage());
                }
                stringBuilder.append(",");
            }
        });


        UserInfoBean userInfoBean4 = new UserInfoBean();
        userInfoBean4.setUsername(ConstansUserManager.Level_3 + "2");
        userInfoBean4.setPassword("123456");
        userInfoBean4.setNickName("学生2");
        userInfoBean4.setUserLevel(ConstansUserManager.Level_3);
        userInfoBean4.setUserType(ConstansUserManager.UserType_2);
        userInfoBean4.setEvaluate("");
        userInfoBean4.signUp(new SaveListener<UserInfoBean>() {
            @Override
            public void done(UserInfoBean objectId, BmobException e) {
                stringBuilder.append("维修员2");
                if (e == null) {
                    stringBuilder.append("objectId:" + objectId);
                } else {
                    stringBuilder.append("创建数据失败:" + e.getMessage());
                }
                stringBuilder.append(",");
            }
        });

    }
}
