diff --git a/module/program/model.php b/module/program/model.php index 27e9a5c29d..ef0ae83f2c 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1230,13 +1230,14 @@ class programModel extends model } /** + * 获取顶级项目集的ID。 * Get top program by id. * * @param int $programID * @access public * @return int */ - public function getTopByID($programID) + public function getTopByID(int $programID): int { if(empty($programID)) return 0; @@ -1247,16 +1248,17 @@ class programModel extends model } /** + * 通过路径获取顶级项目集的ID。 * Get top program by path. * * @param string $path * @access public - * @return string + * @return int */ - public function getTopByPath($path) + public function getTopByPath($path): int { $paths = explode(',', trim($path, ',')); - return $paths[0]; + return (int)$paths[0]; } /** diff --git a/module/program/test/model/gettopbyid.php b/module/program/test/model/gettopbyid.php index 0a60a11007..940f5428eb 100755 --- a/module/program/test/model/gettopbyid.php +++ b/module/program/test/model/gettopbyid.php @@ -7,11 +7,8 @@ su('admin'); /** title=测试 programModel::getTopByID(); +timeout=0 cid=1 -pid=1 - -获取项目集1最上级的项目集id >> 1 -获取项目集1000最上级的项目集id >> 0 */ @@ -21,4 +18,4 @@ $top1 = $tester->program->getTopByID(1); $top1000 = $tester->program->getTopByID(1000); r($top1) && p() && e('1'); //获取项目集1最上级的项目集id -r($top1000) && p() && e('0'); //获取项目集1000最上级的项目集id \ No newline at end of file +r($top1000) && p() && e('0'); //获取项目集1000最上级的项目集id diff --git a/module/program/test/model/gettopbypath.php b/module/program/test/model/gettopbypath.php index 39d9dfaf56..88b0c16823 100644 --- a/module/program/test/model/gettopbypath.php +++ b/module/program/test/model/gettopbypath.php @@ -5,11 +5,8 @@ include dirname(__FILE__, 5) . '/test/lib/init.php'; /** title=测试 programModel::getTopByPath(); +timeout=0 cid=1 -pid=1 - -获取顶级项目集的顶级id >> 1 -获取子项目集的顶级父项目集 >> 2 */