* [perf] refactor: standardize search cache naming and parameter handling

- Change session key from 'searchParams' to 'SearchFunc' for consistency
- Simplify processSearchParams method to accept module name directly
- Update method calls across search control and zen modules
This commit is contained in:
liugang
2025-08-18 09:25:19 +08:00
parent 993931eb0d
commit bc43a5a053
3 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -315,7 +315,7 @@ class model extends baseModel
$key++;
}
$this->session->set($module . 'searchParams', ['funcModel' => $funcModel, 'funcName' => $methodName, 'funcArgs' => $funcArgs]);
$this->session->set($module . 'SearchFunc', ['funcModel' => $funcModel, 'funcName' => $methodName, 'funcArgs' => $funcArgs]);
}
/**
+2 -2
View File
@@ -35,7 +35,7 @@ class search extends control
$searchParams = $module . 'searchParams';
$searchForm = $module . 'Form';
$this->searchZen->processSearchParams($searchParams);
$this->searchZen->processSearchParams($module);
$fields = empty($fields) ? json_decode($_SESSION[$searchParams]['searchFields'], true) : $fields;
$params = empty($params) ? json_decode($_SESSION[$searchParams]['fieldParams'], true) : $params;
@@ -85,7 +85,7 @@ class search extends control
$searchParams = $module . 'searchParams';
$searchForm = $module . 'Form';
$this->searchZen->processSearchParams($searchParams);
$this->searchZen->processSearchParams($module);
$fields = empty($fields) ? json_decode($_SESSION[$searchParams]['searchFields'], true) : $fields;
$params = empty($params) ? json_decode($_SESSION[$searchParams]['fieldParams'], true) : $params;
+5 -5
View File
@@ -6,15 +6,15 @@ class searchZen extends search
* 构造搜索表单时调用被搜索模块的方法处理搜索参数。
* Call the method of the searched module to process search parameters when constructing the search form.
*
* @param string $searchParams
* @param string $module
* @access public
* @return bool
*/
public function processSearchParams(string $searchParams): bool
public function processSearchParams(string $module): bool
{
$funcModel = $_SESSION[$searchParams]['funcModel'] ?? '';
$funcName = $_SESSION[$searchParams]['funcName'] ?? '';
$funcArgs = $_SESSION[$searchParams]['funcArgs'] ?? [];
$funcModel = $_SESSION[$module . 'SearchFunc']['funcModel'] ?? '';
$funcName = $_SESSION[$module . 'SearchFunc']['funcName'] ?? '';
$funcArgs = $_SESSION[$module . 'SearchFunc']['funcArgs'] ?? [];
if(!$funcModel || !$funcName) return false;
$funcArgs['cacheSearchParams'] = false; // 不缓存搜索参数以加载真实值。Do not cache search parameters to load real values.