Esempio n. 1
0
 /**
  * 添加操作员
  */
 public function opAddAction()
 {
     $this->setLeftNav('opAdd');
     $req = $this->request;
     if (!$req->isPost()) {
         $this->view->setvar('opencity', $this->openCityList());
         $this->view->setVar('opGroup', BackendOperatorGroup::find());
         return;
     }
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     $opAccount = $req->getPost('operator_account');
     $opShowName = $req->getPost('operator_show_name');
     $opPassword = $req->getPost('operator_password');
     $opRole = 0;
     $opGroup = intval($req->getPost('operator_group'));
     $opRemark = $req->getPost('operator_remark', null, '');
     if (!$opAccount || !$opShowName || !$opPassword || $opGroup < 0) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数问题!');
         return $response;
     }
     if (BackendOperator::count(['conditions' => 'operator_account = :account:', 'bind' => ['account' => $opAccount]]) > 0) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '此账户名称已经存在!');
         return $response;
     }
     $op = new BackendOperator();
     $op->operator_account = $opAccount;
     $op->operator_show_name = $opShowName;
     $op->operator_password = $this->operator->hashPassword($opPassword);
     $op->operator_role = $opRole;
     $op->operator_group = $opGroup;
     $op->operator_remark = $opRemark;
     if ($op->save()) {
         $response->sendResult($op->operator_id);
         $this->operatorLog($this->operator->id, BackendOpLog::APPEND_OPERATOR_SUCCESS, $opAccount . ',' . $opShowName);
     } else {
         $this->databaseErrorLog($op);
         $error = '保存数据异常!';
         $response->sendError(ResponseResultStatus::DATABASE_ERROR, $error);
         $this->operatorLog($this->operator->id, BackendOpLog::APPEND_OPERATOR_FAILED, $error);
     }
     return $response;
 }
Esempio n. 2
0
 /**
  * 添加关联1.0
  */
 public function questionUserAddAction()
 {
     $req = $this->request;
     if (!$req->isPost()) {
         $this->view->setVar('opList', BackendOperator::find('operator_group = 2'));
         return;
     }
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     $opId = intval($req->getPost('op_id', null, 0));
     $userId = intval($req->getPost('user_id', null, 0));
     if ($opId < 1 || $userId < 1) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数问题!');
         return $response;
     }
     // 操作员是否存在
     if (BackendOperator::count('operator_id = ' . $opId) == 0) {
         $response->sendError(ResponseResultStatus::BUSINESS, '操作员不存在!');
         return $response;
     }
     // 用户是否存在
     if (UserBase::count('user_id = ' . $userId) == 0) {
         $response->sendError(ResponseResultStatus::BUSINESS, '用户不存在!');
         return $response;
     }
     $info = new OmQuestionAnswerUser();
     $info->op_id = $opId;
     $info->user_id = $userId;
     if ($info->save() == false) {
         $this->databaseErrorLog($info);
         $response->sendError(ResponseResultStatus::DATABASE_ERROR, '保存数据异常!');
     } else {
         $response->sendResult($info->qau_id);
     }
     return $response;
 }