Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
b09ffedb
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,发现更多精彩内容 >>
提交
b09ffedb
编写于
2月 11, 2020
作者:
C
Captain.B
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
workspace add
上级
f51ddf20
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
126 addition
and
11 deletion
+126
-11
backend/src/main/java/io/metersphere/controller/WorkspaceController.java
...n/java/io/metersphere/controller/WorkspaceController.java
+22
-0
backend/src/main/java/io/metersphere/controller/handler/ResultResponseBodyAdvice.java
...ersphere/controller/handler/ResultResponseBodyAdvice.java
+42
-0
backend/src/main/java/io/metersphere/service/UserService.java
...end/src/main/java/io/metersphere/service/UserService.java
+2
-0
backend/src/main/java/io/metersphere/service/WorkspaceService.java
...rc/main/java/io/metersphere/service/WorkspaceService.java
+34
-0
frontend/src/performance/components/settings/Workspace.vue
frontend/src/performance/components/settings/Workspace.vue
+26
-11
未找到文件。
backend/src/main/java/io/metersphere/controller/WorkspaceController.java
0 → 100644
浏览文件 @
b09ffedb
package
io.metersphere.controller
;
import
io.metersphere.base.domain.Workspace
;
import
io.metersphere.service.WorkspaceService
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
@RequestMapping
(
"workspace"
)
@RestController
public
class
WorkspaceController
{
@Resource
private
WorkspaceService
workspaceService
;
@PostMapping
(
"add"
)
public
Workspace
insertUser
(
@RequestBody
Workspace
workspace
)
{
return
workspaceService
.
add
(
workspace
);
}
}
backend/src/main/java/io/metersphere/controller/handler/ResultResponseBodyAdvice.java
0 → 100644
浏览文件 @
b09ffedb
package
io.metersphere.controller.handler
;
import
com.alibaba.fastjson.JSON
;
import
io.metersphere.controller.ResultHolder
;
import
org.springframework.core.MethodParameter
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
;
import
org.springframework.http.server.ServerHttpRequest
;
import
org.springframework.http.server.ServerHttpResponse
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice
;
/**
* 统一处理返回结果集
*/
@RestControllerAdvice
(
value
=
{
"io.metersphere.controller"
})
public
class
ResultResponseBodyAdvice
implements
ResponseBodyAdvice
<
Object
>
{
@Override
public
boolean
supports
(
MethodParameter
methodParameter
,
Class
<?
extends
HttpMessageConverter
<?>>
converterType
)
{
return
MappingJackson2HttpMessageConverter
.
class
.
isAssignableFrom
(
converterType
)
||
StringHttpMessageConverter
.
class
.
isAssignableFrom
(
converterType
);
}
@Override
public
Object
beforeBodyWrite
(
Object
o
,
MethodParameter
methodParameter
,
MediaType
mediaType
,
Class
<?
extends
HttpMessageConverter
<?>>
converterType
,
ServerHttpRequest
serverHttpRequest
,
ServerHttpResponse
serverHttpResponse
)
{
// 处理空值
if
(
o
==
null
&&
StringHttpMessageConverter
.
class
.
isAssignableFrom
(
converterType
))
{
return
null
;
}
if
(!(
o
instanceof
ResultHolder
))
{
if
(
o
instanceof
String
)
{
return
JSON
.
toJSONString
(
ResultHolder
.
success
(
o
));
}
return
ResultHolder
.
success
(
o
);
}
return
o
;
}
}
backend/src/main/java/io/metersphere/service/UserService.java
浏览文件 @
b09ffedb
...
...
@@ -9,6 +9,7 @@ import io.metersphere.dto.UserDTO;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.Resource
;
...
...
@@ -16,6 +17,7 @@ import java.util.List;
import
java.util.stream.Collectors
;
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
UserService
{
@Resource
...
...
backend/src/main/java/io/metersphere/service/WorkspaceService.java
0 → 100644
浏览文件 @
b09ffedb
package
io.metersphere.service
;
import
io.metersphere.base.domain.Workspace
;
import
io.metersphere.base.mapper.WorkspaceMapper
;
import
io.metersphere.commons.MSException
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.UUID
;
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
WorkspaceService
{
@Resource
private
WorkspaceMapper
workspaceMapper
;
public
Workspace
add
(
Workspace
workspace
)
{
if
(
StringUtils
.
isBlank
(
workspace
.
getName
()))
{
MSException
.
throwException
(
"Workspace name cannot be null."
);
}
// TODO 组织ID 暂无
if
(
StringUtils
.
isBlank
(
workspace
.
getOrganizationId
()))
{
workspace
.
setOrganizationId
(
"root"
);
}
long
createTime
=
System
.
currentTimeMillis
();
workspace
.
setCreateTime
(
createTime
);
workspace
.
setUpdateTime
(
createTime
);
// 首次 update time
workspace
.
setId
(
UUID
.
randomUUID
().
toString
());
// 设置ID
workspaceMapper
.
insertSelective
(
workspace
);
return
workspace
;
}
}
frontend/src/performance/components/settings/Workspace.vue
浏览文件 @
b09ffedb
...
...
@@ -25,17 +25,17 @@
</el-card>
<ms-create-box
:tips=
"btnTips"
:exec=
"create"
/>
<el-dialog
title=
"创建工作空间"
:visible.sync=
"createVisible"
width=
"30%"
>
<el-form
:model=
"form"
label-position=
"left"
label-width=
"100px"
size=
"small"
>
<el-form-item
label=
"名称"
>
<el-form
:model=
"form"
:rules=
"rules"
ref=
"form"
label-position=
"left"
label-width=
"100px"
size=
"small"
>
<el-form-item
label=
"名称"
prop=
"name"
>
<el-input
v-model=
"form.name"
autocomplete=
"off"
/>
</el-form-item>
<el-form-item
label=
"
启用
"
>
<el-
switch
v-model=
"form.enable"
/
>
<el-form-item
label=
"
描述
"
>
<el-
input
type=
"textarea"
v-model=
"form.description"
></el-input
>
</el-form-item>
</el-form>
<span
slot=
"footer"
class=
"dialog-footer"
>
<el-button
type=
"primary"
@
click=
"createVisible = false
"
size=
"medium"
>
创建
</el-button>
</span>
<el-button
type=
"primary"
@
click=
"submit('form')
"
size=
"medium"
>
创建
</el-button>
</span>
</el-dialog>
</div>
</template>
...
...
@@ -49,8 +49,17 @@
methods
:
{
create
()
{
this
.
createVisible
=
true
;
this
.
$get
(
"
/test/user
"
,
function
(
response
)
{
window
.
console
.
log
(
response
);
},
submit
(
formName
)
{
this
.
$refs
[
formName
].
validate
((
valid
)
=>
{
if
(
valid
)
{
this
.
createVisible
=
false
;
this
.
$post
(
"
/workspace/add
"
,
this
.
form
,
()
=>
{
this
.
$message
({
message
:
'
保存成功
'
,
type
:
'
success
'
});
})
}
else
{
return
false
;
}
});
},
edit
(
row
)
{
...
...
@@ -78,9 +87,15 @@
enable
:
"
是
"
}],
form
:
{
name
:
""
,
enable
:
false
}
// name: "",
// description: ""
},
rules
:
{
name
:
[
{
required
:
true
,
message
:
'
请输入工作空间名称
'
,
trigger
:
'
blur
'
},
{
min
:
2
,
max
:
50
,
message
:
'
长度在 2 到 50 个字符
'
,
trigger
:
'
blur
'
}
]
},
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录