Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
0b072959
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,发现更多精彩内容 >>
提交
0b072959
编写于
5月 06, 2020
作者:
C
Captain.B
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
资源池加密
上级
23d759ba
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
44 addition
and
136 deletion
+44
-136
backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReourcePoolMapper.java
...metersphere/base/mapper/ext/ExtTestReourcePoolMapper.java
+0
-13
backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReourcePoolMapper.xml
.../metersphere/base/mapper/ext/ExtTestReourcePoolMapper.xml
+0
-33
backend/src/main/java/io/metersphere/commons/utils/MybatisInterceptorConfig.java
...o/metersphere/commons/utils/MybatisInterceptorConfig.java
+14
-85
backend/src/main/java/io/metersphere/config/MybatisConfig.java
...nd/src/main/java/io/metersphere/config/MybatisConfig.java
+5
-1
backend/src/main/java/io/metersphere/service/TestResourcePoolService.java
.../java/io/metersphere/service/TestResourcePoolService.java
+25
-4
未找到文件。
backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReourcePoolMapper.java
已删除
100644 → 0
浏览文件 @
23d759ba
package
io.metersphere.base.mapper.ext
;
import
io.metersphere.controller.request.resourcepool.QueryResourcePoolRequest
;
import
io.metersphere.dto.TestResourcePoolDTO
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
ExtTestReourcePoolMapper
{
List
<
TestResourcePoolDTO
>
listResourcePools
(
@Param
(
"request"
)
QueryResourcePoolRequest
request
);
// List<TestResource> listResourcesByPoolId(@Param("poolId") String poolId);
}
backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReourcePoolMapper.xml
已删除
100644 → 0
浏览文件 @
23d759ba
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"io.metersphere.base.mapper.ext.ExtTestReourcePoolMapper"
>
<resultMap
id=
"TestReourcePoolResultMap"
type=
"io.metersphere.dto.TestResourcePoolDTO"
>
<id
column=
"id"
jdbcType=
"VARCHAR"
property=
"id"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"type"
jdbcType=
"VARCHAR"
property=
"type"
/>
<result
column=
"description"
jdbcType=
"VARCHAR"
property=
"description"
/>
<result
column=
"status"
jdbcType=
"VARCHAR"
property=
"status"
/>
<result
column=
"create_time"
jdbcType=
"BIGINT"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"BIGINT"
property=
"updateTime"
/>
<collection
property=
"resources"
column=
"id"
ofType=
"io.metersphere.base.domain.TestResource"
select=
"io.metersphere.base.mapper.ext.ExtTestReourcePoolMapper.listResourcesByPoolId"
>
</collection>
</resultMap>
<select
id=
"listResourcePools"
resultMap=
"TestReourcePoolResultMap"
>
SELECT * FROM test_resource_pool
<where>
<if
test=
"request.name != null"
>
and test_resource_pool.name like CONCAT('%', #{request.name},'%')
</if>
</where>
</select>
<select
id=
"listResourcesByPoolId"
resultType=
"io.metersphere.base.domain.TestResource"
>
SELECT * FROM test_resource WHERE test_resource_pool_id = #{id}
</select>
</mapper>
\ No newline at end of file
backend/src/main/java/io/metersphere/commons/utils/MybatisInterceptorConfig.java
浏览文件 @
0b072959
package
io.metersphere.commons.utils
;
import
lombok.Getter
;
import
lombok.Setter
;
@Getter
@Setter
public
class
MybatisInterceptorConfig
{
private
String
modelName
;
private
String
attrName
;
...
...
@@ -9,7 +14,6 @@ public class MybatisInterceptorConfig {
private
String
undoClass
;
private
String
undoMethod
;
public
MybatisInterceptorConfig
()
{
}
...
...
@@ -17,100 +21,25 @@ public class MybatisInterceptorConfig {
* 用时需谨慎!!!!!
* 主要配置多个的时候,参数少一点
*
* @param model
Name
* @param model
Class
* @param attrName
*/
public
MybatisInterceptorConfig
(
String
modelName
,
String
attrName
)
{
this
.
modelName
=
model
Name
;
public
MybatisInterceptorConfig
(
Class
<?>
modelClass
,
String
attrName
)
{
this
.
modelName
=
model
Class
.
getName
()
;
this
.
attrName
=
attrName
;
this
.
interceptorClass
=
"io.metersphere.commons.utils.EncryptUtils"
;
this
.
interceptorClass
=
EncryptUtils
.
class
.
getName
()
;
this
.
interceptorMethod
=
"aesEncrypt"
;
this
.
undoClass
=
"io.metersphere.commons.utils.EncryptUtils"
;
this
.
undoClass
=
EncryptUtils
.
class
.
getName
()
;
this
.
undoMethod
=
"aesDecrypt"
;
}
public
MybatisInterceptorConfig
(
String
modelName
,
String
attrName
,
String
attrNameForList
)
{
this
.
modelName
=
modelName
;
this
.
attrName
=
attrName
;
this
.
attrNameForList
=
attrNameForList
;
this
.
interceptorClass
=
"io.metersphere.commons.utils.EncryptUtils"
;
this
.
interceptorMethod
=
"aesEncrypt"
;
this
.
undoClass
=
"io.metersphere.commons.utils.EncryptUtils"
;
this
.
undoMethod
=
"aesDecrypt"
;
}
public
MybatisInterceptorConfig
(
String
modelName
,
String
attrName
,
String
interceptorClass
,
String
interceptorMethod
,
String
undoMethod
)
{
this
.
modelName
=
modelName
;
this
.
attrName
=
attrName
;
this
.
interceptorClass
=
interceptorClass
;
this
.
interceptorMethod
=
interceptorMethod
;
this
.
undoClass
=
interceptorClass
;
this
.
undoMethod
=
undoMethod
;
}
public
MybatisInterceptorConfig
(
String
modelName
,
String
attrName
,
String
attrNameForList
,
String
interceptorClass
,
String
interceptorMethod
,
String
undoMethod
)
{
this
.
modelName
=
modelName
;
this
.
attrName
=
attrName
;
this
.
attrNameForList
=
attrNameForList
;
this
.
interceptorClass
=
interceptorClass
;
this
.
interceptorMethod
=
interceptorMethod
;
this
.
undoClass
=
interceptorClass
;
this
.
undoMethod
=
undoMethod
;
}
public
String
getModelName
()
{
return
modelName
;
}
public
void
setModelName
(
String
modelName
)
{
this
.
modelName
=
modelName
;
}
public
String
getAttrName
()
{
return
attrName
;
}
public
void
setAttrName
(
String
attrName
)
{
public
MybatisInterceptorConfig
(
Class
<?>
modelClass
,
String
attrName
,
Class
<?>
interceptorClass
,
String
interceptorMethod
,
String
undoMethod
)
{
this
.
modelName
=
modelClass
.
getName
();
this
.
attrName
=
attrName
;
}
public
String
getAttrNameForList
()
{
return
attrNameForList
;
}
public
void
setAttrNameForList
(
String
attrNameForList
)
{
this
.
attrNameForList
=
attrNameForList
;
}
public
String
getInterceptorMethod
()
{
return
interceptorMethod
;
}
public
void
setInterceptorMethod
(
String
interceptorMethod
)
{
this
.
interceptorClass
=
interceptorClass
.
getName
();
this
.
interceptorMethod
=
interceptorMethod
;
}
public
String
getUndoMethod
()
{
return
undoMethod
;
}
public
void
setUndoMethod
(
String
undoMethod
)
{
this
.
undoClass
=
interceptorClass
.
getName
();
this
.
undoMethod
=
undoMethod
;
}
public
String
getInterceptorClass
()
{
return
interceptorClass
;
}
public
void
setInterceptorClass
(
String
interceptorClass
)
{
this
.
interceptorClass
=
interceptorClass
;
}
public
String
getUndoClass
()
{
return
undoClass
;
}
public
void
setUndoClass
(
String
undoClass
)
{
this
.
undoClass
=
undoClass
;
}
}
backend/src/main/java/io/metersphere/config/MybatisConfig.java
浏览文件 @
0b072959
package
io.metersphere.config
;
import
com.github.pagehelper.PageInterceptor
;
import
io.metersphere.base.domain.FileContent
;
import
io.metersphere.base.domain.TestResource
;
import
io.metersphere.commons.utils.CompressUtils
;
import
io.metersphere.commons.utils.MybatisInterceptorConfig
;
import
io.metersphere.interceptor.MybatisInterceptor
;
import
org.mybatis.spring.annotation.MapperScan
;
...
...
@@ -37,7 +40,8 @@ public class MybatisConfig {
public
MybatisInterceptor
dbInterceptor
()
{
MybatisInterceptor
interceptor
=
new
MybatisInterceptor
();
List
<
MybatisInterceptorConfig
>
configList
=
new
ArrayList
<>();
configList
.
add
(
new
MybatisInterceptorConfig
(
"io.metersphere.base.domain.FileContent"
,
"file"
,
"io.metersphere.commons.utils.CompressUtils"
,
"zip"
,
"unzip"
));
configList
.
add
(
new
MybatisInterceptorConfig
(
FileContent
.
class
,
"file"
,
CompressUtils
.
class
,
"zip"
,
"unzip"
));
configList
.
add
(
new
MybatisInterceptorConfig
(
TestResource
.
class
,
"configuration"
));
interceptor
.
setInterceptorConfigList
(
configList
);
return
interceptor
;
}
...
...
backend/src/main/java/io/metersphere/service/TestResourcePoolService.java
浏览文件 @
0b072959
...
...
@@ -7,15 +7,16 @@ import io.metersphere.base.domain.TestResourcePool;
import
io.metersphere.base.domain.TestResourcePoolExample
;
import
io.metersphere.base.mapper.TestResourceMapper
;
import
io.metersphere.base.mapper.TestResourcePoolMapper
;
import
io.metersphere.base.mapper.ext.ExtTestReourcePoolMapper
;
import
io.metersphere.commons.constants.ResourcePoolTypeEnum
;
import
io.metersphere.commons.constants.ResourceStatusEnum
;
import
io.metersphere.commons.exception.MSException
;
import
io.metersphere.commons.utils.LogUtil
;
import
io.metersphere.controller.request.resourcepool.QueryResourcePoolRequest
;
import
io.metersphere.dto.NodeDTO
;
import
io.metersphere.dto.TestResourcePoolDTO
;
import
io.metersphere.engine.kubernetes.provider.KubernetesProvider
;
import
io.metersphere.i18n.Translator
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -25,6 +26,8 @@ import org.springframework.transaction.annotation.Transactional;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
...
...
@@ -46,8 +49,6 @@ public class TestResourcePoolService {
@Resource
private
TestResourceMapper
testResourceMapper
;
@Resource
private
ExtTestReourcePoolMapper
extTestReourcePoolMapper
;
@Resource
private
RestTemplate
restTemplate
;
public
TestResourcePoolDTO
addTestResourcePool
(
TestResourcePoolDTO
testResourcePool
)
{
...
...
@@ -72,7 +73,27 @@ public class TestResourcePoolService {
}
public
List
<
TestResourcePoolDTO
>
listResourcePools
(
QueryResourcePoolRequest
request
)
{
return
extTestReourcePoolMapper
.
listResourcePools
(
request
);
TestResourcePoolExample
example
=
new
TestResourcePoolExample
();
TestResourcePoolExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
StringUtils
.
isNotBlank
(
request
.
getName
()))
{
criteria
.
andNameLike
(
StringUtils
.
wrapIfMissing
(
request
.
getName
(),
"%"
));
}
List
<
TestResourcePool
>
testResourcePools
=
testResourcePoolMapper
.
selectByExample
(
example
);
List
<
TestResourcePoolDTO
>
testResourcePoolDTOS
=
new
ArrayList
<>();
testResourcePools
.
forEach
(
pool
->
{
TestResourceExample
example2
=
new
TestResourceExample
();
example2
.
createCriteria
().
andTestResourcePoolIdEqualTo
(
pool
.
getId
());
List
<
TestResource
>
testResources
=
testResourceMapper
.
selectByExampleWithBLOBs
(
example2
);
TestResourcePoolDTO
testResourcePoolDTO
=
new
TestResourcePoolDTO
();
try
{
BeanUtils
.
copyProperties
(
testResourcePoolDTO
,
pool
);
testResourcePoolDTO
.
setResources
(
testResources
);
testResourcePoolDTOS
.
add
(
testResourcePoolDTO
);
}
catch
(
IllegalAccessException
|
InvocationTargetException
e
)
{
LogUtil
.
error
(
e
);
}
});
return
testResourcePoolDTOS
;
}
private
void
validateTestResourcePool
(
TestResourcePoolDTO
testResourcePool
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录