组织成员管理
This commit is contained in:
parent
62873e656e
commit
7ec03015dd
|
@ -3,6 +3,8 @@ package io.metersphere.commons.constants;
|
|||
public class RoleConstants {
|
||||
public final static String ADMIN = "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_MANAGER = "test_manager";
|
||||
public final static String TEST_USER = "test_user";
|
||||
|
|
|
@ -8,6 +8,7 @@ import io.metersphere.commons.utils.PageUtils;
|
|||
import io.metersphere.commons.utils.Pager;
|
||||
import io.metersphere.controller.request.member.AddMemberRequest;
|
||||
import io.metersphere.controller.request.member.QueryMemberRequest;
|
||||
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
|
||||
import io.metersphere.dto.UserDTO;
|
||||
import io.metersphere.dto.UserRoleDTO;
|
||||
import io.metersphere.service.UserService;
|
||||
|
@ -98,4 +99,20 @@ public class UserController {
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import io.metersphere.commons.constants.RoleConstants;
|
|||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.controller.request.member.AddMemberRequest;
|
||||
import io.metersphere.controller.request.member.QueryMemberRequest;
|
||||
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
|
||||
import io.metersphere.dto.UserDTO;
|
||||
import io.metersphere.dto.UserRoleDTO;
|
||||
import io.metersphere.dto.UserRoleHelpDTO;
|
||||
|
@ -258,4 +259,26 @@ public class UserService {
|
|||
.andUserIdEqualTo(userId).andSourceIdEqualTo(workspaceId);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue