/** * 修改操作员基础信息 */ public function opUpdateBaseAction() { $req = $this->request; if (!$req->isPost()) { $id = intval($req->getQuery('id', null, 0)); $this->view->setVar('id', $id); $this->view->setVar('opInfo', BackendOperator::findFirst('operator_id = ' . $id)); $this->view->setVar('opGroup', BackendOperatorGroup::find()); return; } $response = new ResponseResult(); $response->callback = $req->getPost('callback', null, 'parent.setFormResult'); $response->callbackJavascriptTag = true; $opId = intval($req->getPost('operator_id', null, 0)); $opAccount = $req->getPost('operator_account'); $opShowName = $req->getPost('operator_show_name'); $opGroup = intval($req->getPost('operator_group')); $opRemark = $req->getPost('operator_remark', null, ''); if ($opId <= 0 || !$opAccount || !$opShowName || $opGroup < 0) { $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数问题!'); return $response; } $accountExist = BackendOperator::query()->where('operator_account = :account:', ['account' => $opAccount])->execute()->getFirst(); if (!!$accountExist && $accountExist->operator_id != $opId) { $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '此账户名称已经存在!'); return $response; } $info = BackendOperator::findFirst('operator_id = ' . $opId); $data = []; if ($info->operator_account != $opAccount) { $data['operator_account'] = $opAccount; } if ($info->operator_show_name != $opShowName) { $data['operator_show_name'] = $opShowName; } if ($info->operator_group != $opGroup) { $data['operator_group'] = $opGroup; } if ($info->operator_remark != $opRemark) { $data['operator_remark'] = $opRemark; } $info->update($data); $response->sendResult('ok'); return $response; }
/** * 添加关联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; }