Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
1c5f83a1
M
metersphere
项目概览
MeterSphere
/
metersphere
上一次同步 3 年多
通知
25
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
metersphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1c5f83a1
编写于
12月 25, 2020
作者:
C
chenjianxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 导出带模块,导入自动生成模块
上级
f7a0463e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
73 addition
and
10 deletion
+73
-10
backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java
...o/metersphere/api/controller/ApiDefinitionController.java
+5
-0
backend/src/main/java/io/metersphere/api/parse/MsParser.java
backend/src/main/java/io/metersphere/api/parse/MsParser.java
+43
-4
frontend/src/business/components/api/definition/ApiDefinition.vue
.../src/business/components/api/definition/ApiDefinition.vue
+16
-4
frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue
...ents/api/definition/components/list/ApiCaseSimpleList.vue
+1
-1
frontend/src/business/components/api/definition/components/module/ApiModuleHeader.vue
...ents/api/definition/components/module/ApiModuleHeader.vue
+1
-1
frontend/src/business/components/common/head/ProjectSwitch.vue
...end/src/business/components/common/head/ProjectSwitch.vue
+6
-0
frontend/src/common/js/constants.js
frontend/src/common/js/constants.js
+1
-0
未找到文件。
backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java
浏览文件 @
1c5f83a1
...
...
@@ -41,6 +41,11 @@ public class ApiDefinitionController {
return
PageUtils
.
setPageInfo
(
page
,
apiDefinitionService
.
list
(
request
));
}
@PostMapping
(
"/list/all"
)
public
List
<
ApiDefinitionResult
>
list
(
@RequestBody
ApiDefinitionRequest
request
)
{
return
apiDefinitionService
.
list
(
request
);
}
@PostMapping
(
value
=
"/create"
,
consumes
=
{
"multipart/form-data"
})
@RequiresRoles
(
value
=
{
RoleConstants
.
TEST_MANAGER
,
RoleConstants
.
TEST_USER
},
logical
=
Logical
.
OR
)
public
void
create
(
@RequestPart
(
"request"
)
SaveApiDefinitionRequest
request
,
@RequestPart
(
value
=
"files"
)
List
<
MultipartFile
>
bodyFiles
)
{
...
...
backend/src/main/java/io/metersphere/api/parse/MsParser.java
浏览文件 @
1c5f83a1
...
...
@@ -15,11 +15,10 @@ import io.metersphere.api.service.ApiModuleService;
import
io.metersphere.base.domain.ApiModule
;
import
io.metersphere.commons.utils.CommonBeanFactory
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.*
;
public
class
MsParser
extends
ApiImportAbstractParser
{
...
...
@@ -42,7 +41,8 @@ public class MsParser extends ApiImportAbstractParser {
List
<
ApiDefinitionResult
>
data
=
apiDefinitionImport
.
getData
();
data
.
forEach
(
apiDefinition
->
{
String
id
=
UUID
.
randomUUID
().
toString
();
apiDefinition
.
setModuleId
(
null
);
// apiDefinition.setModuleId(null);
parseModule
(
apiDefinition
,
importRequest
.
isSaved
());
apiDefinition
.
setId
(
id
);
apiDefinition
.
setProjectId
(
this
.
projectId
);
String
request
=
apiDefinition
.
getRequest
();
...
...
@@ -121,4 +121,43 @@ public class MsParser extends ApiImportAbstractParser {
}
}
}
private
void
parseModule
(
ApiDefinitionResult
apiDefinition
,
Boolean
isSaved
)
{
String
modulePath
=
apiDefinition
.
getModulePath
();
if
(
StringUtils
.
isBlank
(
modulePath
))
{
return
;
}
if
(
modulePath
.
startsWith
(
"/"
))
{
modulePath
=
modulePath
.
substring
(
1
,
modulePath
.
length
());
}
if
(
modulePath
.
endsWith
(
"/"
))
{
modulePath
=
modulePath
.
substring
(
0
,
modulePath
.
length
()
-
1
);
}
List
<
String
>
modules
=
Arrays
.
asList
(
modulePath
.
split
(
"/"
));
ApiModule
parent
=
null
;
Iterator
<
String
>
iterator
=
modules
.
iterator
();
while
(
iterator
.
hasNext
())
{
String
item
=
iterator
.
next
();
parent
=
buildModule
(
item
,
parent
,
isSaved
);
if
(!
iterator
.
hasNext
())
{
apiDefinition
.
setModuleId
(
parent
.
getId
());
}
}
}
private
ApiModule
buildModule
(
String
name
,
ApiModule
parentModule
,
boolean
isSaved
)
{
apiModuleService
=
CommonBeanFactory
.
getBean
(
ApiModuleService
.
class
);
ApiModule
module
;
if
(
parentModule
!=
null
)
{
module
=
apiModuleService
.
getNewModule
(
name
,
this
.
projectId
,
parentModule
.
getLevel
()
+
1
);
module
.
setParentId
(
parentModule
.
getId
());
}
else
{
module
=
apiModuleService
.
getNewModule
(
name
,
this
.
projectId
,
1
);
}
if
(
isSaved
)
{
createModule
(
module
);
}
return
module
;
}
}
frontend/src/business/components/api/definition/ApiDefinition.vue
浏览文件 @
1c5f83a1
...
...
@@ -106,6 +106,7 @@
import
{
downloadFile
,
getCurrentUser
,
getUUID
,
getCurrentProjectID
}
from
"
@/common/js/utils
"
;
import
MsApiModule
from
"
./components/module/ApiModule
"
;
import
ApiCaseSimpleList
from
"
./components/list/ApiCaseSimpleList
"
;
import
{
PROJECT_NAME
}
from
"
../../../../common/js/constants
"
;
export
default
{
name
:
"
ApiDefinition
"
,
...
...
@@ -258,18 +259,29 @@
if
(
this
.
$refs
.
apiList
[
0
].
selectRows
&&
this
.
$refs
.
apiList
[
0
].
selectRows
.
size
>
0
)
{
let
arr
=
Array
.
from
(
this
.
$refs
.
apiList
[
0
].
selectRows
);
obj
.
data
=
arr
;
downloadFile
(
"
导出API.json
"
,
JSON
.
stringify
(
obj
));
this
.
buildApiPath
(
obj
.
data
);
downloadFile
(
"
Metersphere_Api_
"
+
localStorage
.
getItem
(
PROJECT_NAME
)
+
"
.json
"
,
JSON
.
stringify
(
obj
));
}
else
{
let
condition
=
{};
let
url
=
"
/api/definition/list/
1/100000
"
;
let
url
=
"
/api/definition/list/
all
"
;
condition
.
filters
=
[
"
Prepare
"
,
"
Underway
"
,
"
Completed
"
];
condition
.
projectId
=
getCurrentProjectID
();
this
.
$post
(
url
,
condition
,
response
=>
{
obj
.
data
=
response
.
data
.
listObject
;
downloadFile
(
"
导出API.json
"
,
JSON
.
stringify
(
obj
));
obj
.
data
=
response
.
data
;
this
.
buildApiPath
(
obj
.
data
);
downloadFile
(
"
Metersphere_Api_
"
+
localStorage
.
getItem
(
PROJECT_NAME
)
+
"
.json
"
,
JSON
.
stringify
(
obj
));
});
}
},
buildApiPath
(
apis
)
{
apis
.
forEach
((
api
)
=>
{
this
.
moduleOptions
.
forEach
(
item
=>
{
if
(
api
.
moduleId
===
item
.
id
)
{
api
.
modulePath
=
item
.
path
;
}
});
});
},
refresh
(
data
)
{
this
.
$refs
.
apiList
[
0
].
initTable
(
data
);
},
...
...
frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue
浏览文件 @
1c5f83a1
...
...
@@ -34,7 +34,7 @@
</
template
>
</el-table-column>
<el-table-column
prop=
"name"
:label=
"$t('
api_test.definition.api_
name')"
show-overflow-tooltip
/>
<el-table-column
prop=
"name"
:label=
"$t('
test_track.case.
name')"
show-overflow-tooltip
/>
<el-table-column
prop=
"priority"
...
...
frontend/src/business/components/api/definition/components/module/ApiModuleHeader.vue
浏览文件 @
1c5f83a1
...
...
@@ -33,7 +33,7 @@
@
saveAsEdit=
"saveAsEdit"
@
refresh=
"refresh"
ref=
"basisApi"
/>
<api-import
ref=
"apiImport"
@
refresh=
"$emit('refresh
Table
')"
/>
<api-import
ref=
"apiImport"
@
refresh=
"$emit('refresh')"
/>
</div>
</template>
...
...
frontend/src/business/components/common/head/ProjectSwitch.vue
浏览文件 @
1c5f83a1
...
...
@@ -24,6 +24,7 @@
<
script
>
import
SearchList
from
"
@/business/components/common/head/SearchList
"
;
import
{
PROJECT_NAME
}
from
"
../../../../common/js/constants
"
;
export
default
{
name
:
"
ProjectSwitch
"
,
...
...
@@ -31,6 +32,11 @@ export default {
projectName
:
String
},
components
:
{
SearchList
},
watch
:
{
currentProject
()
{
localStorage
.
setItem
(
PROJECT_NAME
,
this
.
currentProject
);
}
},
data
()
{
return
{
currentProject
:
this
.
projectName
...
...
frontend/src/common/js/constants.js
浏览文件 @
1c5f83a1
...
...
@@ -11,6 +11,7 @@ export const ROLE_TEST_VIEWER = 'test_viewer';
export
const
WORKSPACE_ID
=
'
workspace_id
'
;
export
const
CURRENT_PROJECT
=
'
current_project
'
;
export
const
PROJECT_ID
=
'
project_id
'
;
export
const
PROJECT_NAME
=
'
project_name
'
;
export
const
REFRESH_SESSION_USER_URL
=
'
user/refresh
'
;
export
const
WORKSPACE
=
'
workspace
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录