zengyicheng преди 2 години
родител
ревизия
5fd8d30b03
променени са 1 файла, в които са добавени 47 реда и са изтрити 1 реда
  1. 47 1
      pbl.js

+ 47 - 1
pbl.js

@@ -1745,7 +1745,7 @@ router.route('/batchRegistrationMore').post(function(req, res, next) {
         });
         });
     }
     }
 });
 });
-
+//新增学生
 router.route('/batchRegistration').post(function(req, res, next) {
 router.route('/batchRegistration').post(function(req, res, next) {
     var users = req.body[0];
     var users = req.body[0];
     //循环注册
     //循环注册
@@ -1791,6 +1791,52 @@ router.route('/batchRegistration').post(function(req, res, next) {
     });
     });
 });
 });
 
 
+//新增教师
+router.route('/batchRegistration1').post(function(req, res, next) {
+    var users = req.body[0];
+    //循环注册
+    var _username = users.alias;
+    var _mail = users.username;
+    var _password = users.password || "123456";
+    var _alias = users.alias;
+    var _oid = users.oid;
+    var _ph = users.ph;
+    var _class = users.cid;
+    var _sId = users.sid;
+    //加密密碼
+    _password = bcrypt.hashSync(_password, bcrypt.genSaltSync(10));
+    //生成激活碼
+    let _hashstr = new Date().getTime() + "";
+    let _digest = crypto.createHash('sha256').update(_hashstr, 'utf8').digest('hex');
+    //用戶數據
+    var _userdata = [
+        _mail,
+        _password,
+        _alias,
+        "",
+        0,
+        _username,
+        "",
+        generateAPIKey(_username),
+        _digest,
+        "",
+        _username,
+        _sId,
+        1,
+        _oid,
+        _ph,
+        _class,
+        '',
+        "0",
+    ];
+    //參數拼接,註冊
+    _userdata.unshift(_mysqluser[0], _mysqluser[1], "pbl_add_batchregister");
+    //用戶註冊處理
+    mysql.usselect(_userdata, function(ret) {
+        res.end(JSON.stringify({ uid: ret[1][0].uid, ph: _ph, oid: _oid, cid: _class, success: 1 }));
+    });
+});
+
 router.route('/batchRegistrationOrg').post(function(req, res, next) {
 router.route('/batchRegistrationOrg').post(function(req, res, next) {
     var users = req.body[0];
     var users = req.body[0];
     //循环注册
     //循环注册