删除无用代码
This commit is contained in:
parent
28a2d25ce0
commit
63f3b96486
|
@ -23,7 +23,6 @@ import org.springframework.beans.BeanUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -129,107 +128,6 @@ public class UserService {
|
|||
userMapper.updateByPrimaryKeySelective(user);
|
||||
}
|
||||
|
||||
/*public List<Role> getUserRolesList(String userId) {
|
||||
UserRoleExample userRoleExample = new UserRoleExample();
|
||||
userRoleExample.createCriteria().andUserIdEqualTo(userId);
|
||||
List<UserRole> userRolesList = userRoleMapper.selectByExample(userRoleExample);
|
||||
List<String> roleIds = userRolesList.stream().map(UserRole::getRoleId).collect(Collectors.toList());
|
||||
RoleExample roleExample = new RoleExample();
|
||||
roleExample.createCriteria().andIdIn(roleIds);
|
||||
return roleMapper.selectByExample(roleExample);
|
||||
}
|
||||
|
||||
public List<UserRoleDTO> getUserRoleList(String userId) {
|
||||
if (StringUtils.isEmpty(userId)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return convertUserRoleDTO(extUserRoleMapper.getUserRoleHelpList(userId));
|
||||
}*/
|
||||
|
||||
private List<UserRoleDTO> convertUserRoleDTO(List<UserRoleHelpDTO> helpDTOList) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
Map<String, UserRoleDTO> roleMap = new HashMap<>();
|
||||
|
||||
List<UserRoleDTO> resultList = new ArrayList<>();
|
||||
|
||||
List<UserRoleDTO> otherList = new ArrayList<>();
|
||||
|
||||
Set<String> orgSet = new HashSet<>();
|
||||
|
||||
Set<String> workspaceSet = new HashSet<>();
|
||||
|
||||
for (UserRoleHelpDTO helpDTO : helpDTOList) {
|
||||
UserRoleDTO userRoleDTO = roleMap.get(helpDTO.getSourceId());
|
||||
|
||||
if (userRoleDTO == null) {
|
||||
userRoleDTO = new UserRoleDTO();
|
||||
|
||||
if (!StringUtils.isEmpty(helpDTO.getParentId())) {
|
||||
workspaceSet.add(helpDTO.getParentId());
|
||||
userRoleDTO.setType("workspace");
|
||||
} else {
|
||||
orgSet.add(helpDTO.getSourceId());
|
||||
userRoleDTO.setType("organization");
|
||||
}
|
||||
|
||||
userRoleDTO.setId(helpDTO.getSourceId());
|
||||
userRoleDTO.setRoleId(helpDTO.getRoleId());
|
||||
userRoleDTO.setName(helpDTO.getSourceName());
|
||||
userRoleDTO.setParentId(helpDTO.getParentId());
|
||||
userRoleDTO.setDesc(helpDTO.getRoleName());
|
||||
|
||||
} else {
|
||||
userRoleDTO.setDesc(userRoleDTO.getDesc() + "," + helpDTO.getRoleName());
|
||||
}
|
||||
roleMap.put(helpDTO.getSourceId(), userRoleDTO);
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(buffer.toString())) {
|
||||
UserRoleDTO dto = new UserRoleDTO();
|
||||
dto.setId("admin");
|
||||
dto.setType("admin");
|
||||
dto.setDesc(buffer.toString());
|
||||
resultList.add(dto);
|
||||
}
|
||||
|
||||
for (String org : orgSet) {
|
||||
workspaceSet.remove(org);
|
||||
}
|
||||
|
||||
List<UserRoleDTO> orgWorkSpace = new ArrayList<>(roleMap.values());
|
||||
|
||||
if (!CollectionUtils.isEmpty(workspaceSet)) {
|
||||
for (String orgId : workspaceSet) {
|
||||
Organization organization = organizationMapper.selectByPrimaryKey(orgId);
|
||||
if (organization != null) {
|
||||
UserRoleDTO dto = new UserRoleDTO();
|
||||
dto.setId(orgId);
|
||||
dto.setName(organization.getName());
|
||||
dto.setSwitchable(false);
|
||||
dto.setType("organization");
|
||||
orgWorkSpace.add(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
orgWorkSpace.sort((o1, o2) -> {
|
||||
if (o1.getParentId() == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (o2.getParentId() == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return o1.getParentId().compareTo(o2.getParentId());
|
||||
});
|
||||
resultList.addAll(orgWorkSpace);
|
||||
resultList.addAll(otherList);
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public void switchUserRole(UserDTO user, String sign, String sourceId) {
|
||||
User newUser = new User();
|
||||
if (StringUtils.equals("organization", sign)) {
|
||||
|
@ -336,10 +234,6 @@ public class UserService {
|
|||
return userMapper.countByExample(example) > 0;
|
||||
}
|
||||
|
||||
public List<OrganizationMemberDTO> getOrganizationMemberDTO(QueryOrgMemberRequest request) {
|
||||
return extUserRoleMapper.getOrganizationMemberDTO(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询该组织外的其他用户列表
|
||||
*/
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -59,9 +58,9 @@ public class WorkspaceService {
|
|||
if (workspaceMapper.countByExample(example) > 0) {
|
||||
MSException.throwException(Translator.get("workspace_name_already_exists"));
|
||||
}
|
||||
workspace.setId(UUID.randomUUID().toString()); // 设置ID
|
||||
workspace.setId(UUID.randomUUID().toString());
|
||||
workspace.setCreateTime(currentTime);
|
||||
workspace.setUpdateTime(currentTime); // 首次 update time
|
||||
workspace.setUpdateTime(currentTime);
|
||||
workspaceMapper.insertSelective(workspace);
|
||||
} else {
|
||||
workspace.setUpdateTime(currentTime);
|
||||
|
@ -112,19 +111,6 @@ public class WorkspaceService {
|
|||
}
|
||||
}
|
||||
|
||||
public void checkWorkspaceOwnerByTestManager(String workspaceId) {
|
||||
checkWorkspaceIsExist(workspaceId);
|
||||
SessionUser user = SessionUtils.getUser();
|
||||
List<String> wsIds = user.getUserRoles().stream()
|
||||
.filter(ur -> RoleConstants.TEST_MANAGER.equals(ur.getRoleId()))
|
||||
.map(UserRole::getSourceId)
|
||||
.collect(Collectors.toList());
|
||||
boolean contains = wsIds.contains(workspaceId);
|
||||
if (!contains) {
|
||||
MSException.throwException(Translator.get("workspace_does_not_belong_to_user"));
|
||||
}
|
||||
}
|
||||
|
||||
public void checkWorkspaceOwner(String workspaceId) {
|
||||
checkWorkspaceIsExist(workspaceId);
|
||||
WorkspaceExample example = new WorkspaceExample();
|
||||
|
|
Loading…
Reference in New Issue