fix(系统设置): 用户编辑问题
This commit is contained in:
parent
0e1ffbf873
commit
f6c566f77a
|
@ -197,7 +197,7 @@ public class GroupService {
|
|||
UserGroupExample userGroupExample = new UserGroupExample();
|
||||
userGroupExample.createCriteria().andUserIdEqualTo(userId);
|
||||
List<UserGroup> userGroups = userGroupMapper.selectByExample(userGroupExample);
|
||||
List<String> groupsIds = userGroups.stream().map(UserGroup::getGroupId).collect(Collectors.toList());
|
||||
List<String> groupsIds = userGroups.stream().map(UserGroup::getGroupId).distinct().collect(Collectors.toList());
|
||||
for (int i = 0; i < groupsIds.size(); i++) {
|
||||
String id = groupsIds.get(i);
|
||||
Group group = groupMapper.selectByPrimaryKey(id);
|
||||
|
|
|
@ -208,7 +208,7 @@ public class OrganizationService {
|
|||
|
||||
public OrganizationResource listResource(String groupId, String type) {
|
||||
Group group = groupMapper.selectByPrimaryKey(groupId);
|
||||
final String orgId = group.getScopeId();
|
||||
String orgId = group.getScopeId();
|
||||
OrganizationResource resource = new OrganizationResource();
|
||||
if (!StringUtils.equals("global", orgId)) {
|
||||
Organization organization = organizationMapper.selectByPrimaryKey(orgId);
|
||||
|
|
|
@ -402,7 +402,13 @@ public class UserService {
|
|||
UserRoleExample userRoleExample = new UserRoleExample();
|
||||
userRoleExample.createCriteria().andUserIdEqualTo(userId);
|
||||
List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
|
||||
List<String> list = userRoles.stream().map(UserRole::getSourceId).collect(Collectors.toList());
|
||||
|
||||
UserGroupExample userGroupExample = new UserGroupExample();
|
||||
userGroupExample.createCriteria().andUserIdEqualTo(userId);
|
||||
List<UserGroup> userGroups = userGroupMapper.selectByExample(userGroupExample);
|
||||
List<String> list = userGroups.stream().map(UserGroup::getSourceId).collect(Collectors.toList());
|
||||
|
||||
// List<String> list = userRoles.stream().map(UserRole::getSourceId).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
if (list.contains(user.getLastWorkspaceId()) || list.contains(user.getLastOrganizationId())) {
|
||||
user.setLastOrganizationId("");
|
||||
|
@ -411,10 +417,13 @@ public class UserService {
|
|||
}
|
||||
}
|
||||
|
||||
userRoleMapper.deleteByExample(userRoleExample);
|
||||
List<Map<String, Object>> roles = user.getRoles();
|
||||
if (!roles.isEmpty()) {
|
||||
insertUserRole(roles, user.getId());
|
||||
userGroupMapper.deleteByExample(userGroupExample);
|
||||
// userRoleMapper.deleteByExample(userRoleExample);
|
||||
// List<Map<String, Object>> roles = user.getRoles();
|
||||
List<Map<String, Object>> groups = user.getGroups();
|
||||
if (!groups.isEmpty()) {
|
||||
insertUserGroup(groups, user.getId());
|
||||
// insertUserRole(roles, user.getId());
|
||||
}
|
||||
|
||||
UserExample example = new UserExample();
|
||||
|
|
|
@ -45,19 +45,19 @@ CREATE TABLE IF NOT EXISTS `user_group_permission`
|
|||
INSERT INTO `group` (id, name, description, `system`, type, create_time, update_time, creator, scope_id)
|
||||
VALUES ('admin', '系统管理员', '默认用户组', 1, 'SYSTEM', 1621224000000, 1621224000000, 'admin', 'global');
|
||||
INSERT INTO `group` (id, name, description, `system`, type, create_time, update_time, creator, scope_id)
|
||||
VALUES ('org_admin', '组织管理员', '组织管理员', 1, 'ORGANIZATION', 1620674220001, 1620674220000, 'system', 'global');
|
||||
VALUES ('org_admin', '组织管理员', '组织管理员', 1, 'ORGANIZATION', 1620674220001, 1620674220000, 'admin', 'global');
|
||||
INSERT INTO `group` (id, name, description, `system`, type, create_time, update_time, creator, scope_id)
|
||||
VALUES ('org_member', '组织成员', '组织成员', 1, 'ORGANIZATION', 1620674220002, 1620674220000, 'system', 'global');
|
||||
VALUES ('org_member', '组织成员', '组织成员', 1, 'ORGANIZATION', 1620674220002, 1620674220000, 'admin', 'global');
|
||||
INSERT INTO `group` (id, name, description, `system`, type, create_time, update_time, creator, scope_id)
|
||||
VALUES ('project_admin', '项目管理员', '项目管理员', 1, 'PROJECT', 1620674220004, 1620674220000, 'system', 'global');
|
||||
VALUES ('project_admin', '项目管理员', '项目管理员', 1, 'PROJECT', 1620674220004, 1620674220000, 'admin', 'global');
|
||||
INSERT INTO `group` (id, name, description, `system`, type, create_time, update_time, creator, scope_id)
|
||||
VALUES ('project_member', '项目成员', '项目成员', 1, 'PROJECT', 1620674220005, 1620674220000, 'system', 'global');
|
||||
VALUES ('project_member', '项目成员', '项目成员', 1, 'PROJECT', 1620674220005, 1620674220000, 'admin', 'global');
|
||||
INSERT INTO `group` (id, name, description, `system`, type, create_time, update_time, creator, scope_id)
|
||||
VALUES ('read_only', '只读用户', '只读用户', 1, 'PROJECT', 1620674220006, 1620674220000, 'system', 'global');
|
||||
VALUES ('read_only', '只读用户', '只读用户', 1, 'PROJECT', 1620674220006, 1620674220000, 'admin', 'global');
|
||||
INSERT INTO `group` (id, name, description, `system`, type, create_time, update_time, creator, scope_id)
|
||||
VALUES ('ws_admin', '工作空间管理员', '工作空间管理员', 1, 'WORKSPACE', 1620674220007, 1620674220000, 'system', 'global');
|
||||
VALUES ('ws_admin', '工作空间管理员', '工作空间管理员', 1, 'WORKSPACE', 1620674220007, 1620674220000, 'admin', 'global');
|
||||
INSERT INTO `group` (id, name, description, `system`, type, create_time, update_time, creator, scope_id)
|
||||
VALUES ('ws_member', '工作空间成员', '工作空间成员', 1, 'WORKSPACE', 1620674220008, 1620674220000, 'system', 'global');
|
||||
VALUES ('ws_member', '工作空间成员', '工作空间成员', 1, 'WORKSPACE', 1620674220008, 1620674220000, 'admin', 'global');
|
||||
|
||||
|
||||
-- 系统管理员 组织管理员 组织成员
|
||||
|
@ -94,8 +94,10 @@ WHERE role_id = 'test_user';
|
|||
|
||||
-- 只读用户
|
||||
INSERT INTO user_group(id, user_id, group_id, source_id, create_time, update_time)
|
||||
SELECT UUID(), user_id, 'read_only', source_id, create_time, update_time
|
||||
FROM user_role
|
||||
SELECT UUID(), user_id, 'read_only', project.id, w.create_time, w.update_time
|
||||
FROM project
|
||||
JOIN workspace w ON project.workspace_id = w.id
|
||||
JOIN user_role ON source_id = workspace_id
|
||||
WHERE role_id = 'test_viewer';
|
||||
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ export default {
|
|||
this.title = title ? title : this.title;
|
||||
|
||||
if (type === 'Edit') {
|
||||
this.$get('/user/group/all/' + encodeURIComponent(row.id), response => {
|
||||
this.result = this.$get('/user/group/all/' + encodeURIComponent(row.id), response => {
|
||||
let data = response.data;
|
||||
this.$set(this.form, "groups", data);
|
||||
});
|
||||
|
@ -262,7 +262,8 @@ export default {
|
|||
createUser(createUserForm) {
|
||||
this.$refs[createUserForm].validate(valid => {
|
||||
if (valid) {
|
||||
this.result = this.$post('/user/special/add', this.form, () => {
|
||||
let url = this.type === 'Add' ? '/user/special/add' : '/user/special/update';
|
||||
this.result = this.$post(url, this.form, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.$emit("refresh");
|
||||
this.createVisible = false;
|
||||
|
|
Loading…
Reference in New Issue