Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
7ec03015
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,发现更多精彩内容 >>
提交
7ec03015
编写于
2月 21, 2020
作者:
S
shiziyuan9527
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
组织成员管理
上级
62873e65
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
67 addition
and
0 deletion
+67
-0
backend/src/main/java/io/metersphere/commons/constants/RoleConstants.java
.../java/io/metersphere/commons/constants/RoleConstants.java
+2
-0
backend/src/main/java/io/metersphere/controller/UserController.java
...c/main/java/io/metersphere/controller/UserController.java
+17
-0
backend/src/main/java/io/metersphere/controller/request/organization/AddOrgMemberRequest.java
.../controller/request/organization/AddOrgMemberRequest.java
+25
-0
backend/src/main/java/io/metersphere/service/UserService.java
...end/src/main/java/io/metersphere/service/UserService.java
+23
-0
未找到文件。
backend/src/main/java/io/metersphere/commons/constants/RoleConstants.java
浏览文件 @
7ec03015
...
@@ -3,6 +3,8 @@ package io.metersphere.commons.constants;
...
@@ -3,6 +3,8 @@ package io.metersphere.commons.constants;
public
class
RoleConstants
{
public
class
RoleConstants
{
public
final
static
String
ADMIN
=
"admin"
;
public
final
static
String
ADMIN
=
"admin"
;
public
final
static
String
ORG_ADMIN
=
"org_admin"
;
public
final
static
String
ORG_ADMIN
=
"org_admin"
;
// 组织内其它角色
public
final
static
String
ORG_OTHER
=
"org_other"
;
public
final
static
String
TEST_VIEWER
=
"test_viewer"
;
public
final
static
String
TEST_VIEWER
=
"test_viewer"
;
public
final
static
String
TEST_MANAGER
=
"test_manager"
;
public
final
static
String
TEST_MANAGER
=
"test_manager"
;
public
final
static
String
TEST_USER
=
"test_user"
;
public
final
static
String
TEST_USER
=
"test_user"
;
...
...
backend/src/main/java/io/metersphere/controller/UserController.java
浏览文件 @
7ec03015
...
@@ -8,6 +8,7 @@ import io.metersphere.commons.utils.PageUtils;
...
@@ -8,6 +8,7 @@ import io.metersphere.commons.utils.PageUtils;
import
io.metersphere.commons.utils.Pager
;
import
io.metersphere.commons.utils.Pager
;
import
io.metersphere.controller.request.member.AddMemberRequest
;
import
io.metersphere.controller.request.member.AddMemberRequest
;
import
io.metersphere.controller.request.member.QueryMemberRequest
;
import
io.metersphere.controller.request.member.QueryMemberRequest
;
import
io.metersphere.controller.request.organization.AddOrgMemberRequest
;
import
io.metersphere.dto.UserDTO
;
import
io.metersphere.dto.UserDTO
;
import
io.metersphere.dto.UserRoleDTO
;
import
io.metersphere.dto.UserRoleDTO
;
import
io.metersphere.service.UserService
;
import
io.metersphere.service.UserService
;
...
@@ -98,4 +99,20 @@ public class UserController {
...
@@ -98,4 +99,20 @@ public class UserController {
userService
.
deleteMember
(
workspaceId
,
userId
);
userService
.
deleteMember
(
workspaceId
,
userId
);
}
}
/**
* 添加组织成员
*/
@PostMapping
(
"/orgmember/add"
)
public
void
addOrganizationMember
(
@RequestBody
AddOrgMemberRequest
request
)
{
userService
.
addOrganizationMember
(
request
);
}
/**
* 删除组织成员
*/
@GetMapping
(
"/orgmember/delete/{organizationId}/{userId}"
)
public
void
delOrganizationMember
(
@PathVariable
String
organizationId
,
@PathVariable
String
userId
)
{
userService
.
delOrganizationMember
(
organizationId
,
userId
);
}
}
}
backend/src/main/java/io/metersphere/controller/request/organization/AddOrgMemberRequest.java
0 → 100644
浏览文件 @
7ec03015
package
io.metersphere.controller.request.organization
;
import
java.util.List
;
public
class
AddOrgMemberRequest
{
private
String
organizationId
;
private
List
<
String
>
userIds
;
public
String
getOrganizationId
()
{
return
organizationId
;
}
public
void
setOrganizationId
(
String
organizationId
)
{
this
.
organizationId
=
organizationId
;
}
public
List
<
String
>
getUserIds
()
{
return
userIds
;
}
public
void
setUserIds
(
List
<
String
>
userIds
)
{
this
.
userIds
=
userIds
;
}
}
backend/src/main/java/io/metersphere/service/UserService.java
浏览文件 @
7ec03015
...
@@ -10,6 +10,7 @@ import io.metersphere.commons.constants.RoleConstants;
...
@@ -10,6 +10,7 @@ import io.metersphere.commons.constants.RoleConstants;
import
io.metersphere.commons.exception.MSException
;
import
io.metersphere.commons.exception.MSException
;
import
io.metersphere.controller.request.member.AddMemberRequest
;
import
io.metersphere.controller.request.member.AddMemberRequest
;
import
io.metersphere.controller.request.member.QueryMemberRequest
;
import
io.metersphere.controller.request.member.QueryMemberRequest
;
import
io.metersphere.controller.request.organization.AddOrgMemberRequest
;
import
io.metersphere.dto.UserDTO
;
import
io.metersphere.dto.UserDTO
;
import
io.metersphere.dto.UserRoleDTO
;
import
io.metersphere.dto.UserRoleDTO
;
import
io.metersphere.dto.UserRoleHelpDTO
;
import
io.metersphere.dto.UserRoleHelpDTO
;
...
@@ -258,4 +259,26 @@ public class UserService {
...
@@ -258,4 +259,26 @@ public class UserService {
.
andUserIdEqualTo
(
userId
).
andSourceIdEqualTo
(
workspaceId
);
.
andUserIdEqualTo
(
userId
).
andSourceIdEqualTo
(
workspaceId
);
userRoleMapper
.
deleteByExample
(
example
);
userRoleMapper
.
deleteByExample
(
example
);
}
}
public
void
addOrganizationMember
(
AddOrgMemberRequest
request
)
{
if
(!
CollectionUtils
.
isEmpty
(
request
.
getUserIds
()))
{
for
(
String
userId
:
request
.
getUserIds
())
{
UserRole
userRole
=
new
UserRole
();
userRole
.
setId
(
UUID
.
randomUUID
().
toString
());
userRole
.
setRoleId
(
RoleConstants
.
ORG_OTHER
);
userRole
.
setSourceId
(
request
.
getOrganizationId
());
userRole
.
setUserId
(
userId
);
userRole
.
setUpdateTime
(
System
.
currentTimeMillis
());
userRole
.
setCreateTime
(
System
.
currentTimeMillis
());
userRoleMapper
.
insertSelective
(
userRole
);
}
}
}
public
void
delOrganizationMember
(
String
organizationId
,
String
userId
)
{
UserRoleExample
userRoleExample
=
new
UserRoleExample
();
userRoleExample
.
createCriteria
().
andRoleIdEqualTo
(
RoleConstants
.
ORG_OTHER
)
.
andUserIdEqualTo
(
userId
).
andSourceIdEqualTo
(
organizationId
);
userRoleMapper
.
deleteByExample
(
userRoleExample
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录