Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
867225673b
|
@ -25,7 +25,7 @@
|
|||
inner join test_case on test_plan_test_case.case_id = test_case.id
|
||||
<where>
|
||||
<if test="request.name != null">
|
||||
and test_plan_test_case.name like CONCAT('%', #{request.name},'%')
|
||||
and test_case.name like CONCAT('%', #{request.name},'%')
|
||||
</if>
|
||||
<if test="request.nodeIds != null and request.nodeIds.size() > 0">
|
||||
and test_plan_test_case.node_id in
|
||||
|
|
|
@ -9,6 +9,7 @@ import io.metersphere.commons.utils.Pager;
|
|||
import io.metersphere.controller.request.OrganizationRequest;
|
||||
import io.metersphere.dto.OrganizationMemberDTO;
|
||||
import io.metersphere.service.OrganizationService;
|
||||
import io.metersphere.service.UserService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -22,6 +23,8 @@ public class OrganizationController {
|
|||
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@RequiresRoles(RoleConstants.ADMIN)
|
||||
|
@ -45,6 +48,7 @@ public class OrganizationController {
|
|||
@GetMapping("/delete/{organizationId}")
|
||||
@RequiresRoles(RoleConstants.ADMIN)
|
||||
public void deleteOrganization(@PathVariable(value = "organizationId") String organizationId) {
|
||||
userService.refreshSessionUser("organization", organizationId);
|
||||
organizationService.deleteOrganization(organizationId);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.shiro.authz.annotation.Logical;
|
|||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -144,6 +145,13 @@ public class UserController {
|
|||
return SessionUtils.getUser();
|
||||
}
|
||||
|
||||
@PostMapping("/refresh/{sign}/{sourceId}")
|
||||
@RequiresRoles(RoleConstants.ADMIN)
|
||||
public UserDTO refreshSessionUser(@PathVariable String sign, @PathVariable String sourceId) {
|
||||
userService.refreshSessionUser(sign, sourceId);
|
||||
return SessionUtils.getUser();
|
||||
}
|
||||
|
||||
@GetMapping("/info/{userId}")
|
||||
public User getUserInfo(@PathVariable(value = "userId") String userId) {
|
||||
return userService.getUserInfo(userId);
|
||||
|
|
|
@ -10,12 +10,12 @@ import io.metersphere.controller.request.WorkspaceRequest;
|
|||
import io.metersphere.dto.WorkspaceDTO;
|
||||
import io.metersphere.dto.WorkspaceMemberDTO;
|
||||
import io.metersphere.service.OrganizationService;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.service.WorkspaceService;
|
||||
import io.metersphere.user.SessionUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -26,6 +26,8 @@ public class WorkspaceController {
|
|||
private WorkspaceService workspaceService;
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@PostMapping("add")
|
||||
@RequiresRoles(RoleConstants.ORG_ADMIN)
|
||||
|
@ -57,6 +59,7 @@ public class WorkspaceController {
|
|||
@GetMapping("special/delete/{workspaceId}")
|
||||
@RequiresRoles(RoleConstants.ADMIN)
|
||||
public void deleteWorkspaceByAdmin(@PathVariable String workspaceId) {
|
||||
userService.refreshSessionUser("workspace", workspaceId);
|
||||
workspaceService.deleteWorkspace(workspaceId);
|
||||
}
|
||||
|
||||
|
@ -64,6 +67,7 @@ public class WorkspaceController {
|
|||
@RequiresRoles(RoleConstants.ORG_ADMIN)
|
||||
public void deleteWorkspace(@PathVariable String workspaceId) {
|
||||
workspaceService.checkWorkspaceOwnerByOrgAdmin(workspaceId);
|
||||
userService.refreshSessionUser("workspace", workspaceId);
|
||||
workspaceService.deleteWorkspace(workspaceId);
|
||||
}
|
||||
|
||||
|
|
|
@ -258,6 +258,25 @@ public class UserService {
|
|||
}
|
||||
}
|
||||
|
||||
public void refreshSessionUser(String sign, String sourceId) {
|
||||
SessionUser sessionUser = SessionUtils.getUser();
|
||||
// 获取最新UserDTO
|
||||
UserDTO user = getUserDTO(sessionUser.getId());
|
||||
User newUser = new User();
|
||||
if (StringUtils.equals("organization", sign) && StringUtils.equals(sourceId, user.getLastOrganizationId())) {
|
||||
user.setLastOrganizationId("");
|
||||
user.setLastWorkspaceId("");
|
||||
}
|
||||
if (StringUtils.equals("workspace", sign) && StringUtils.equals(sourceId, user.getLastWorkspaceId())) {
|
||||
user.setLastWorkspaceId("");
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(user, newUser);
|
||||
|
||||
SessionUtils.putUser(SessionUser.fromUser(user));
|
||||
userMapper.updateByPrimaryKeySelective(newUser);
|
||||
}
|
||||
|
||||
/*修改当前用户用户密码*/
|
||||
private User updateCurrentUserPwd(EditPassWordRequest request) {
|
||||
if (SessionUtils.getUser() != null) {
|
||||
|
|
|
@ -145,12 +145,13 @@
|
|||
<script>
|
||||
import MsCreateBox from "../CreateBox";
|
||||
import {Message} from "element-ui";
|
||||
import {TokenKey} from "../../../../common/js/constants";
|
||||
import {DEFAULT, TokenKey} from "../../../../common/js/constants";
|
||||
import MsTablePagination from "../../common/pagination/TablePagination";
|
||||
import MsTableHeader from "../../common/components/MsTableHeader";
|
||||
import MsRolesTag from "../../common/components/MsRolesTag";
|
||||
import MsTableOperator from "../../common/components/MsTableOperator";
|
||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import {getCurrentWorkspaceId, refreshSessionAndCookies} from "../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsOrganizationWorkspace",
|
||||
|
@ -197,6 +198,12 @@
|
|||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$get('/workspace/delete/' + row.id, () => {
|
||||
let lastWorkspaceId = getCurrentWorkspaceId();
|
||||
let sourceId = row.id;
|
||||
if (lastWorkspaceId === sourceId) {
|
||||
let sign = DEFAULT;
|
||||
refreshSessionAndCookies(sign, sourceId);
|
||||
}
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.list();
|
||||
});
|
||||
|
|
|
@ -175,6 +175,8 @@
|
|||
import MsRolesTag from "../../common/components/MsRolesTag";
|
||||
import MsTableOperator from "../../common/components/MsTableOperator";
|
||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import {getCurrentOrganizationId, getCurrentUser, refreshSessionAndCookies} from "../../../../common/js/utils";
|
||||
import {DEFAULT, ORGANIZATION} from "../../../../common/js/constants";
|
||||
|
||||
export default {
|
||||
name: "MsOrganization",
|
||||
|
@ -311,6 +313,12 @@
|
|||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.result = this.$get(this.deletePath + row.id, () => {
|
||||
let lastOrganizationId = getCurrentOrganizationId();
|
||||
let sourceId = row.id;
|
||||
if (lastOrganizationId === sourceId) {
|
||||
let sign = DEFAULT;
|
||||
refreshSessionAndCookies(sign, sourceId);
|
||||
}
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.initTableData();
|
||||
});
|
||||
|
@ -325,6 +333,13 @@
|
|||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.result = this.$get('/user/special/org/member/delete/' + this.currentRow.id + '/' + row.id, () => {
|
||||
let sourceId = this.currentRow.id;
|
||||
let currentUser = getCurrentUser();
|
||||
let userId = row.id;
|
||||
if (currentUser.id === userId) {
|
||||
let sign = ORGANIZATION;
|
||||
refreshSessionAndCookies(sign, sourceId);
|
||||
}
|
||||
this.$success(this.$t('commons.delete_success'))
|
||||
this.cellClick(this.currentRow);
|
||||
});
|
||||
|
@ -395,6 +410,9 @@
|
|||
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;
|
||||
})
|
||||
|
|
|
@ -195,6 +195,8 @@
|
|||
import MsRolesTag from "../../common/components/MsRolesTag";
|
||||
import MsTableOperator from "../../common/components/MsTableOperator";
|
||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import {getCurrentUser, getCurrentWorkspaceId, refreshSessionAndCookies} from "../../../../common/js/utils";
|
||||
import {DEFAULT, WORKSPACE} from "../../../../common/js/constants";
|
||||
|
||||
export default {
|
||||
name: "MsSystemWorkspace",
|
||||
|
@ -307,6 +309,12 @@
|
|||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$get('/workspace/special/delete/' + row.id, () => {
|
||||
let lastWorkspaceId = getCurrentWorkspaceId();
|
||||
let sourceId = row.id;
|
||||
if (lastWorkspaceId === sourceId) {
|
||||
let sign = DEFAULT;
|
||||
refreshSessionAndCookies(sign, sourceId);
|
||||
}
|
||||
Message.success(this.$t('commons.delete_success'));
|
||||
this.list();
|
||||
});
|
||||
|
@ -374,6 +382,13 @@
|
|||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.result = this.$get('/user/special/ws/member/delete/' + this.currentWorkspaceRow.id + '/' + 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.delete_success'));
|
||||
this.cellClick(this.currentWorkspaceRow);
|
||||
});
|
||||
|
|
|
@ -8,3 +8,8 @@ export const ROLE_TEST_VIEWER = 'test_viewer';
|
|||
|
||||
export const WORKSPACE_ID = 'workspace_id';
|
||||
export const CURRENT_PROJECT = 'current_project';
|
||||
|
||||
export const REFRESH_SESSION_USER_URL = 'user/refresh';
|
||||
export const WORKSPACE = 'workspace';
|
||||
export const ORGANIZATION = 'organization';
|
||||
export const DEFAULT = 'default';
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
import {ROLE_ORG_ADMIN, ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER, TokenKey} from "./constants";
|
||||
import {
|
||||
REFRESH_SESSION_USER_URL,
|
||||
ROLE_ORG_ADMIN,
|
||||
ROLE_TEST_MANAGER,
|
||||
ROLE_TEST_USER,
|
||||
ROLE_TEST_VIEWER,
|
||||
TokenKey
|
||||
} from "./constants";
|
||||
import axios from "axios";
|
||||
|
||||
export function hasRole(role) {
|
||||
let user = JSON.parse(localStorage.getItem(TokenKey));
|
||||
|
@ -29,6 +37,20 @@ export function checkoutCurrentWorkspace() {
|
|||
return user.userRoles.filter(ur => hasRoles(ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER) && user.lastWorkspaceId === ur.sourceId).length > 0;
|
||||
}
|
||||
|
||||
export function getCurrentOrganizationId() {
|
||||
let user = JSON.parse(localStorage.getItem(TokenKey));
|
||||
return user.lastOrganizationId;
|
||||
}
|
||||
|
||||
export function getCurrentWorkspaceId() {
|
||||
let user = JSON.parse(localStorage.getItem(TokenKey));
|
||||
return user.lastWorkspaceId;
|
||||
}
|
||||
|
||||
export function getCurrentUser() {
|
||||
return JSON.parse(localStorage.getItem(TokenKey));
|
||||
}
|
||||
|
||||
export function saveLocalStorage(response) {
|
||||
// 登录信息保存 cookie
|
||||
localStorage.setItem(TokenKey, JSON.stringify(response.data));
|
||||
|
@ -38,6 +60,13 @@ export function saveLocalStorage(response) {
|
|||
localStorage.setItem("roles", roles);
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue