From 16231492a1912bd5ca9dc9c14661c09cf6fba56c Mon Sep 17 00:00:00 2001 From: witersen <1801168257@qq.com> Date: Wed, 27 Apr 2022 02:09:12 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=BD=BB=E5=BA=95=E8=A7=A3=E5=86=B3S?= =?UTF-8?q?VN=E7=94=A8=E6=88=B7=E8=A2=AB=E6=8E=88=E6=9D=83=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E7=9B=AE=E5=BD=95=E6=B5=8F=E8=A7=88=E7=9A=84=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=8E=A7=E5=88=B6=E9=97=AE=E9=A2=98=202=E3=80=81?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E8=B0=83=E6=95=B4=E5=88=B0=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E6=98=AF=E6=96=87=E4=BB=B6=203=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=86=E9=A1=B5=E9=83=A8=E5=88=86=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=88=E6=9D=83=E6=95=B0=E9=87=8F=E4=B8=8D=E5=AF=B9?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 01.web/src/views/repositoryInfo/index.vue | 22 ++++- 02.php/app/controller/svnrep.class.php | 112 +++++++++++++++++++++- 2 files changed, 124 insertions(+), 10 deletions(-) diff --git a/01.web/src/views/repositoryInfo/index.vue b/01.web/src/views/repositoryInfo/index.vue index 917ac64..854f878 100644 --- a/01.web/src/views/repositoryInfo/index.vue +++ b/01.web/src/views/repositoryInfo/index.vue @@ -1381,7 +1381,11 @@ export default { ClickRowGetRepCon(row, index) { if (this.tableDataRepCon[index].resourceType == "2") { this.currentRepTreePath = this.tableDataRepCon[index].fullPath; - this.GetRepCon(); + if (this.user_role_id == 1) { + this.GetRepCon(); + } else if (this.user_role_id == 2) { + this.GetUserRepCon(); + } } }, /** @@ -1389,7 +1393,11 @@ export default { */ ClickBreadGetRepCon(fullPath) { this.currentRepTreePath = fullPath; - this.GetRepCon(); + if (this.user_role_id == 1) { + this.GetRepCon(); + } else if (this.user_role_id == 2) { + this.GetUserRepCon(); + } }, /** * 复制检出地址 @@ -1604,9 +1612,13 @@ export default { * 点击目录树节点触发 */ ChangeSelectTreeNode(selectArray, currentItem) { - this.currentRepTreePriPath = currentItem.fullPath; - this.GetRepPathUserPri(); - this.GetRepPathGroupPri(); + if (currentItem.resourceType == "2") { + this.currentRepTreePriPath = currentItem.fullPath; + this.GetRepPathUserPri(); + this.GetRepPathGroupPri(); + } else { + this.$Message.error("不支持文件授权"); + } }, /** * 异步加载目录下的内容 diff --git a/02.php/app/controller/svnrep.class.php b/02.php/app/controller/svnrep.class.php index a8f09a0..38704bb 100644 --- a/02.php/app/controller/svnrep.class.php +++ b/02.php/app/controller/svnrep.class.php @@ -3,7 +3,7 @@ * @Author: witersen * @Date: 2022-04-24 23:37:05 * @LastEditors: witersen - * @LastEditTime: 2022-04-26 21:38:11 + * @LastEditTime: 2022-04-27 02:06:19 * @Description: QQ:1801168257 */ @@ -331,6 +331,7 @@ class svnrep extends controller 'rep_name[~]' => $searchKeyword, ], ], + 'svn_user_name' => $this->globalUserName ]); FunMessageExit(200, 1, '成功', [ @@ -358,6 +359,10 @@ class svnrep extends controller */ function GetUserRepCon() { + $path = $this->requestPayload['path']; + + $repName = $this->requestPayload['rep_name']; + /** * 获取svn检出地址 * @@ -377,11 +382,108 @@ class svnrep extends controller FunMessageExit(200, 0, '用户不存在' . $this->globalUserName); } - //检查权限 - $result = CheckSvnUserPathAutzh($checkoutHost, $this->requestPayload['rep_name'], $this->requestPayload['path'], $this->globalUserName, $svnUserPass); - FunMessageExit(200, 0, 'test', $result); - } + $cmdSvnList = sprintf("svn list '%s' --username '%s' --password '%s' --no-auth-cache --non-interactive --trust-server-cert", $checkoutHost . '/' . $repName . $path, $this->globalUserName, $svnUserPass); + $result = FunShellExec($cmdSvnList); + + if ($result == ISNULL) { + $resultArray = []; + } else { + if (strstr($result, 'svn: E170001: Authentication error from server: Password incorrect')) { + FunMessageExit(200, 0, '密码错误'); + } + if (strstr($result, 'svn: E170001: Authorization failed')) { + FunMessageExit(200, 0, '没有权限'); + } + if (strstr($result, 'svn: E170013: Unable to connect to a repository at URL')) { + FunMessageExit(200, 0, '其它错误'); + } + + $resultArray = explode("\n", trim($result)); + } + + $data = []; + foreach ($resultArray as $key => $value) { + //补全路径 + if (substr($path, strlen($path) - 1, 1) == '/') { + $value = $path . $value; + } else { + $value = $path . '/' . $value; + } + + //获取文件或者文件夹最年轻的版本号 + $lastRev = FunGetRepFileRev($repName, $value); + + //获取文件或者文件夹最年轻的版本的作者 + $lastRevAuthor = FunGetRepFileAuthor($repName, $lastRev); + + //同上 日期 + $lastRevDate = FunGetRepFileDate($repName, $lastRev); + + //同上 日志 + $lastRevLog = FunGetRepFileLog($repName, $lastRev); + + $pathArray = explode('/', $value); + $pathArray = array_values(array_filter($pathArray, 'FunArrayValueFilter')); + $pathArrayCount = count($pathArray); + if (substr($value, strlen($value) - 1, 1) == '/') { + array_push($data, [ + 'resourceType' => 2, + 'resourceName' => $pathArray[$pathArrayCount - 1], + 'fileSize' => '', + 'revAuthor' => $lastRevAuthor, + 'revNum' => 'r' . $lastRev, + 'revTime' => $lastRevDate, + 'revLog' => $lastRevLog, + 'fullPath' => $value + ]); + } else { + array_push($data, [ + 'resourceType' => 1, + 'resourceName' => $pathArray[$pathArrayCount - 1], + 'fileSize' => FunGetRepRevFileSize($repName, $value), + 'revAuthor' => $lastRevAuthor, + 'revNum' => 'r' . $lastRev, + 'revTime' => $lastRevDate, + 'revLog' => $lastRevLog, + 'fullPath' => $value + ]); + } + } + //处理面包屑 + if ($path == '/') { + $breadPathArray = ['/']; + $breadNameArray = [$repName]; + } else { + $pathArray = explode('/', $path); + //将全路径处理为带有/的数组 + $tempArray = []; + array_push($tempArray, '/'); + for ($i = 0; $i < count($pathArray); $i++) { + if ($pathArray[$i] != '') { + array_push($tempArray, $pathArray[$i]); + array_push($tempArray, '/'); + } + } + //处理为递增的路径数组 + $breadPathArray = ['/']; + $breadNameArray = [$repName]; + $tempPath = '/'; + for ($i = 1; $i < count($tempArray); $i += 2) { + $tempPath .= $tempArray[$i] . $tempArray[$i + 1]; + array_push($breadPathArray, $tempPath); + array_push($breadNameArray, $tempArray[$i]); + } + } + + FunMessageExit(200, 1, '', [ + 'data' => $data, + 'bread' => [ + 'path' => $breadPathArray, + 'name' => $breadNameArray + ] + ]); + } /** * 管理人员根据目录名称获取该目录下的文件和文件夹列表