From 0da024b32c7230cb207aa961caa09b058afea0ec Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 22 Nov 2023 13:19:38 +0800 Subject: [PATCH] * Refactor custom::getURSRList method. --- module/custom/model.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/module/custom/model.php b/module/custom/model.php index 486edb91be..0b1c6cd2a6 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -663,36 +663,38 @@ class customModel extends model } /** + * 获取需求概念列表。 * Get UR and SR list. * * @access public * @return array */ - public function getURSRList() + public function getURSRList(): array { $this->app->loadLang('custom'); $lang = $this->app->getClientLang(); - $langData = $this->dao->select('`key`, `value`, `system`')->from(TABLE_LANG) + $URSRDataList = $this->dao->select('`key`, `value`, `system`')->from(TABLE_LANG) ->where('lang')->eq($lang) ->andWhere('module')->eq('custom') ->andWhere('section')->eq('URSRList') ->fetchAll(); - if(empty($langData)) + + if(empty($URSRDataList)) { - $URSR = $this->loadModel('setting')->getURSR(); - $langData = $this->dao->select('`key`, `value`, `system`')->from(TABLE_LANG)->where('`key`')->eq($URSR)->andWhere('module')->eq('custom')->andWhere('section')->eq('URSRList')->fetchAll(); + $URSR = $this->loadModel('setting')->getURSR(); + $URSRDataList = $this->dao->select('`key`, `value`, `system`')->from(TABLE_LANG)->where('`key`')->eq($URSR)->andWhere('module')->eq('custom')->andWhere('section')->eq('URSRList')->fetchAll(); } $URSRList = array(); - foreach($langData as $content) + foreach($URSRDataList as $URSRData) { - $value = json_decode($content->value); - $URSRList[$content->key] = new stdclass(); - $URSRList[$content->key]->key = $content->key; - $URSRList[$content->key]->SRName = $value->SRName; - $URSRList[$content->key]->URName = $value->URName; - $URSRList[$content->key]->system = $content->system; + $value = json_decode($URSRData->value); + $URSRList[$URSRData->key] = new stdclass(); + $URSRList[$URSRData->key]->key = $URSRData->key; + $URSRList[$URSRData->key]->SRName = $value->SRName; + $URSRList[$URSRData->key]->URName = $value->URName; + $URSRList[$URSRData->key]->system = $URSRData->system; } return $URSRList;