diff --git a/app/classes/IssueFilterLogic.php b/app/classes/IssueFilterLogic.php index 927e21a72..b7e1d53ed 100644 --- a/app/classes/IssueFilterLogic.php +++ b/app/classes/IssueFilterLogic.php @@ -16,6 +16,7 @@ use main\app\model\issue\IssueStatusModel; use main\app\model\issue\IssueFilterModel; use main\app\model\issue\IssueFollowModel; +use main\app\model\issue\IssueTypeModel; use main\app\model\project\ProjectModuleModel; use main\app\model\project\ReportProjectIssueModel; use main\app\model\project\ReportSprintIssueModel; @@ -161,21 +162,17 @@ public function getList($page = 1, $pageSize = 50) if (strpos($versionStr, 'MariaDB') !== false) { $versionNum = 0; } - if ($versionNum < 5.70) { - // 使用LOCATE模糊搜索 - if (strlen($search) < 10) { - $sql .= " AND ( LOCATE(:summary,`summary`)>0 OR pkey=:pkey)"; - $params['pkey'] = $search; - $params['summary'] = $search; - } else { - $sql .= " AND LOCATE(:summary,`summary`)>0 "; - $params['summary'] = $search; - } + + // 使用LOCATE模糊搜索 + if (strlen($search) < 10) { + $sql .= " AND ( LOCATE(:summary,`summary`)>0 OR pkey=:pkey)"; + $params['pkey'] = $search; + $params['summary'] = $search; } else { - // 使用全文索引 - $sql .= " AND MATCH (`summary`) AGAINST (:summary IN NATURAL LANGUAGE MODE) "; + $sql .= " AND LOCATE(:summary,`summary`)>0 "; $params['summary'] = $search; } + } } @@ -268,6 +265,26 @@ public function getList($page = 1, $pageSize = 50) $sql .= " AND status=:status"; $params['status'] = $statusId; } + + // 事项类型 + $typeId = null; + if (isset($_GET[urlencode('类型')])) { + $model = new IssueTypeModel(); + $row = $model->getByName(urldecode($_GET[urlencode('类型')])); + if (isset($row['id'])) { + $typeId = $row['id']; + } + unset($row); + } + if (isset($_GET['type_id'])) { + $typeId = (int)$_GET['type_id']; + } + + if ($typeId !== null) { + $sql .= " AND issue_type=:issue_type"; + $params['issue_type'] = $typeId; + } + // 我未解决的 if ($sysFilter == 'my_unsolved') { $params['assignee'] = UserAuth::getInstance()->getId(); @@ -508,14 +525,8 @@ public function getAdvQueryList($page = 1, $pageSize = 50) $params[$field] = '%'.$value.'%'; break; case 'like %...%': - if ($versionNum < 5.70) { - $sql .= " LOCATE(:$field,$field)>0 "; - $params[$field] = $value; - } else { - // 使用全文索引 - $sql .= " MATCH ($field) AGAINST (:$field IN NATURAL LANGUAGE MODE) "; - $params[$field] = $value; - } + $sql .= " LOCATE(:$field,$field)>0 "; + $params[$field] = $value; break; case 'is null': case 'is not null': @@ -564,8 +575,8 @@ public function getAdvQueryList($page = 1, $pageSize = 50) try { // 获取总数 $sqlCount = "SELECT count(*) as cc FROM {$table} " . $sql; - //echo $sqlCount; - //print_r($params); + // echo $sqlCount; + // print_r($params); $count = $model->db->getOne($sqlCount, $params); $fields = '*'; $sql = "SELECT {$fields} FROM {$table} " . $sql; diff --git a/app/classes/SearchLogic.php b/app/classes/SearchLogic.php index 2410d42c5..daeb562ef 100644 --- a/app/classes/SearchLogic.php +++ b/app/classes/SearchLogic.php @@ -86,13 +86,13 @@ public static function getProjectByKeyword($keyword = 0, $page = 1, $pageSize = $model = new ProjectModel(); $table = $model->getTable(); $field = "*"; - if (self::$mysqlVersion < 5.70) { + //if (self::$mysqlVersion < 5.70) { // 使用LOCATE模糊搜索 $where = "WHERE locate(:keyword,name) > 0 OR locate(:keyword,`key`) > 0 "; - } else { + //} else { // 使用全文索引 - $where =" WHERE MATCH (`name`) AGAINST (:keyword IN NATURAL LANGUAGE MODE) "; - } + // $where =" WHERE MATCH (`name`) AGAINST (:keyword IN NATURAL LANGUAGE MODE) "; + //} $params['keyword'] = $keyword; @@ -145,13 +145,13 @@ public static function getIssueByKeywordWithNgram($keyword = 0, $page = 1, $page $issueModel = new IssueModel(); $table = $issueModel->getTable(); - if (self::$mysqlVersion < 5.70) { + //if (self::$mysqlVersion < 5.70) { // 使用LOCATE模糊搜索 $where = "WHERE locate(:keyword,`summary`) > 0 "; - } else { + //} else { // 使用全文索引 - $where =" WHERE MATCH (`summary`) AGAINST (:keyword IN NATURAL LANGUAGE MODE) "; - } + // $where =" WHERE MATCH (`summary`) AGAINST (:keyword IN NATURAL LANGUAGE MODE) "; + //} $params['keyword'] = $keyword; $sql = "SELECT * FROM {$table} {$where} {$limitSql}"; @@ -171,17 +171,18 @@ public static function getIssueCountByKeywordWithNgram($keyword) $model = new IssueModel(); $table = $model->getTable(); - if (self::$mysqlVersion < 5.70) { + //if (self::$mysqlVersion < 5.70) { // 使用LOCATE模糊搜索 $where = "WHERE locate(:keyword,`summary`) > 0 "; - } else { + //} else { // 使用全文索引 - $where =" WHERE MATCH (`summary`) AGAINST (:keyword IN NATURAL LANGUAGE MODE) "; - } + // $where =" WHERE MATCH (`summary`) AGAINST (:keyword IN NATURAL LANGUAGE MODE) "; + //} $params['keyword'] = $keyword; $params['keyword'] = $keyword; $sqlCount = "SELECT count(*) as cc FROM {$table} " . $where; + //echo $sqlCount; $count = $model->db->getOne($sqlCount, $params); return (int)$count; } diff --git a/app/view/twig/admin/workflow_edit.twig b/app/view/twig/admin/workflow_edit.twig index 0c2cbf653..48c205c66 100644 --- a/app/view/twig/admin/workflow_edit.twig +++ b/app/view/twig/admin/workflow_edit.twig @@ -113,7 +113,7 @@