/** * 操作日志 */ public function opLogAction() { $this->setLeftNav('opLog'); $req = $this->request; $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $filterOp = intval($req->getQuery('filterOp', null, -10000)); $filterType = intval($req->getQuery('filterType', null, -10000)); $where = []; $bindParams = []; if ($filterOp > -10000) { $where[] = 'Apps\\Common\\Models\\BackendOperatorLog.operator_id = :opId:'; $bindParams['opId'] = $filterOp == -10000 ? 0 : $filterOp; } if ($filterType > -10000) { $where[] = 'log_type = :opType:'; $bindParams['opType'] = $filterType; } $whereStr = implode(' AND ', $where); // 总数 $total = BackendOperatorLog::count(['conditions' => $whereStr, 'bind' => $bindParams]); // 操作员列表 $opList = BackendOperator::find(); $this->view->setVar('opList', $opList); // 操作类型 $this->view->setVar('opLogTypes', BackendOperatorLogType::find()); $data = BackendOperatorLog::query()->columns(['Apps\\Common\\Models\\BackendOperatorLog.log_id', 'op.operator_id', 'op.operator_show_name', 'logType.type_title log_type', 'Apps\\Common\\Models\\BackendOperatorLog.log_client_info', 'Apps\\Common\\Models\\BackendOperatorLog.log_addtime'])->where($whereStr)->bind($bindParams)->leftJoin('Apps\\Common\\Models\\BackendOperator', 'op.operator_id = Apps\\Common\\Models\\BackendOperatorLog.operator_id', 'op')->leftJoin('Apps\\Common\\Models\\BackendOperatorLogType', 'logType.type_id = Apps\\Common\\Models\\BackendOperatorLog.log_type', 'logType')->limit($limit, ($page - 1) * $limit)->orderBy('Apps\\Common\\Models\\BackendOperatorLog.log_id DESC')->execute(); $this->view->setVar('total', $total); $this->view->setVar('page', $page); $this->view->setVar('limit', $limit); $this->view->setVar('filterOp', $filterOp); $this->view->setVar('filterType', $filterType); $this->view->setVar('data', $data); }
/** * 添加关联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; }