const Parse = require("parse/node");

Parse.serverURL = "https://web2023.fmode.cn/parse"; // 配置服务器地址
Parse.initialize("dev"); // 配置应用名称

async function registerUser(user) {
  let query = new Parse.Query("LjUser");
  query.descending("stuno");
  query.first().then(async result => {
    const maxStuno = result.get("stuno");
    console.log(maxStuno);
    const stuno_new = (parseInt(maxStuno) + 1).toString().padStart(9, "0");
    console.log(user.account)

    const user1 = new Parse.User();
    user1.set("username", "12")
    user1.set("account", user.account);
    user1.set("name", "雅力士")
    user1.set("password", user.password);
    user1.set("email", user.email);
    user1.set("gender", user.gender);
    user1.set("stuno", stuno_new);
    user1.set("member", "1");
    user1.set("skills", user.skills);
    user1.set("isFirstRegister", "1");
    user1.set("availableBalance", "2.00");
    user1.set("birthday", user.birthday);
    user1.set("phoneNumber", "")
    try {
      await user1.signUp();
      // Hooray! Let them use the app now.
    } catch (error) {
      console.log(error)
    }

    // UPDATE "Profile" SET "schoolClass"='DGnxrAMgJD';
  }).catch(error => {
    console.log("请检查网络问题");
  });

}

registerUser({
  account: "2",
  password: "12",
  email: "122@qq.com",
  skills: "1",
  birthday: "1"
});
