Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
23749780
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,发现更多精彩内容 >>
提交
23749780
编写于
4月 28, 2021
作者:
黎
黎龙鑫
提交者:
jianxing
4月 28, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(系统设置):重构环境列表显示
上级
01171820
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
86 addition
and
40 deletion
+86
-40
backend/src/main/java/io/metersphere/api/controller/ApiTestEnvironmentController.java
...ersphere/api/controller/ApiTestEnvironmentController.java
+22
-0
backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java
...io/metersphere/api/service/ApiTestEnvironmentService.java
+12
-0
backend/src/main/java/io/metersphere/controller/request/EnvironmentRequest.java
...io/metersphere/controller/request/EnvironmentRequest.java
+14
-0
frontend/src/business/components/settings/project/EnvironmentList.vue
.../business/components/settings/project/EnvironmentList.vue
+38
-40
未找到文件。
backend/src/main/java/io/metersphere/api/controller/ApiTestEnvironmentController.java
浏览文件 @
23749780
package
io.metersphere.api.controller
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.PageHelper
;
import
io.metersphere.api.service.ApiTestEnvironmentService
;
import
io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs
;
import
io.metersphere.commons.constants.RoleConstants
;
import
io.metersphere.commons.utils.PageUtils
;
import
io.metersphere.commons.utils.Pager
;
import
io.metersphere.controller.request.EnvironmentRequest
;
import
io.metersphere.service.CheckPermissionService
;
import
org.apache.shiro.authz.annotation.Logical
;
import
org.apache.shiro.authz.annotation.RequiresRoles
;
...
...
@@ -27,6 +32,23 @@ public class ApiTestEnvironmentController {
return
apiTestEnvironmentService
.
list
(
projectId
);
}
/**
* 查询指定项目和指定名称的环境
* @param goPage
* @param pageSize
* @param environmentRequest
* @return
*/
@PostMapping
(
"/list/{goPage}/{pageSize}"
)
public
Pager
<
List
<
ApiTestEnvironmentWithBLOBs
>>
listByCondition
(
@PathVariable
int
goPage
,
@PathVariable
int
pageSize
,
@RequestBody
EnvironmentRequest
environmentRequest
)
{
List
<
String
>
projectIds
=
environmentRequest
.
getProjectIds
();
for
(
String
projectId
:
projectIds
)
{
checkPermissionService
.
checkProjectOwner
(
projectId
);
}
Page
<
Object
>
page
=
PageHelper
.
startPage
(
goPage
,
pageSize
,
true
);
return
PageUtils
.
setPageInfo
(
page
,
apiTestEnvironmentService
.
listByConditions
(
environmentRequest
));
}
@GetMapping
(
"/get/{id}"
)
public
ApiTestEnvironmentWithBLOBs
get
(
@PathVariable
String
id
)
{
return
apiTestEnvironmentService
.
get
(
id
);
...
...
backend/src/main/java/io/metersphere/api/service/ApiTestEnvironmentService.java
浏览文件 @
23749780
...
...
@@ -7,6 +7,7 @@ import io.metersphere.base.domain.ApiTestEnvironmentExample;
import
io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs
;
import
io.metersphere.base.mapper.ApiTestEnvironmentMapper
;
import
io.metersphere.commons.exception.MSException
;
import
io.metersphere.controller.request.EnvironmentRequest
;
import
io.metersphere.i18n.Translator
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
...
...
@@ -31,6 +32,17 @@ public class ApiTestEnvironmentService {
return
apiTestEnvironmentMapper
.
selectByExampleWithBLOBs
(
example
);
}
public
List
<
ApiTestEnvironmentWithBLOBs
>
listByConditions
(
EnvironmentRequest
environmentRequest
)
{
ApiTestEnvironmentExample
example
=
new
ApiTestEnvironmentExample
();
ApiTestEnvironmentExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andProjectIdIn
(
environmentRequest
.
getProjectIds
());
if
(
StringUtils
.
isNotBlank
(
environmentRequest
.
getName
()))
{
environmentRequest
.
setName
(
StringUtils
.
wrapIfMissing
(
environmentRequest
.
getName
(),
'%'
));
//使搜索文本变成数据库中的正则表达式
criteria
.
andNameLike
(
environmentRequest
.
getName
());
}
return
apiTestEnvironmentMapper
.
selectByExampleWithBLOBs
(
example
);
}
public
List
<
ApiTestEnvironmentWithBLOBs
>
selectByExampleWithBLOBs
(
ApiTestEnvironmentExample
example
)
{
return
apiTestEnvironmentMapper
.
selectByExampleWithBLOBs
(
example
);
}
...
...
backend/src/main/java/io/metersphere/controller/request/EnvironmentRequest.java
0 → 100644
浏览文件 @
23749780
package
io.metersphere.controller.request
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.List
;
@Getter
@Setter
public
class
EnvironmentRequest
{
private
String
name
;
//查询时的环境名称条件
private
List
<
String
>
projectIds
;
}
frontend/src/business/components/settings/project/EnvironmentList.vue
浏览文件 @
23749780
...
...
@@ -14,9 +14,8 @@
</ms-table-header>
</template>
<!-- 环境列表内容 -->
<!-- 实现搜索,根据搜索内容变换显示的环境列表 -->
<el-table
border
:data=
"environments.filter(env => !searchText || env.name.toLowerCase().includes(searchText.toLowerCase()))"
@
selection-change=
"handleSelectionChange"
max-height=
"515"
class=
"adjust-table"
style=
"width: 100%"
ref=
"table"
>
<el-table
border
:data=
"environments"
@
selection-change=
"handleSelectionChange"
class=
"adjust-table"
style=
"width: 100%"
ref=
"table"
>
<el-table-column
type=
"selection"
></el-table-column>
<el-table-column
:label=
"$t('commons.project')"
width=
"250"
show-overflow-tooltip
>
<
template
v-slot=
"scope"
>
...
...
@@ -42,9 +41,8 @@
</template>
</el-table-column>
</el-table>
<el-row
type=
"flex"
justify=
"end"
>
<el-pagination
layout=
"total"
:total=
"total"
></el-pagination>
</el-row>
<ms-table-pagination
:change=
"list"
:current-page.sync=
"currentPage"
:page-size.sync=
"pageSize"
:total=
"total"
/>
</el-card>
<!-- 创建、编辑、复制环境时的对话框 -->
...
...
@@ -126,7 +124,7 @@
return
{
btnTips
:
this
.
$t
(
'
api_test.environment.create
'
),
projectList
:
[],
condition
:
{
envName
:
''
},
//用于搜索框
condition
:
{
},
//封装传递给后端的查询条件
environments
:
[],
currentEnvironment
:
new
Environment
(),
result
:
{},
...
...
@@ -138,20 +136,21 @@
isTesterPermission
:
false
,
domainVisible
:
false
,
conditions
:
[],
currentPage
:
1
,
pageSize
:
10
,
total
:
0
,
projectIds
:
[],
//当前工作空间所拥有的所有项目id
}
},
computed
:
{
searchText
()
{
//搜索框的文本
return
this
.
condition
.
name
;
},
/*
搜索后对应的总条目。搜索内容为空的话就是全部记录条数;搜索内容不为空的话就是匹配的记录条数
*/
total
()
{
return
this
.
environments
.
filter
(
env
=>
!
this
.
searchText
||
env
.
name
.
toLowerCase
().
includes
(
this
.
searchText
.
toLowerCase
())).
length
;
created
()
{
this
.
isTesterPermission
=
checkoutTestManagerOrTestUser
();
},
activated
()
{
this
.
list
();
},
watch
:
{
//当创建及复制环境所选择的项目变化时,改变当前环境对应的projectId
currentProjectId
()
{
...
...
@@ -203,22 +202,26 @@
}
},
list
()
{
this
.
environments
=
[];
let
url
=
"
/project/listAll
"
;
this
.
result
=
this
.
$get
(
url
,
(
response
)
=>
{
//请求未成功怎么办?
if
(
!
this
.
projectList
||
this
.
projectList
.
length
===
0
)
{
//没有项目数据的话请求项目数据
this
.
$get
(
"
/project/listAll
"
,
(
response
)
=>
{
this
.
projectList
=
response
.
data
;
//获取当前工作空间所拥有的项目,
this
.
projectList
.
forEach
(
project
=>
{
this
.
idNameMap
.
set
(
project
.
id
,
project
.
name
);
this
.
projectIds
.
push
(
project
.
id
);
});
//获取每个项目所对应的环境列表
this
.
projectList
.
map
((
project
)
=>
{
this
.
$get
(
'
/api/environment/list/
'
+
project
.
id
,
response
=>
{
let
envData
=
response
.
data
;
envData
.
forEach
(
env
=>
{
this
.
environments
.
push
(
env
);
})
})
this
.
getEnvironments
();
})
}
else
{
this
.
getEnvironments
()
}
},
getEnvironments
(){
this
.
environments
=
[];
this
.
condition
.
projectIds
=
this
.
projectIds
;
let
url
=
'
/api/environment/list/
'
+
this
.
currentPage
+
'
/
'
+
this
.
pageSize
;
this
.
result
=
this
.
$post
(
url
,
this
.
condition
,
response
=>
{
this
.
environments
=
response
.
data
.
listObject
;
this
.
total
=
response
.
data
.
itemCount
;
})
},
createEnv
()
{
...
...
@@ -227,7 +230,8 @@
this
.
dialogVisible
=
true
;
this
.
currentEnvironment
=
new
Environment
();
},
search
(
searchText
)
{
search
()
{
this
.
list
()
},
editEnv
(
environment
)
{
this
.
dialogTitle
=
this
.
$t
(
'
api_test.environment.config_environment
'
);
...
...
@@ -334,13 +338,7 @@
}
},
created
()
{
this
.
isTesterPermission
=
checkoutTestManagerOrTestUser
();
},
activated
()
{
this
.
list
();
},
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录