Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
a003603c
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
a003603c
编写于
3月 18, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
show filter list
上级
9494dd03
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
186 addition
and
26 deletion
+186
-26
internal/comm/consts/enum.go
internal/comm/consts/enum.go
+9
-0
internal/server/modules/v1/controller/test-filter.go
internal/server/modules/v1/controller/test-filter.go
+26
-0
internal/server/modules/v1/controller/workspace.go
internal/server/modules/v1/controller/workspace.go
+5
-0
internal/server/modules/v1/domain/test-script.go
internal/server/modules/v1/domain/test-script.go
+5
-0
internal/server/modules/v1/index.go
internal/server/modules/v1/index.go
+3
-0
internal/server/modules/v1/index/test-filter.go
internal/server/modules/v1/index/test-filter.go
+26
-0
internal/server/modules/v1/model/workspace.go
internal/server/modules/v1/model/workspace.go
+8
-6
internal/server/modules/v1/repo/workspace.go
internal/server/modules/v1/repo/workspace.go
+2
-2
internal/server/modules/v1/service/test-filter.go
internal/server/modules/v1/service/test-filter.go
+53
-0
internal/server/modules/v1/service/test-script.go
internal/server/modules/v1/service/test-script.go
+2
-1
ui/src/store/zentao.ts
ui/src/store/zentao.ts
+11
-3
ui/src/utils/cache.ts
ui/src/utils/cache.ts
+4
-2
ui/src/views/script/index.vue
ui/src/views/script/index.vue
+21
-10
ui/src/views/script/service.ts
ui/src/views/script/service.ts
+11
-2
未找到文件。
internal/comm/consts/enum.go
浏览文件 @
a003603c
...
...
@@ -163,3 +163,12 @@ const (
Dir
TreeNodeType
=
"dir"
File
TreeNodeType
=
"file"
)
type
ScriptFilterType
string
const
(
FilterWorkspace
ScriptFilterType
=
"workspace"
FilterModule
ScriptFilterType
=
"module"
FilterSuite
ScriptFilterType
=
"suite"
FilterTask
ScriptFilterType
=
"task"
)
internal/server/modules/v1/controller/test-filter.go
0 → 100644
浏览文件 @
a003603c
package
controller
import
(
commConsts
"github.com/aaronchen2k/deeptest/internal/comm/consts"
"github.com/aaronchen2k/deeptest/internal/server/modules/v1/service"
"github.com/kataras/iris/v12"
)
type
TestFilterCtrl
struct
{
TestFilterService
*
service
.
TestFilterService
`inject:""`
BaseCtrl
}
func
NewTestFilterCtrl
()
*
TestFilterCtrl
{
return
&
TestFilterCtrl
{}
}
// ListItems 获取脚本过滤器的内容列表
func
(
c
*
TestFilterCtrl
)
ListItems
(
ctx
iris
.
Context
)
{
currSiteId
,
_
:=
ctx
.
URLParamInt
(
"currSiteId"
)
currProductId
,
_
:=
ctx
.
URLParamInt
(
"currProductId"
)
filerType
:=
ctx
.
URLParam
(
"filerType"
)
ret
,
_
:=
c
.
TestFilterService
.
ListFilterItems
(
commConsts
.
ScriptFilterType
(
filerType
),
currSiteId
,
currProductId
)
ctx
.
JSON
(
c
.
SuccessResp
(
ret
))
}
internal/server/modules/v1/controller/workspace.go
浏览文件 @
a003603c
...
...
@@ -57,7 +57,9 @@ func (c *WorkspaceCtrl) Get(ctx iris.Context) {
}
func
(
c
*
WorkspaceCtrl
)
Create
(
ctx
iris
.
Context
)
{
currSiteId
,
_
:=
ctx
.
URLParamInt
(
"currSiteId"
)
currProductId
,
_
:=
ctx
.
URLParamInt
(
"currProductId"
)
if
currProductId
<=
0
{
ctx
.
JSON
(
c
.
ErrResp
(
commConsts
.
ParamErr
,
fmt
.
Sprintf
(
"参数%s不合法"
,
"currProductId"
)))
return
...
...
@@ -68,6 +70,7 @@ func (c *WorkspaceCtrl) Create(ctx iris.Context) {
ctx
.
JSON
(
c
.
ErrResp
(
commConsts
.
CommErr
,
err
.
Error
()))
}
req
.
SiteId
=
uint
(
currSiteId
)
req
.
ProductId
=
uint
(
currProductId
)
id
,
err
:=
c
.
WorkspaceService
.
Create
(
req
)
if
err
!=
nil
{
...
...
@@ -79,6 +82,7 @@ func (c *WorkspaceCtrl) Create(ctx iris.Context) {
}
func
(
c
*
WorkspaceCtrl
)
Update
(
ctx
iris
.
Context
)
{
currSiteId
,
_
:=
ctx
.
URLParamInt
(
"currSiteId"
)
currProductId
,
_
:=
ctx
.
URLParamInt
(
"currProductId"
)
if
currProductId
<=
0
{
ctx
.
JSON
(
c
.
ErrResp
(
commConsts
.
ParamErr
,
fmt
.
Sprintf
(
"参数%s不合法"
,
"currProductId"
)))
...
...
@@ -90,6 +94,7 @@ func (c *WorkspaceCtrl) Update(ctx iris.Context) {
ctx
.
JSON
(
c
.
ErrResp
(
commConsts
.
CommErr
,
err
.
Error
()))
}
req
.
SiteId
=
uint
(
currSiteId
)
req
.
ProductId
=
uint
(
currProductId
)
err
:=
c
.
WorkspaceService
.
Update
(
req
)
if
err
!=
nil
{
...
...
internal/server/modules/v1/domain/test-script.go
浏览文件 @
a003603c
...
...
@@ -9,3 +9,8 @@ type TestScript struct {
WorkspaceId
uint
`json:"workspaceId"`
}
type
FilterItem
struct
{
Label
string
`json:"label"`
Value
int
`json:"value"`
}
internal/server/modules/v1/index.go
浏览文件 @
a003603c
...
...
@@ -20,6 +20,7 @@ type IndexModule struct {
SyncModule
*
index
.
SyncModule
`inject:""`
WorkspaceModule
*
index
.
WorkspaceModule
`inject:""`
TestFilterModule
*
index
.
TestFilterModule
`inject:""`
TestScriptModule
*
index
.
TestScriptModule
`inject:""`
TestExecModule
*
index
.
TestExecModule
`inject:""`
TestResultModule
*
index
.
TestResultModule
`inject:""`
...
...
@@ -49,6 +50,8 @@ func (m *IndexModule) Party() module.WebModule {
m
.
ConfigModule
.
Party
(),
m
.
SyncModule
.
Party
(),
m
.
WorkspaceModule
.
Party
(),
m
.
TestFilterModule
.
Party
(),
m
.
TestScriptModule
.
Party
(),
m
.
TestExecModule
.
Party
(),
m
.
TestBugModule
.
Party
(),
...
...
internal/server/modules/v1/index/test-filter.go
0 → 100644
浏览文件 @
a003603c
package
index
import
(
"github.com/aaronchen2k/deeptest/internal/server/core/module"
"github.com/aaronchen2k/deeptest/internal/server/middleware"
"github.com/aaronchen2k/deeptest/internal/server/modules/v1/controller"
"github.com/kataras/iris/v12"
)
type
TestFilterModule
struct
{
TestFilterCtrl
*
controller
.
TestFilterCtrl
`inject:""`
}
func
NewTestFilterModule
()
*
TestFilterModule
{
return
&
TestFilterModule
{}
}
// Party 脚本
func
(
m
*
TestFilterModule
)
Party
()
module
.
WebModule
{
handler
:=
func
(
index
iris
.
Party
)
{
index
.
Use
(
middleware
.
InitCheck
())
index
.
Get
(
"/listItems"
,
m
.
TestFilterCtrl
.
ListItems
)
.
Name
=
"获取脚本过滤器的内容列表"
}
return
module
.
NewModule
(
"/filters"
,
handler
)
}
internal/server/modules/v1/model/workspace.go
浏览文件 @
a003603c
...
...
@@ -5,12 +5,14 @@ import commConsts "github.com/aaronchen2k/deeptest/internal/comm/consts"
type
Workspace
struct
{
BaseModel
Path
string
`json:"path"`
Name
string
`json:"name"`
Desc
string
`json:"desc" gorm:"column:descr"`
Type
commConsts
.
TestTool
`json:"type" gorm:"default:ztf"`
Cmd
string
`json:"cmd"`
ProductId
uint
`json:"productId"`
Path
string
`json:"path"`
Name
string
`json:"name"`
Desc
string
`json:"desc" gorm:"column:descr"`
Type
commConsts
.
TestTool
`json:"type" gorm:"default:ztf"`
Cmd
string
`json:"cmd"`
SiteId
uint
`json:"siteId"`
ProductId
uint
`json:"productId"`
IsDefault
bool
`json:"isDefault"`
}
...
...
internal/server/modules/v1/repo/workspace.go
浏览文件 @
a003603c
...
...
@@ -195,9 +195,9 @@ func (r *WorkspaceRepo) SetCurrWorkspace(pth string) (err error) {
return
err
}
func
(
r
*
WorkspaceRepo
)
ListWorkspacesByProduct
(
productId
int
)
(
pos
[]
model
.
Workspace
,
err
error
)
{
func
(
r
*
WorkspaceRepo
)
ListWorkspacesByProduct
(
siteId
,
productId
int
)
(
pos
[]
model
.
Workspace
,
err
error
)
{
err
=
r
.
DB
.
Model
(
&
model
.
Workspace
{})
.
Where
(
"
product_id = ?"
,
productId
)
.
Where
(
"
site_id = ? AND product_id = ?"
,
siteId
,
productId
)
.
Where
(
"NOT deleted AND NOT disabled"
)
.
Find
(
&
pos
)
.
Error
...
...
internal/server/modules/v1/service/test-filter.go
0 → 100644
浏览文件 @
a003603c
package
service
import
(
commConsts
"github.com/aaronchen2k/deeptest/internal/comm/consts"
serverDomain
"github.com/aaronchen2k/deeptest/internal/server/modules/v1/domain"
"github.com/aaronchen2k/deeptest/internal/server/modules/v1/repo"
)
type
TestFilterService
struct
{
WorkspaceRepo
*
repo
.
WorkspaceRepo
`inject:""`
SiteService
*
SiteService
`inject:""`
}
func
NewTestFilterService
()
*
TestFilterService
{
return
&
TestFilterService
{}
}
func
(
s
*
TestFilterService
)
ListFilterItems
(
filerType
commConsts
.
ScriptFilterType
,
siteId
int
,
productId
int
)
(
ret
[]
serverDomain
.
FilterItem
,
err
error
)
{
if
filerType
==
commConsts
.
FilterWorkspace
{
ret
,
err
=
s
.
ListWorkspaceFilter
(
siteId
,
productId
)
return
}
//site, _ := s.SiteService.GetDomainObject(uint(siteId))
//config := commDomain.WorkspaceConf{
// Url: site.Url,
// Username: site.Username,
// Password: site.Password,
//}
if
filerType
==
commConsts
.
FilterModule
{
}
else
if
filerType
==
commConsts
.
FilterSuite
{
}
else
if
filerType
==
commConsts
.
FilterTask
{
}
return
}
func
(
s
*
TestFilterService
)
ListWorkspaceFilter
(
siteId
int
,
productId
int
)
(
ret
[]
serverDomain
.
FilterItem
,
err
error
)
{
workspaces
,
err
:=
s
.
WorkspaceRepo
.
ListWorkspacesByProduct
(
siteId
,
productId
)
for
_
,
item
:=
range
workspaces
{
filterItem
:=
serverDomain
.
FilterItem
{
Label
:
item
.
Name
,
Value
:
int
(
item
.
ID
)}
ret
=
append
(
ret
,
filterItem
)
}
return
}
internal/server/modules/v1/service/test-script.go
浏览文件 @
a003603c
...
...
@@ -10,6 +10,7 @@ import (
type
TestScriptService
struct
{
WorkspaceRepo
*
repo
.
WorkspaceRepo
`inject:""`
SiteService
*
SiteService
`inject:""`
}
func
NewTestScriptService
()
*
TestScriptService
{
...
...
@@ -19,7 +20,7 @@ func NewTestScriptService() *TestScriptService {
func
(
s
*
TestScriptService
)
LoadTestScriptsBySiteProduct
(
site
serverDomain
.
ZentaoSite
,
product
serverDomain
.
ZentaoProduct
)
(
root
serverDomain
.
TestAsset
,
err
error
)
{
workspaces
,
_
:=
s
.
WorkspaceRepo
.
ListWorkspacesByProduct
(
product
.
Id
)
workspaces
,
_
:=
s
.
WorkspaceRepo
.
ListWorkspacesByProduct
(
site
.
Id
,
product
.
Id
)
root
=
serverDomain
.
TestAsset
{
Path
:
""
,
Title
:
"测试脚本"
,
Type
:
commConsts
.
Root
,
Slots
:
iris
.
Map
{
"icon"
:
"icon"
}}
for
_
,
workspace
:=
range
workspaces
{
...
...
ui/src/store/zentao.ts
浏览文件 @
a003603c
...
...
@@ -16,7 +16,9 @@ export interface ZentaoData {
testScripts
:
any
[]
currSite
:
any
currProduct
:
any
scriptLoaded
:
boolean
filerItems
:
any
[]
modules
:
any
[]
suites
:
any
[]
...
...
@@ -58,7 +60,9 @@ const initState: ZentaoData = {
testScripts
:
[],
currSite
:
{},
currProduct
:
{},
scriptLoaded
:
false
,
filerItems
:
[],
modules
:
[],
suites
:
[],
...
...
@@ -83,11 +87,12 @@ const StoreModel: ModuleType = {
async
saveSitesAndProducts
(
state
,
payload
)
{
state
.
sites
=
payload
.
sites
;
state
.
products
=
payload
.
products
;
if
(
payload
.
testScripts
)
{
state
.
scriptLoaded
=
payload
.
needLoadScript
if
(
state
.
scriptLoaded
)
{
state
.
testScripts
=
[
payload
.
testScripts
];
state
.
scriptLoaded
=
true
}
else
{
state
.
scriptLoaded
=
false
state
.
testScripts
=
[];
}
state
.
currSite
=
payload
.
currSite
;
...
...
@@ -146,6 +151,9 @@ const StoreModel: ModuleType = {
async
fetchSitesAndProducts
({
commit
},
payload
)
{
const
response
:
ResponseData
=
await
querySiteAndProduct
(
payload
);
const
{
data
}
=
response
;
data
.
needLoadScript
=
payload
.
needLoadScript
commit
(
'
saveSitesAndProducts
'
,
data
)
return
true
;
...
...
ui/src/utils/cache.ts
浏览文件 @
a003603c
...
...
@@ -37,10 +37,12 @@ export const getScriptFilters = async () => {
}
export
const
setScriptFilters
=
async
(
by
,
val
)
=>
{
let
mp
=
await
getCache
(
settings
.
scriptFilters
);
if
(
!
mp
)
mp
=
{}
mp
.
by
=
by
mp
[
by
]
=
val
if
(
val
)
mp
[
by
]
=
val
console
.
log
(
'
---
'
,
mp
)
await
setCache
(
settings
.
scriptFilters
,
mp
);
}
ui/src/views/script/index.vue
浏览文件 @
a003603c
...
...
@@ -25,8 +25,8 @@
:bordered=
"false"
:dropdownMatchSelectWidth=
"false"
>
<a-select-option
v-for=
"item in filerItems"
:key=
"item.
id"
:value=
"item.id
"
>
{{
item
.
name
}}
<a-select-option
v-for=
"item in filerItems"
:key=
"item.
value"
:value=
"item.value
"
>
{{
item
.
label
}}
</a-select-option>
</a-select>
</div>
...
...
@@ -92,7 +92,8 @@ import {Empty, message, notification} from "ant-design-vue";
import
{
MonacoOptions
}
from
"
@/utils/const
"
;
import
MonacoEditor
from
"
@/components/Editor/MonacoEditor.vue
"
;
import
{
ZentaoData
}
from
"
@/store/zentao
"
;
import
{
getScriptFilters
}
from
"
@/utils/cache
"
;
import
{
getScriptFilters
,
setScriptFilters
}
from
"
@/utils/cache
"
;
import
{
listFilterItems
}
from
"
@/views/script/service
"
;
interface
ListScriptPageSetupData
{
t
:
(
key
:
string
|
number
)
=>
string
;
...
...
@@ -153,16 +154,26 @@ export default defineComponent({
let
filerItems
=
ref
([]
as
any
)
const
filerType
=
ref
(
''
)
const
filerValue
=
ref
(
''
)
getScriptFilters
().
then
(
(
filter
)
=>
{
const
loadFilterItems
=
async
()
=>
{
const
filter
=
await
getScriptFilters
()
filerType
.
value
=
filter
.
by
filerValue
.
value
=
filter
.
val
// filerItems =
})
const
selectFilerType
=
(
val
)
=>
{
console
.
log
(
'
selectFilerType
'
)
listFilterItems
(
filerType
.
value
).
then
((
data
)
=>
{
console
.
log
(
'
ksjdhfdsf
'
,
data
)
filerItems
.
value
=
data
.
data
})
}
loadFilterItems
()
const
selectFilerType
=
async
(
val
)
=>
{
console
.
log
(
'
selectFilerType
'
,
val
)
await
setScriptFilters
(
val
,
null
)
await
loadFilterItems
()
}
const
selectFilerValue
=
(
val
)
=>
{
console
.
log
(
'
selectFilerValue
'
)
const
selectFilerValue
=
async
(
val
)
=>
{
console
.
log
(
'
selectFilerValue
'
,
val
)
await
setScriptFilters
(
filerType
.
value
,
val
)
}
const
expandedKeys
=
ref
<
string
[]
>
([]);
...
...
ui/src/views/script/service.ts
浏览文件 @
a003603c
...
...
@@ -2,12 +2,21 @@ import request from '@/utils/request';
import
{
Script
}
from
'
./data.d
'
;
const
apiPath
=
'
scripts
'
;
const
apiPathFilters
=
'
filters
'
;
export
async
function
listFilterItems
(
filerType
:
string
):
Promise
<
any
>
{
const
params
=
{
filerType
:
filerType
}
return
request
({
url
:
`/
${
apiPathFilters
}
/listItems`
,
params
});
}
export
async
function
get
(
path
:
string
):
Promise
<
any
>
{
const
params
=
{
path
:
path
}
return
request
({
url
:
`/
scripts
/get`
,
url
:
`/
${
apiPath
}
/get`
,
params
});
}
...
...
@@ -16,7 +25,7 @@ export async function extract(path: string): Promise<any> {
const
params
=
{
path
:
path
}
return
request
({
url
:
`/
scripts
/extract`
,
url
:
`/
${
apiPath
}
/extract`
,
params
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录