From a7f019c0df59ad553ddb5cb9a34431183c3ea4aa Mon Sep 17 00:00:00 2001 From: zenggang Date: Sat, 16 Dec 2023 10:23:16 +0000 Subject: [PATCH] * Adjust gitlab code. --- module/gitlab/model.php | 16 ++++++++++++++++ module/gitlab/test/model/apicreategroup.php | 2 +- module/gitlab/test/model/apicreateproject.php | 4 ++-- module/gitlab/test/model/apigetnamespaces.php | 2 +- module/gitlab/test/model/apigetprojects.php | 2 +- module/gitlab/test/model/apigetprojectspager.php | 10 +++++----- module/gitlab/test/model/apigettodolist.php | 2 +- module/gitlab/test/model/getmatchedusers.php | 4 ++-- 8 files changed, 29 insertions(+), 13 deletions(-) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 690e394af1..8d7739cbcf 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -88,6 +88,22 @@ class gitlabModel extends model return rtrim($gitlab->url, '/') . '/api/v4%s' . "?private_token={$gitlab->token}" . $sudoParam; } + /** + * Get gitlab user id by zentao account. + * + * @param int $gitlabID + * @access public + * @return array + */ + public function getUserIDByZentaoAccount($gitlabID, $zentaoAccount) + { + return $this->dao->select('openID')->from(TABLE_OAUTH) + ->where('providerType')->eq('gitlab') + ->andWhere('providerID')->eq($gitlabID) + ->andWhere('account')->eq($zentaoAccount) + ->fetch('openID'); + } + /** * 获取gitlab的用户id和真实名字的键值对。 * Get gitlab user id and realname pairs of one gitlab. diff --git a/module/gitlab/test/model/apicreategroup.php b/module/gitlab/test/model/apicreategroup.php index 5e732f8c2a..89f0b12785 100644 --- a/module/gitlab/test/model/apicreategroup.php +++ b/module/gitlab/test/model/apicreategroup.php @@ -48,4 +48,4 @@ $result = $gitlab->apiCreateGroup($gitlabID, $group); if(!empty($result->name) and $result->name == $group->name) $result = true; if(!empty($result->message) and $result->message == 'Failed to save group {:path=>["已经被使用"]}') $result = true; r($result) && p() && e('1'); //通过gitlabID,projectID,分支对象正确创建GitLab分支 -r($gitlab->apiCreateGroup($gitlabID, $group)) && p('message') && e('Failed to save group {:path=>["已经被使用"]}'); //使用重复的分支信息创建分支 +r($gitlab->apiCreateGroup($gitlabID, $group)) && p('message') && e('Failed to save group {:path=>["已经被使用"]}'); //使用重复的分支信息创建分支 \ No newline at end of file diff --git a/module/gitlab/test/model/apicreateproject.php b/module/gitlab/test/model/apicreateproject.php index 5e0753d786..9783f5facd 100644 --- a/module/gitlab/test/model/apicreateproject.php +++ b/module/gitlab/test/model/apicreateproject.php @@ -12,7 +12,7 @@ cid=1 - 使用空的群组URL创建gitlab群组 @return false - 使用错误gitlabID创建群组 @0 - 通过gitlabID,projectID,分支对象正确创建GitLab分支 @1 -- 使用重复的分支信息创建分支属性message @Failed to save project {:path=>["已经被使用"]} +- 使用重复的分支信息创建分支第path条的0属性 @已经被使用 */ @@ -47,4 +47,4 @@ if(!empty($result->message->path[0]) and $result->message->path[0] == '已经被 r($result) && p() && e('1'); //通过gitlabID,projectID,分支对象正确创建GitLab分支 $result = $gitlab->apiCreateProject($gitlabID, $project); -r($result->message) && p('path:0') && e('已经被使用'); //使用重复的分支信息创建分支 +r($result->message) && p('path:0') && e('已经被使用'); //使用重复的分支信息创建分支 \ No newline at end of file diff --git a/module/gitlab/test/model/apigetnamespaces.php b/module/gitlab/test/model/apigetnamespaces.php index 0ff8a4f442..0a32b5fb52 100644 --- a/module/gitlab/test/model/apigetnamespaces.php +++ b/module/gitlab/test/model/apigetnamespaces.php @@ -28,4 +28,4 @@ r(count($result) > 0) && p() && e('1'); //通过gitlabID,获取GitLab names $result = $gitlab->apiGetNamespaces(0); r($result) && p() && e('0'); //通过错误的gitlabID获取namespace列表 -r(count($result)) && p() && e('0'); //通过错误的gitlabID获取namespace列表数量 +r(count($result)) && p() && e('0'); //通过错误的gitlabID获取namespace列表数量 \ No newline at end of file diff --git a/module/gitlab/test/model/apigetprojects.php b/module/gitlab/test/model/apigetprojects.php index f7ec3d43b5..4bd16e258a 100644 --- a/module/gitlab/test/model/apigetprojects.php +++ b/module/gitlab/test/model/apigetprojects.php @@ -49,4 +49,4 @@ r($result) && p('0:name') && e('privateTest'); //通过gitlabID minID为4获取G $simple = 'true'; $maxID = 2; $result = $gitlab->apiGetProjects($gitlabID, $simple, 0, $maxID); -r($result) && p('0:name') && e('testHtml'); //通过gitlabID maxID为4获取GitLab项目列表 +r($result) && p('0:name') && e('testHtml'); //通过gitlabID maxID为4获取GitLab项目列表 \ No newline at end of file diff --git a/module/gitlab/test/model/apigetprojectspager.php b/module/gitlab/test/model/apigetprojectspager.php index 80158c88fa..bc8d066550 100644 --- a/module/gitlab/test/model/apigetprojectspager.php +++ b/module/gitlab/test/model/apigetprojectspager.php @@ -8,11 +8,11 @@ title=测试 gitlabModel::apiGetProjectsPager(); timeout=0 cid=1 -- 通过gitlabID,projectID,获取GitLab项目列表 @1 -- 通过gitlabID,projectID,获取GitLab项目数量 @1 +- 通过gitlabID,获取GitLab项目列表 @1 +- 通过gitlabID,获取GitLab项目数量 @1 - 当gitlabID为0时,获取GitLab项目列表 @return empty -- 通过gitlabID,projectID,按项目名升序获取GitLab项目列表第1条的name属性 @testHtml -- 通过gitlabID,projectID,搜索字符'zentaopms_15.2_20210720'获取GitLab项目列表第0条的name属性 @privateProject +- 通过gitlabID,按项目名升序获取GitLab项目列表第1条的name属性 @testHtml +- 通过gitlabID,搜索字符'private'获取GitLab项目列表第0条的name属性 @privateProject */ @@ -46,4 +46,4 @@ r($result['projects']) && p('1:name') && e('testHtml'); //通过gitlabID,按项 $keyword = 'private'; $result = $gitlab->apiGetProjectsPager($gitlabID, $keyword, $orderBy, $pager); -r($result['projects']) && p('0:name') && e('privateProject'); //通过gitlabID,搜索字符'private'获取GitLab项目列表 +r($result['projects']) && p('0:name') && e('privateProject'); //通过gitlabID,搜索字符'private'获取GitLab项目列表 \ No newline at end of file diff --git a/module/gitlab/test/model/apigettodolist.php b/module/gitlab/test/model/apigettodolist.php index 9bdc2350a0..8ea662b5b8 100644 --- a/module/gitlab/test/model/apigettodolist.php +++ b/module/gitlab/test/model/apigettodolist.php @@ -46,4 +46,4 @@ $gitlabID = 0; $projectID = 0; $result = $gitlab->apiGetTodoList($gitlabID, $projectID, $sudo); if(empty($result)) $result = 'return empty'; -r($result) && p() && e('return empty'); //当gitlabID,projectID都为0时,获取GitLab待办列表 +r($result) && p() && e('return empty'); //当gitlabID,projectID都为0时,获取GitLab待办列表 \ No newline at end of file diff --git a/module/gitlab/test/model/getmatchedusers.php b/module/gitlab/test/model/getmatchedusers.php index a4a4ae5c13..9bea3ab6d7 100644 --- a/module/gitlab/test/model/getmatchedusers.php +++ b/module/gitlab/test/model/getmatchedusers.php @@ -13,7 +13,7 @@ cid=1 - 获取gitlab服务器1匹配的用户列表。 - 第1条的account属性 @root - 第1条的zentaoAccount属性 @user3 -- 获取gitlab服务器1匹配的用户数量。 @2 +- 获取gitlab服务器1匹配的用户数量。 @3 - 当gitlab用户为空时获取gitlab服务器1匹配的用户数量。 @0 - 当禅道用户为空时获取gitlab服务器1匹配的用户数量。 - 第4条的account属性 @user6 @@ -34,4 +34,4 @@ $matchedUsers = $gitlab->getMatchedUsersTest($gitlabID, $gitlabUsers, $zentaoUse r($matchedUsers) && p('1:account,zentaoAccount') && e('root,user3'); // 获取gitlab服务器1匹配的用户列表。 r(count($matchedUsers)) && p('') && e('3'); // 获取gitlab服务器1匹配的用户数量。 r($gitlab->getMatchedUsersTest($gitlabID, array(), $zentaoUsers)) && p('') && e('0'); // 当gitlab用户为空时获取gitlab服务器1匹配的用户数量。 -r($gitlab->getMatchedUsersTest($gitlabID, $gitlabUsers, array())) && p('4:account,zentaoAccount') && e('user6,user6'); // 当禅道用户为空时获取gitlab服务器1匹配的用户数量。 +r($gitlab->getMatchedUsersTest($gitlabID, $gitlabUsers, array())) && p('4:account,zentaoAccount') && e('user6,user6'); // 当禅道用户为空时获取gitlab服务器1匹配的用户数量。 \ No newline at end of file