'asc']; protected string|array $orderGuarantee = ['id' => 'asc']; protected bool $modelValidate = true; protected bool $modelSceneValidate = true; protected function initController(WebmanRequest $request): ?Response { $this->model = new \app\common\model\GameConfig(); return null; } /** * @return list */ protected function excludedConfigKeys(): array { return [ ZiHuaDictionaryLib::CONFIG_KEY, DepositTier::CONFIG_KEY, StreakWinReward::CONFIG_KEY, ]; } /** * 列表:排除独立表单维护的配置键 */ protected function _index(): Response { if ($this->request && $this->request->get('select')) { return $this->select($this->request); } list($where, $alias, $limit, $order) = $this->queryBuilder(); $table = strtolower($this->model->getTable()); $mainShort = $alias[$table] ?? ''; if ($mainShort !== '') { $where[] = [$mainShort . '.config_key', 'not in', $this->excludedConfigKeys()]; } $res = $this->model ->field($this->indexField) ->withJoin($this->withJoinTable, $this->withJoinType) ->with($this->withJoinTable) ->alias($alias) ->where($where) ->order($order) ->paginate($limit); return $this->success('', [ 'list' => $res->items(), 'total' => $res->total(), 'remark' => get_route_remark(), ]); } /** * 远程下拉:排除独立维护的配置键 */ protected function _select(): Response { if (empty($this->model)) { return $this->success('', [ 'list' => [], 'total' => 0, ]); } $pk = $this->model->getPk(); $fields = [$pk]; $quickSearchArr = is_array($this->quickSearchField) ? $this->quickSearchField : explode(',', (string) $this->quickSearchField); foreach ($quickSearchArr as $f) { $f = trim((string) $f); if ($f === '') { continue; } $f = str_contains($f, '.') ? substr($f, strrpos($f, '.') + 1) : $f; if ($f !== '' && !in_array($f, $fields, true)) { $fields[] = $f; } } list($where, $alias, $limit, $order) = $this->queryBuilder(); $table = strtolower($this->model->getTable()); $mainShort = $alias[$table] ?? ''; if ($mainShort !== '') { $where[] = [$mainShort . '.config_key', 'not in', $this->excludedConfigKeys()]; } $res = $this->model ->field($fields) ->alias($alias) ->where($where) ->order($order) ->paginate($limit); return $this->success('', [ 'list' => $res->items(), 'total' => $res->total(), ]); } }