public function saveTeacher($teacher, $loginname) { if ($teacher == "") { return; } $instId = session('instId'); $model = new \Home\Model\TeacherModel(); $operator = new \Home\Model\OperatorModel(); try { $model->startTrans(); $result = $model->saveTeacher($teacher, $instId); //TODO 稍后改成用户自定义密码 $operatorId = $operator->addOperator($instId, $loginname, '123456', 0, $teacher, $result[0]['teacher_id']); //TODO 稍后改成查数据库code=ROLE_TEACHER的 $operator->addOperatorAndRoleRela($operatorId[0]['operator_id'], 1); $model->commit(); $data = "true"; } catch (Exception $e) { $model->rollback(); $data = "false"; } $this->ajaxReturn($data); }