refactor(系统设置): 删除无用代码

This commit is contained in:
shiziyuan9527 2021-06-18 17:35:29 +08:00 committed by 刘瑞斌
parent d16cc9b5c0
commit 3bc0459f42
7 changed files with 5 additions and 172 deletions

View File

@ -105,10 +105,6 @@ public class UserService {
return extUserMapper.queryNameByIds(userIds); return extUserMapper.queryNameByIds(userIds);
} }
/* public List<String> queryEmailByIds(List<String> userIds) {
return extUserMapper.queryTypeByIds(userIds);
}*/
public UserDTO insert(UserRequest user) { public UserDTO insert(UserRequest user) {
checkUserParam(user); checkUserParam(user);
// //
@ -119,10 +115,7 @@ public class UserService {
} else { } else {
createUser(user); createUser(user);
} }
// List<Map<String, Object>> roles = user.getRoles();
// if (!roles.isEmpty()) {
// insertUserRole(roles, user.getId());
// }
List<Map<String, Object>> groups = user.getGroups(); List<Map<String, Object>> groups = user.getGroups();
if (!groups.isEmpty()) { if (!groups.isEmpty()) {
insertUserGroup(groups, user.getId()); insertUserGroup(groups, user.getId());
@ -194,9 +187,6 @@ public class UserService {
userRole.setSourceId("adminSourceId"); userRole.setSourceId("adminSourceId");
userRoleMapper.insertSelective(userRole); userRoleMapper.insertSelective(userRole);
} else { } else {
// if (!map.keySet().contains("ids")) {
// MSException.throwException(role + " no source id");
// }
List<String> list = (List<String>) map.get("ids"); List<String> list = (List<String>) map.get("ids");
for (int j = 0; j < list.size(); j++) { for (int j = 0; j < list.size(); j++) {
UserRole userRole1 = new UserRole(); UserRole userRole1 = new UserRole();
@ -283,9 +273,7 @@ public class UserService {
} }
UserDTO userDTO = new UserDTO(); UserDTO userDTO = new UserDTO();
BeanUtils.copyProperties(user, 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); UserGroupPermissionDTO dto = getUserGroupPermission(userId);
userDTO.setUserGroups(dto.getUserGroups()); userDTO.setUserGroups(dto.getUserGroups());
userDTO.setGroups(dto.getGroups()); userDTO.setGroups(dto.getGroups());
@ -401,16 +389,11 @@ public class UserService {
public void updateUserRole(UserRequest user) { public void updateUserRole(UserRequest user) {
String userId = user.getId(); String userId = user.getId();
UserRoleExample userRoleExample = new UserRoleExample();
userRoleExample.createCriteria().andUserIdEqualTo(userId);
List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
UserGroupExample userGroupExample = new UserGroupExample(); UserGroupExample userGroupExample = new UserGroupExample();
userGroupExample.createCriteria().andUserIdEqualTo(userId); userGroupExample.createCriteria().andUserIdEqualTo(userId);
List<UserGroup> userGroups = userGroupMapper.selectByExample(userGroupExample); List<UserGroup> userGroups = userGroupMapper.selectByExample(userGroupExample);
List<String> list = userGroups.stream().map(UserGroup::getSourceId).collect(Collectors.toList()); 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 (!CollectionUtils.isEmpty(list)) {
if (list.contains(user.getLastWorkspaceId()) || list.contains(user.getLastOrganizationId())) { if (list.contains(user.getLastWorkspaceId()) || list.contains(user.getLastOrganizationId())) {
user.setLastOrganizationId(null); user.setLastOrganizationId(null);
@ -420,12 +403,9 @@ public class UserService {
} }
userGroupMapper.deleteByExample(userGroupExample); userGroupMapper.deleteByExample(userGroupExample);
// userRoleMapper.deleteByExample(userRoleExample);
// List<Map<String, Object>> roles = user.getRoles();
List<Map<String, Object>> groups = user.getGroups(); List<Map<String, Object>> groups = user.getGroups();
if (!groups.isEmpty()) { if (!groups.isEmpty()) {
insertUserGroup(groups, user.getId()); insertUserGroup(groups, user.getId());
// insertUserRole(roles, user.getId());
} }
UserExample example = new UserExample(); UserExample example = new UserExample();
@ -553,10 +533,6 @@ public class UserService {
} }
public void deleteMember(String workspaceId, String userId) { public void deleteMember(String workspaceId, String userId) {
// UserRoleExample example = new UserRoleExample();
// example.createCriteria().andRoleIdLike("%test%")
// .andUserIdEqualTo(userId).andSourceIdEqualTo(workspaceId);
GroupExample groupExample = new GroupExample(); GroupExample groupExample = new GroupExample();
groupExample.createCriteria().andTypeEqualTo(UserGroupType.WORKSPACE); groupExample.createCriteria().andTypeEqualTo(UserGroupType.WORKSPACE);
List<Group> groups = groupMapper.selectByExample(groupExample); List<Group> groups = groupMapper.selectByExample(groupExample);
@ -582,25 +558,12 @@ public class UserService {
public void addOrganizationMember(AddOrgMemberRequest request) { public void addOrganizationMember(AddOrgMemberRequest request) {
if (!CollectionUtils.isEmpty(request.getUserIds())) { if (!CollectionUtils.isEmpty(request.getUserIds())) {
for (String userId : 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 userGroupExample = new UserGroupExample();
userGroupExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getOrganizationId()); userGroupExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getOrganizationId());
List<UserGroup> userGroups = userGroupMapper.selectByExample(userGroupExample); List<UserGroup> userGroups = userGroupMapper.selectByExample(userGroupExample);
if (userGroups.size() > 0) { if (userGroups.size() > 0) {
MSException.throwException(Translator.get("user_already_exists") + ": " + userId); MSException.throwException(Translator.get("user_already_exists") + ": " + userId);
} else { } 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()) { for (String groupId : request.getGroupIds()) {
UserGroup userGroup = new UserGroup(); UserGroup userGroup = new UserGroup();
userGroup.setId(UUID.randomUUID().toString()); userGroup.setId(UUID.randomUUID().toString());
@ -627,9 +590,6 @@ public class UserService {
return; return;
} }
// UserRoleExample userRoleExample = new UserRoleExample();
// userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdIn(resourceIds);
UserGroupExample userGroupExample = new UserGroupExample(); UserGroupExample userGroupExample = new UserGroupExample();
userGroupExample.createCriteria().andUserIdEqualTo(userId) userGroupExample.createCriteria().andUserIdEqualTo(userId)
.andGroupIdIn(groupIds) .andGroupIdIn(groupIds)
@ -642,7 +602,6 @@ public class UserService {
userMapper.updateByPrimaryKeySelective(user); userMapper.updateByPrimaryKeySelective(user);
} }
// userRoleMapper.deleteByExample(userRoleExample);
userGroupMapper.deleteByExample(userGroupExample); userGroupMapper.deleteByExample(userGroupExample);
} }
@ -762,32 +721,6 @@ public class UserService {
if (subject.isAuthenticated()) { if (subject.isAuthenticated()) {
UserDTO user = (UserDTO) subject.getSession().getAttribute(ATTR_USER); UserDTO user = (UserDTO) subject.getSession().getAttribute(ATTR_USER);
autoSwitch(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")); return ResultHolder.success(subject.getSession().getAttribute("user"));
} else { } else {
return ResultHolder.error(Translator.get("login_fail")); return ResultHolder.error(Translator.get("login_fail"));

View File

@ -150,7 +150,7 @@
<script> <script>
import MsCreateBox from "../CreateBox"; import MsCreateBox from "../CreateBox";
import {Message} from "element-ui"; 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 MsTablePagination from "../../common/pagination/TablePagination";
import MsTableHeader from "../../common/components/MsTableHeader"; import MsTableHeader from "../../common/components/MsTableHeader";
import MsRolesTag from "../../common/components/MsRolesTag"; import MsRolesTag from "../../common/components/MsRolesTag";
@ -162,7 +162,6 @@ import {
getCurrentUser, getCurrentUser,
getCurrentWorkspaceId, getCurrentWorkspaceId,
listenGoBack, listenGoBack,
refreshSessionAndCookies,
removeGoBackListener removeGoBackListener
} from "../../../../common/js/utils"; } from "../../../../common/js/utils";
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm"; import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
@ -241,12 +240,6 @@ export default {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$get('/workspace/delete/' + workspace.id, () => { 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.$success(this.$t('commons.delete_success'));
this.list(); this.list();
}); });
@ -261,36 +254,6 @@ export default {
list() { list() {
let url = '/workspace/list/' + this.currentPage + '/' + this.pageSize; let url = '/workspace/list/' + this.currentPage + '/' + this.pageSize;
let lastOrganizationId = getCurrentOrganizationId(); 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.condition.organizationId = lastOrganizationId;
this.result = this.$post(url, this.condition, response => { this.result = this.$post(url, this.condition, response => {
let data = response.data; let data = response.data;

View File

@ -202,9 +202,7 @@ import MsTableOperatorButton from "../../common/components/MsTableOperatorButton
import MsDialogFooter from "../../common/components/MsDialogFooter"; import MsDialogFooter from "../../common/components/MsDialogFooter";
import { import {
getCurrentOrganizationId, getCurrentOrganizationId,
getCurrentUser,
listenGoBack, listenGoBack,
refreshSessionAndCookies,
removeGoBackListener removeGoBackListener
} from "@/common/js/utils"; } from "@/common/js/utils";
import {DEFAULT, GROUP_ORGANIZATION, ORGANIZATION} from "@/common/js/constants"; import {DEFAULT, GROUP_ORGANIZATION, ORGANIZATION} from "@/common/js/constants";
@ -316,9 +314,6 @@ export default {
this.dialogOrgMemberUpdateVisible = true; this.dialogOrgMemberUpdateVisible = true;
this.memberForm = Object.assign({}, row); this.memberForm = Object.assign({}, row);
let groupIds = this.memberForm.groups.map(r => r.id); 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.result = this.$post('/user/group/list', {type: GROUP_ORGANIZATION, resourceId: this.orgId}, response => {
this.$set(this.memberForm, "allgroups", response.data); this.$set(this.memberForm, "allgroups", response.data);
}); });
@ -381,11 +376,6 @@ export default {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.result = this.$get(this.deletePath + organization.id, () => { 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.$success(this.$t('commons.delete_success'));
this.reloadTopMenus(); this.reloadTopMenus();
}); });
@ -403,12 +393,6 @@ export default {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.result = this.$get('/user/special/org/member/delete/' + this.currentRow.id + '/' + encodeURIComponent(row.id), () => { 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.$success(this.$t('commons.remove_success'));
this.cellClick(this.currentRow); this.cellClick(this.currentRow);
}); });
@ -483,9 +467,6 @@ export default {
organizationId: this.currentRow.id organizationId: this.currentRow.id
}; };
this.result = this.$post("user/special/org/member/add", param, () => { 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.cellClick(this.currentRow);
this.dialogOrgMemberAddVisible = false; this.dialogOrgMemberAddVisible = false;
}); });

View File

@ -218,13 +218,11 @@ import MsTableOperator from "../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton"; import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import MsDialogFooter from "../../common/components/MsDialogFooter"; import MsDialogFooter from "../../common/components/MsDialogFooter";
import { import {
getCurrentUser,
getCurrentWorkspaceId, getCurrentWorkspaceId,
listenGoBack, listenGoBack,
refreshSessionAndCookies,
removeGoBackListener removeGoBackListener
} from "@/common/js/utils"; } 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"; import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
export default { export default {
@ -417,12 +415,10 @@ export default {
editMember(row) { editMember(row) {
this.dialogWsMemberUpdateVisible = true; this.dialogWsMemberUpdateVisible = true;
this.memberForm = Object.assign({}, row); this.memberForm = Object.assign({}, row);
// console.log(this.memberForm)
let groupIds = this.memberForm.groups.map(r => r.id); let groupIds = this.memberForm.groups.map(r => r.id);
this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.orgId}, response => { this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.orgId}, response => {
this.$set(this.memberForm, "allgroups", response.data); this.$set(this.memberForm, "allgroups", response.data);
}); });
// console.log(this.memberForm)
// //
this.$set(this.memberForm, 'groupIds', groupIds); this.$set(this.memberForm, 'groupIds', groupIds);
listenGoBack(this.handleClose); listenGoBack(this.handleClose);
@ -437,12 +433,6 @@ export default {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$get('/workspace/special/delete/' + workspace.id, () => { 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')); Message.success(this.$t('commons.delete_success'));
this.list(); this.list();
}); });
@ -460,13 +450,6 @@ export default {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.result = this.$get('/user/special/ws/member/delete/' + this.currentWorkspaceRow.id + '/' + encodeURIComponent(row.id), () => { 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.$success(this.$t('commons.remove_success'));
this.cellClick(this.currentWorkspaceRow); this.cellClick(this.currentWorkspaceRow);
}); });

View File

@ -110,9 +110,8 @@ import MsTableHeader from "../../common/components/MsTableHeader";
import MsTableOperator from "../../common/components/MsTableOperator"; import MsTableOperator from "../../common/components/MsTableOperator";
import MsDialogFooter from "../../common/components/MsDialogFooter"; import MsDialogFooter from "../../common/components/MsDialogFooter";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton"; 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 MsRolesTag from "../../common/components/MsRolesTag";
import {ROLE_ADMIN} from "@/common/js/constants";
import {getCurrentUser} from "../../../../common/js/utils"; import {getCurrentUser} from "../../../../common/js/utils";
import {PHONE_REGEX} from "@/common/js/regex"; import {PHONE_REGEX} from "@/common/js/regex";
import UserImport from "@/business/components/settings/system/components/UserImport"; import UserImport from "@/business/components/settings/system/components/UserImport";

View File

@ -269,27 +269,11 @@
}); });
}, },
create() { create() {
// this.form = {};
// let param = {
// name: this.condition.name,
// organizationId: this.currentUser().lastOrganizationId
// };
let wsId = getCurrentWorkspaceId(); let wsId = getCurrentWorkspaceId();
if (typeof wsId == "undefined" || wsId == null || wsId == "") { if (typeof wsId == "undefined" || wsId == null || wsId == "") {
this.$warning(this.$t('workspace.please_select_a_workspace_first')); this.$warning(this.$t('workspace.please_select_a_workspace_first'));
return false; 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(); this.$refs.addMember.open();
listenGoBack(this.handleClose); listenGoBack(this.handleClose);
}, },

View File

@ -7,7 +7,6 @@ import {
ORIGIN_COLOR_SHALLOW, ORIGIN_COLOR_SHALLOW,
PRIMARY_COLOR, PRIMARY_COLOR,
PROJECT_ID, PROJECT_ID,
REFRESH_SESSION_USER_URL,
ROLE_ADMIN, ROLE_ADMIN,
ROLE_ORG_ADMIN, ROLE_ORG_ADMIN,
ROLE_TEST_MANAGER, ROLE_TEST_MANAGER,
@ -233,15 +232,6 @@ export function saveLicense(data) {
localStorage.setItem(LicenseKey, 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) { export function jsonToMap(jsonStr) {
let obj = JSON.parse(jsonStr); let obj = JSON.parse(jsonStr);
let strMap = new Map(); let strMap = new Map();