去掉todo
This commit is contained in:
parent
a6cca8e701
commit
e5f57dc68b
|
@ -1,8 +1,13 @@
|
||||||
package io.metersphere.service;
|
package io.metersphere.service;
|
||||||
|
|
||||||
|
import io.metersphere.base.domain.UserRole;
|
||||||
import io.metersphere.base.domain.Workspace;
|
import io.metersphere.base.domain.Workspace;
|
||||||
|
import io.metersphere.base.domain.WorkspaceExample;
|
||||||
import io.metersphere.base.mapper.WorkspaceMapper;
|
import io.metersphere.base.mapper.WorkspaceMapper;
|
||||||
|
import io.metersphere.commons.constants.RoleConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
|
import io.metersphere.user.SessionUser;
|
||||||
|
import io.metersphere.user.SessionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -10,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@ -21,10 +27,9 @@ public class WorkspaceService {
|
||||||
if (StringUtils.isBlank(workspace.getName())) {
|
if (StringUtils.isBlank(workspace.getName())) {
|
||||||
MSException.throwException("Workspace name cannot be null.");
|
MSException.throwException("Workspace name cannot be null.");
|
||||||
}
|
}
|
||||||
// TODO 组织ID 暂无
|
// set organization id
|
||||||
if (StringUtils.isBlank(workspace.getOrganizationId())) {
|
workspace.setOrganizationId(SessionUtils.getCurrentOrganizationId());
|
||||||
workspace.setOrganizationId("root");
|
|
||||||
}
|
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
if (StringUtils.isBlank(workspace.getId())) {
|
if (StringUtils.isBlank(workspace.getId())) {
|
||||||
workspace.setId(UUID.randomUUID().toString()); // 设置ID
|
workspace.setId(UUID.randomUUID().toString()); // 设置ID
|
||||||
|
@ -47,7 +52,18 @@ public class WorkspaceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkOwner(String workspaceId) {
|
public void checkOwner(String workspaceId) {
|
||||||
// TODO 验证当前用户是否拥有当前此空间权限
|
SessionUser user = SessionUtils.getUser();
|
||||||
|
List<String> orgIds = user.getUserRoles().stream()
|
||||||
|
.filter(ur -> RoleConstants.ORG_ADMIN.equals(ur.getRoleId()))
|
||||||
|
.map(UserRole::getSourceId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
WorkspaceExample example = new WorkspaceExample();
|
||||||
|
example.createCriteria()
|
||||||
|
.andOrganizationIdIn(orgIds)
|
||||||
|
.andIdEqualTo(workspaceId);
|
||||||
|
if (workspaceMapper.countByExample(example) == 0) {
|
||||||
|
MSException.throwException("The current workspace does not belong to the current user");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue