From 6739fe4db43e0839e8e1c4c567f0269c4e1e791c Mon Sep 17 00:00:00 2001 From: daitingting Date: Fri, 1 Dec 2023 09:19:44 +0000 Subject: [PATCH] * Refactor buildIndexQuery function. --- module/search/model.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/module/search/model.php b/module/search/model.php index e9c91380b8..31c2dad326 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -761,27 +761,28 @@ class searchModel extends model } /** + * 构建索引查询。 * Build index query. * - * @param string $type - * @param bool $testDelete + * @param string $type + * @param bool $testDelete * @access public * @return string */ - public function buildIndexQuery($type, $testDeleted = true) + public function buildIndexQuery(string $type, bool $testDeleted = true) { $table = $this->config->objectTables[$type]; - if($type == 'story' or $type == 'requirement') + if($type == 'story' || $type == 'requirement') { - $query = $this->dao->select('DISTINCT t1.*,t2.spec,t2.verify')->from($table)->alias('t1') + $query = $this->dao->select('DISTINCT t1.*, t2.spec, t2.verify')->from($table)->alias('t1') ->leftJoin(TABLE_STORYSPEC)->alias('t2')->on('t1.id=t2.story') - ->where('t1.deleted')->eq(0) + ->where('t1.deleted')->eq('0') ->andWhere('type')->eq($type) ->andWhere('t1.version=t2.version'); } elseif($type == 'doc') { - $query = $this->dao->select('DISTINCT t1.*,t2.content,t2.digest')->from($table)->alias('t1')->leftJoin(TABLE_DOCCONTENT)->alias('t2')->on('t1.id=t2.doc')->where('t1.deleted')->eq(0)->andWhere('t1.version=t2.version'); + $query = $this->dao->select('DISTINCT t1.*, t2.content, t2.digest')->from($table)->alias('t1')->leftJoin(TABLE_DOCCONTENT)->alias('t2')->on('t1.id=t2.doc')->where('t1.deleted')->eq('0')->andWhere('t1.version=t2.version'); } else { @@ -793,7 +794,7 @@ class searchModel extends model ->beginIF($type == 'program')->andWhere('type')->eq('program')->fi() ->beginIF($type == 'project')->andWhere('type')->eq('project')->fi() ->beginIF($type == 'execution')->andWhere('type')->in('stage,sprint,kanban')->fi() - ->beginIF(isset($data->deleted))->andWhere('t1.deleted')->eq(0)->fi(); + ->beginIF(isset($data->deleted))->andWhere('t1.deleted')->eq('0')->fi(); } return $query; }