refactor(系统设置): 删除无用代码
This commit is contained in:
parent
d16cc9b5c0
commit
3bc0459f42
|
@ -105,10 +105,6 @@ public class UserService {
|
|||
return extUserMapper.queryNameByIds(userIds);
|
||||
}
|
||||
|
||||
/* public List<String> queryEmailByIds(List<String> userIds) {
|
||||
return extUserMapper.queryTypeByIds(userIds);
|
||||
}*/
|
||||
|
||||
public UserDTO insert(UserRequest user) {
|
||||
checkUserParam(user);
|
||||
//
|
||||
|
@ -119,10 +115,7 @@ public class UserService {
|
|||
} else {
|
||||
createUser(user);
|
||||
}
|
||||
// List<Map<String, Object>> roles = user.getRoles();
|
||||
// if (!roles.isEmpty()) {
|
||||
// insertUserRole(roles, user.getId());
|
||||
// }
|
||||
|
||||
List<Map<String, Object>> groups = user.getGroups();
|
||||
if (!groups.isEmpty()) {
|
||||
insertUserGroup(groups, user.getId());
|
||||
|
@ -194,9 +187,6 @@ public class UserService {
|
|||
userRole.setSourceId("adminSourceId");
|
||||
userRoleMapper.insertSelective(userRole);
|
||||
} else {
|
||||
// if (!map.keySet().contains("ids")) {
|
||||
// MSException.throwException(role + " no source id");
|
||||
// }
|
||||
List<String> list = (List<String>) map.get("ids");
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
UserRole userRole1 = new UserRole();
|
||||
|
@ -283,9 +273,7 @@ public class UserService {
|
|||
}
|
||||
UserDTO userDTO = new UserDTO();
|
||||
BeanUtils.copyProperties(user, userDTO);
|
||||
// UserRoleDTO userRole = getUserRole(userId);
|
||||
// userDTO.setUserRoles(Optional.ofNullable(userRole.getUserRoles()).orElse(new ArrayList<>()));
|
||||
// userDTO.setRoles(Optional.ofNullable(userRole.getRoles()).orElse(new ArrayList<>()));
|
||||
|
||||
UserGroupPermissionDTO dto = getUserGroupPermission(userId);
|
||||
userDTO.setUserGroups(dto.getUserGroups());
|
||||
userDTO.setGroups(dto.getGroups());
|
||||
|
@ -401,16 +389,11 @@ public class UserService {
|
|||
|
||||
public void updateUserRole(UserRequest user) {
|
||||
String userId = user.getId();
|
||||
UserRoleExample userRoleExample = new UserRoleExample();
|
||||
userRoleExample.createCriteria().andUserIdEqualTo(userId);
|
||||
List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
|
||||
|
||||
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(null);
|
||||
|
@ -420,12 +403,9 @@ public class UserService {
|
|||
}
|
||||
|
||||
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();
|
||||
|
@ -553,10 +533,6 @@ public class UserService {
|
|||
}
|
||||
|
||||
public void deleteMember(String workspaceId, String userId) {
|
||||
// UserRoleExample example = new UserRoleExample();
|
||||
// example.createCriteria().andRoleIdLike("%test%")
|
||||
// .andUserIdEqualTo(userId).andSourceIdEqualTo(workspaceId);
|
||||
|
||||
GroupExample groupExample = new GroupExample();
|
||||
groupExample.createCriteria().andTypeEqualTo(UserGroupType.WORKSPACE);
|
||||
List<Group> groups = groupMapper.selectByExample(groupExample);
|
||||
|
@ -582,25 +558,12 @@ public class UserService {
|
|||
public void addOrganizationMember(AddOrgMemberRequest request) {
|
||||
if (!CollectionUtils.isEmpty(request.getUserIds())) {
|
||||
for (String userId : request.getUserIds()) {
|
||||
// UserRoleExample userRoleExample = new UserRoleExample();
|
||||
// userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getOrganizationId());
|
||||
// List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
|
||||
UserGroupExample userGroupExample = new UserGroupExample();
|
||||
userGroupExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getOrganizationId());
|
||||
List<UserGroup> userGroups = userGroupMapper.selectByExample(userGroupExample);
|
||||
if (userGroups.size() > 0) {
|
||||
MSException.throwException(Translator.get("user_already_exists") + ": " + userId);
|
||||
} else {
|
||||
// for (String roleId : request.getRoleIds()) {
|
||||
// UserRole userRole = new UserRole();
|
||||
// userRole.setId(UUID.randomUUID().toString());
|
||||
// userRole.setRoleId(roleId);
|
||||
// userRole.setSourceId(request.getOrganizationId());
|
||||
// userRole.setUserId(userId);
|
||||
// userRole.setUpdateTime(System.currentTimeMillis());
|
||||
// userRole.setCreateTime(System.currentTimeMillis());
|
||||
// userRoleMapper.insertSelective(userRole);
|
||||
// }
|
||||
for (String groupId : request.getGroupIds()) {
|
||||
UserGroup userGroup = new UserGroup();
|
||||
userGroup.setId(UUID.randomUUID().toString());
|
||||
|
@ -627,9 +590,6 @@ public class UserService {
|
|||
return;
|
||||
}
|
||||
|
||||
// UserRoleExample userRoleExample = new UserRoleExample();
|
||||
// userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdIn(resourceIds);
|
||||
|
||||
UserGroupExample userGroupExample = new UserGroupExample();
|
||||
userGroupExample.createCriteria().andUserIdEqualTo(userId)
|
||||
.andGroupIdIn(groupIds)
|
||||
|
@ -642,7 +602,6 @@ public class UserService {
|
|||
userMapper.updateByPrimaryKeySelective(user);
|
||||
}
|
||||
|
||||
// userRoleMapper.deleteByExample(userRoleExample);
|
||||
userGroupMapper.deleteByExample(userGroupExample);
|
||||
}
|
||||
|
||||
|
@ -762,32 +721,6 @@ public class UserService {
|
|||
if (subject.isAuthenticated()) {
|
||||
UserDTO user = (UserDTO) subject.getSession().getAttribute(ATTR_USER);
|
||||
autoSwitch(user);
|
||||
// 自动选中组织,工作空间
|
||||
// if (StringUtils.isEmpty(user.getLastOrganizationId())) {
|
||||
// List<String> orgIds = user.getGroups()
|
||||
// .stream()
|
||||
// .filter(ug -> StringUtils.equals(ug.getType(), UserGroupType.ORGANIZATION))
|
||||
// .map(Group::getId)
|
||||
// .collect(Collectors.toList());
|
||||
// List<String> testIds = user.getGroups()
|
||||
// .stream()
|
||||
// .filter(ug -> StringUtils.equals(ug.getType(), UserGroupType.WORKSPACE))
|
||||
// .map(Group::getId)
|
||||
// .collect(Collectors.toList());
|
||||
// List<UserGroup> userGroups = user.getUserGroups();
|
||||
// List<UserGroup> org = userGroups.stream().filter(ug -> orgIds.contains(ug.getGroupId()))
|
||||
// .collect(Collectors.toList());
|
||||
// List<UserGroup> test = userGroups.stream().filter(ug -> testIds.contains(ug.getGroupId()))
|
||||
// .collect(Collectors.toList());
|
||||
// if (test.size() > 0) {
|
||||
// String wsId = test.get(0).getSourceId();
|
||||
// switchUserRole("workspace", wsId);
|
||||
// } else if (org.size() > 0) {
|
||||
// String orgId = org.get(0).getSourceId();
|
||||
// switchUserRole("organization", orgId);
|
||||
// }
|
||||
// }
|
||||
// 返回 userDTO
|
||||
return ResultHolder.success(subject.getSession().getAttribute("user"));
|
||||
} else {
|
||||
return ResultHolder.error(Translator.get("login_fail"));
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
<script>
|
||||
import MsCreateBox from "../CreateBox";
|
||||
import {Message} from "element-ui";
|
||||
import {DEFAULT, GROUP_WORKSPACE} from "../../../../common/js/constants";
|
||||
import {GROUP_WORKSPACE} from "../../../../common/js/constants";
|
||||
import MsTablePagination from "../../common/pagination/TablePagination";
|
||||
import MsTableHeader from "../../common/components/MsTableHeader";
|
||||
import MsRolesTag from "../../common/components/MsRolesTag";
|
||||
|
@ -162,7 +162,6 @@ import {
|
|||
getCurrentUser,
|
||||
getCurrentWorkspaceId,
|
||||
listenGoBack,
|
||||
refreshSessionAndCookies,
|
||||
removeGoBackListener
|
||||
} from "../../../../common/js/utils";
|
||||
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
|
||||
|
@ -241,12 +240,6 @@ export default {
|
|||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$get('/workspace/delete/' + workspace.id, () => {
|
||||
let lastWorkspaceId = getCurrentWorkspaceId();
|
||||
let sourceId = workspace.id;
|
||||
if (lastWorkspaceId === sourceId) {
|
||||
let sign = DEFAULT;
|
||||
refreshSessionAndCookies(sign, sourceId);
|
||||
}
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.list();
|
||||
});
|
||||
|
@ -261,36 +254,6 @@ export default {
|
|||
list() {
|
||||
let url = '/workspace/list/' + this.currentPage + '/' + this.pageSize;
|
||||
let lastOrganizationId = getCurrentOrganizationId();
|
||||
// let userRole = this.currentUser.userRoles.filter(r => r.sourceId === lastOrganizationId);
|
||||
// if (userRole.length > 0) {
|
||||
// let isOrg_admin = false;
|
||||
// userRole.forEach(row=>{
|
||||
// if(row.roleId === "org_admin" ){
|
||||
// isOrg_admin = true;
|
||||
// return;
|
||||
// }
|
||||
// });
|
||||
// if (isOrg_admin) {
|
||||
// this.result = this.$post(url, this.condition, response => {
|
||||
// let data = response.data;
|
||||
// this.items = data.listObject;
|
||||
// for (let i = 0; i < this.items.length; i++) {
|
||||
// let param = {
|
||||
// name: '',
|
||||
// workspaceId: this.items[i].id
|
||||
// }
|
||||
// let path = "user/ws/member/list/all";
|
||||
// this.$post(path, param, res => {
|
||||
// let member = res.data;
|
||||
// this.$set(this.items[i], "memberSize", member.length);
|
||||
// })
|
||||
// }
|
||||
// this.total = data.itemCount;
|
||||
// });
|
||||
// } else {
|
||||
// this.items = [];
|
||||
// this.total = 0;
|
||||
// }
|
||||
this.condition.organizationId = lastOrganizationId;
|
||||
this.result = this.$post(url, this.condition, response => {
|
||||
let data = response.data;
|
||||
|
|
|
@ -202,9 +202,7 @@ import MsTableOperatorButton from "../../common/components/MsTableOperatorButton
|
|||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import {
|
||||
getCurrentOrganizationId,
|
||||
getCurrentUser,
|
||||
listenGoBack,
|
||||
refreshSessionAndCookies,
|
||||
removeGoBackListener
|
||||
} from "@/common/js/utils";
|
||||
import {DEFAULT, GROUP_ORGANIZATION, ORGANIZATION} from "@/common/js/constants";
|
||||
|
@ -316,9 +314,6 @@ export default {
|
|||
this.dialogOrgMemberUpdateVisible = true;
|
||||
this.memberForm = Object.assign({}, row);
|
||||
let groupIds = this.memberForm.groups.map(r => r.id);
|
||||
// this.result = this.$get('/role/list/org', response => {
|
||||
// this.$set(this.memberForm, "allroles", response.data);
|
||||
// })
|
||||
this.result = this.$post('/user/group/list', {type: GROUP_ORGANIZATION, resourceId: this.orgId}, response => {
|
||||
this.$set(this.memberForm, "allgroups", response.data);
|
||||
});
|
||||
|
@ -381,11 +376,6 @@ export default {
|
|||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.result = this.$get(this.deletePath + organization.id, () => {
|
||||
let lastOrganizationId = getCurrentOrganizationId();
|
||||
let sourceId = organization.id;
|
||||
if (lastOrganizationId === sourceId) {
|
||||
refreshSessionAndCookies(DEFAULT, sourceId);
|
||||
}
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.reloadTopMenus();
|
||||
});
|
||||
|
@ -403,12 +393,6 @@ export default {
|
|||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.result = this.$get('/user/special/org/member/delete/' + this.currentRow.id + '/' + encodeURIComponent(row.id), () => {
|
||||
let sourceId = this.currentRow.id;
|
||||
let currentUser = getCurrentUser();
|
||||
let userId = row.id;
|
||||
if (currentUser.id === userId) {
|
||||
refreshSessionAndCookies(ORGANIZATION, sourceId);
|
||||
}
|
||||
this.$success(this.$t('commons.remove_success'));
|
||||
this.cellClick(this.currentRow);
|
||||
});
|
||||
|
@ -483,9 +467,6 @@ export default {
|
|||
organizationId: this.currentRow.id
|
||||
};
|
||||
this.result = this.$post("user/special/org/member/add", param, () => {
|
||||
let sign = "other";
|
||||
let sourceId = this.currentRow.id;
|
||||
// refreshSessionAndCookies(sign, sourceId);
|
||||
this.cellClick(this.currentRow);
|
||||
this.dialogOrgMemberAddVisible = false;
|
||||
});
|
||||
|
|
|
@ -218,13 +218,11 @@ import MsTableOperator from "../../common/components/MsTableOperator";
|
|||
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
|
||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import {
|
||||
getCurrentUser,
|
||||
getCurrentWorkspaceId,
|
||||
listenGoBack,
|
||||
refreshSessionAndCookies,
|
||||
removeGoBackListener
|
||||
} from "@/common/js/utils";
|
||||
import {DEFAULT, GROUP_WORKSPACE, WORKSPACE} from "@/common/js/constants";
|
||||
import {GROUP_WORKSPACE} from "@/common/js/constants";
|
||||
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
|
||||
|
||||
export default {
|
||||
|
@ -417,12 +415,10 @@ export default {
|
|||
editMember(row) {
|
||||
this.dialogWsMemberUpdateVisible = true;
|
||||
this.memberForm = Object.assign({}, row);
|
||||
// console.log(this.memberForm)
|
||||
let groupIds = this.memberForm.groups.map(r => r.id);
|
||||
this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.orgId}, response => {
|
||||
this.$set(this.memberForm, "allgroups", response.data);
|
||||
});
|
||||
// console.log(this.memberForm)
|
||||
// 编辑时填充角色信息
|
||||
this.$set(this.memberForm, 'groupIds', groupIds);
|
||||
listenGoBack(this.handleClose);
|
||||
|
@ -437,12 +433,6 @@ export default {
|
|||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$get('/workspace/special/delete/' + workspace.id, () => {
|
||||
let lastWorkspaceId = getCurrentWorkspaceId();
|
||||
let sourceId = workspace.id;
|
||||
if (lastWorkspaceId === sourceId) {
|
||||
let sign = DEFAULT;
|
||||
refreshSessionAndCookies(sign, sourceId);
|
||||
}
|
||||
Message.success(this.$t('commons.delete_success'));
|
||||
this.list();
|
||||
});
|
||||
|
@ -460,13 +450,6 @@ export default {
|
|||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.result = this.$get('/user/special/ws/member/delete/' + this.currentWorkspaceRow.id + '/' + encodeURIComponent(row.id), () => {
|
||||
let sourceId = this.currentWorkspaceRow.id;
|
||||
let userId = row.id;
|
||||
let user = getCurrentUser();
|
||||
if (user.id === userId) {
|
||||
let sign = WORKSPACE;
|
||||
refreshSessionAndCookies(sign, sourceId);
|
||||
}
|
||||
this.$success(this.$t('commons.remove_success'));
|
||||
this.cellClick(this.currentWorkspaceRow);
|
||||
});
|
||||
|
|
|
@ -110,9 +110,8 @@ import MsTableHeader from "../../common/components/MsTableHeader";
|
|||
import MsTableOperator from "../../common/components/MsTableOperator";
|
||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
|
||||
import {getCurrentProjectID, getUUID, hasRole, listenGoBack, removeGoBackListener} from "@/common/js/utils";
|
||||
import {getCurrentProjectID, listenGoBack, removeGoBackListener} from "@/common/js/utils";
|
||||
import MsRolesTag from "../../common/components/MsRolesTag";
|
||||
import {ROLE_ADMIN} from "@/common/js/constants";
|
||||
import {getCurrentUser} from "../../../../common/js/utils";
|
||||
import {PHONE_REGEX} from "@/common/js/regex";
|
||||
import UserImport from "@/business/components/settings/system/components/UserImport";
|
||||
|
|
|
@ -269,27 +269,11 @@
|
|||
});
|
||||
},
|
||||
create() {
|
||||
// this.form = {};
|
||||
// let param = {
|
||||
// name: this.condition.name,
|
||||
// organizationId: this.currentUser().lastOrganizationId
|
||||
// };
|
||||
let wsId = getCurrentWorkspaceId();
|
||||
if (typeof wsId == "undefined" || wsId == null || wsId == "") {
|
||||
this.$warning(this.$t('workspace.please_select_a_workspace_first'));
|
||||
return false;
|
||||
}
|
||||
// this.$post('/user/org/member/list/all', param, response => {
|
||||
// this.createVisible = true;
|
||||
// this.userList = response.data;
|
||||
// })
|
||||
// this.$get('/user/list/', response => {
|
||||
// this.createVisible = true;
|
||||
// this.userList = response.data;
|
||||
// })
|
||||
// this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: getCurrentOrganizationId()}, response => {
|
||||
// this.$set(this.form, "groups", response.data);
|
||||
// })
|
||||
this.$refs.addMember.open();
|
||||
listenGoBack(this.handleClose);
|
||||
},
|
||||
|
|
|
@ -7,7 +7,6 @@ import {
|
|||
ORIGIN_COLOR_SHALLOW,
|
||||
PRIMARY_COLOR,
|
||||
PROJECT_ID,
|
||||
REFRESH_SESSION_USER_URL,
|
||||
ROLE_ADMIN,
|
||||
ROLE_ORG_ADMIN,
|
||||
ROLE_TEST_MANAGER,
|
||||
|
@ -233,15 +232,6 @@ export function saveLicense(data) {
|
|||
localStorage.setItem(LicenseKey, data);
|
||||
}
|
||||
|
||||
|
||||
export function refreshSessionAndCookies(sign, sourceId) {
|
||||
axios.post(REFRESH_SESSION_USER_URL + "/" + sign + "/" + sourceId).then(r => {
|
||||
saveLocalStorage(r.data);
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export function jsonToMap(jsonStr) {
|
||||
let obj = JSON.parse(jsonStr);
|
||||
let strMap = new Map();
|
||||
|
|
Loading…
Reference in New Issue