Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
6e6cc5f3
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
11 个月 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6e6cc5f3
编写于
11月 11, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zentao url parse
上级
a22f8f36
变更
4
展开全部
显示空白变更内容
内联
并排
Showing
4 changed file
with
43 addition
and
595 deletion
+43
-595
internal/pkg/helper/stdin/stdin.go
internal/pkg/helper/stdin/stdin.go
+8
-4
internal/pkg/helper/zentao/zentao.go
internal/pkg/helper/zentao/zentao.go
+14
-5
internal/server/modules/v1/service/site.go
internal/server/modules/v1/service/site.go
+21
-8
res/res.go
res/res.go
+0
-578
未找到文件。
internal/pkg/helper/stdin/stdin.go
浏览文件 @
6e6cc5f3
...
...
@@ -12,7 +12,6 @@ import (
scriptHelper
"github.com/easysoft/zentaoatf/internal/pkg/helper/script"
zentaoHelper
"github.com/easysoft/zentaoatf/internal/pkg/helper/zentao"
commonUtils
"github.com/easysoft/zentaoatf/pkg/lib/common"
fileUtils
"github.com/easysoft/zentaoatf/pkg/lib/file"
i118Utils
"github.com/easysoft/zentaoatf/pkg/lib/i118"
logUtils
"github.com/easysoft/zentaoatf/pkg/lib/log"
stdinUtils
"github.com/easysoft/zentaoatf/pkg/lib/stdin"
...
...
@@ -127,17 +126,22 @@ func InputForSet(dir string) {
SetZentao
:
conf
.
Url
=
stdinUtils
.
GetInput
(
"((http|https)://.*)"
,
conf
.
Url
,
"enter_url"
,
conf
.
Url
)
conf
.
Url
=
zentaoHelper
.
FixSiteUrl
(
conf
.
Url
)
conf
.
Url
=
fileUtils
.
AddUrlPathSepIfNeeded
(
conf
.
Url
)
conf
.
Username
=
stdinUtils
.
GetInput
(
"(.{2,})"
,
conf
.
Username
,
"enter_account"
,
conf
.
Username
)
conf
.
Password
=
stdinUtils
.
GetInput
(
"(.{2,})"
,
conf
.
Password
,
"enter_password"
,
conf
.
Password
)
url1
,
url2
:=
zentaoHelper
.
FixSiteUrl
(
conf
.
Url
)
conf
.
Url
=
url1
err
:=
zentaoHelper
.
Login
(
conf
)
if
err
!=
nil
{
conf
.
Url
=
url2
err
=
zentaoHelper
.
Login
(
conf
)
if
err
!=
nil
{
goto
SetZentao
}
}
}
if
commonUtils
.
IsWin
()
{
var
configInterpreter
bool
...
...
internal/pkg/helper/zentao/zentao.go
浏览文件 @
6e6cc5f3
...
...
@@ -2,6 +2,7 @@ package zentaoHelper
import
(
"fmt"
fileUtils
"github.com/easysoft/zentaoatf/pkg/lib/file"
"net/url"
"regexp"
"strings"
...
...
@@ -110,12 +111,20 @@ func FixUrl(url string) (ret string) {
return
}
func
FixSiteUrl
(
orginUrl
string
)
(
ret
string
)
{
func
FixSiteUrl
(
orginUrl
string
)
(
url1
,
url2
string
)
{
u
,
_
:=
url
.
Parse
(
orginUrl
)
ret
=
fmt
.
Sprintf
(
"%s://%s"
,
u
.
Scheme
,
u
.
Host
)
ret
+=
"/"
if
len
(
u
.
Path
)
>=
7
&&
u
.
Path
[
:
7
]
==
"/zentao"
{
ret
=
ret
+
"zentao/"
url1
=
fmt
.
Sprintf
(
"%s://%s"
,
u
.
Scheme
,
u
.
Host
)
url1
+=
"/"
pth
:=
strings
.
Replace
(
orginUrl
,
url1
,
""
,
-
1
)
pth
=
strings
.
TrimLeft
(
pth
,
"/"
)
arr
:=
strings
.
Split
(
pth
,
"/"
)
if
len
(
arr
)
>
1
{
url2
=
url1
+
arr
[
0
]
}
url1
=
fileUtils
.
AddUrlPathSepIfNeeded
(
url1
)
url2
=
fileUtils
.
AddUrlPathSepIfNeeded
(
url2
)
return
}
internal/server/modules/v1/service/site.go
浏览文件 @
6e6cc5f3
...
...
@@ -10,7 +10,6 @@ import (
"github.com/easysoft/zentaoatf/internal/server/modules/v1/model"
"github.com/easysoft/zentaoatf/internal/server/modules/v1/repo"
"github.com/easysoft/zentaoatf/pkg/domain"
fileUtils
"github.com/easysoft/zentaoatf/pkg/lib/file"
)
type
SiteService
struct
{
...
...
@@ -44,18 +43,24 @@ func (s *SiteService) GetDomainObject(id uint) (site serverDomain.ZentaoSite, er
}
func
(
s
*
SiteService
)
Create
(
site
model
.
Site
)
(
id
uint
,
isDuplicate
bool
,
err
error
)
{
site
.
Url
=
zentaoHelper
.
FixSiteUrl
(
site
.
Url
)
if
site
.
Url
==
""
{
url1
,
url2
:
=
zentaoHelper
.
FixSiteUrl
(
site
.
Url
)
if
url1
==
""
{
err
=
errors
.
New
(
"url not right"
)
return
}
site
.
Url
=
fileUtils
.
AddUrlPathSepIfNeeded
(
site
.
Url
)
site
.
Url
=
url1
config
:=
configHelper
.
LoadBySite
(
site
)
err
=
zentaoHelper
.
Login
(
config
)
if
err
!=
nil
{
site
.
Url
=
url2
config
:=
configHelper
.
LoadBySite
(
site
)
err
=
zentaoHelper
.
Login
(
config
)
if
err
!=
nil
{
return
}
}
id
,
isDuplicate
,
err
=
s
.
SiteRepo
.
Create
(
&
site
)
...
...
@@ -63,16 +68,24 @@ func (s *SiteService) Create(site model.Site) (id uint, isDuplicate bool, err er
}
func
(
s
*
SiteService
)
Update
(
site
model
.
Site
)
(
isDuplicate
bool
,
err
error
)
{
site
.
Url
=
zentaoHelper
.
FixSiteUrl
(
site
.
Url
)
if
site
.
Url
==
""
{
url1
,
url2
:
=
zentaoHelper
.
FixSiteUrl
(
site
.
Url
)
if
url1
==
""
{
err
=
errors
.
New
(
"url not right"
)
return
}
site
.
Url
=
url1
config
:=
configHelper
.
LoadBySite
(
site
)
err
=
zentaoHelper
.
Login
(
config
)
if
err
!=
nil
{
site
.
Url
=
url2
config
:=
configHelper
.
LoadBySite
(
site
)
err
=
zentaoHelper
.
Login
(
config
)
if
err
!=
nil
{
return
}
}
isDuplicate
,
err
=
s
.
SiteRepo
.
Update
(
site
)
if
isDuplicate
||
err
!=
nil
{
...
...
res/res.go
已删除
100644 → 0
浏览文件 @
a22f8f36
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录