refactor(项目设置): 修改项目列表的创建人的显示
This commit is contained in:
parent
8a67a0d3fe
commit
59ae66ceef
|
@ -28,7 +28,9 @@ public interface BaseUserMapper {
|
||||||
List<String> selectUnDeletedUserIdByIdList(@Param("idList") List<String> userIdList);
|
List<String> selectUnDeletedUserIdByIdList(@Param("idList") List<String> userIdList);
|
||||||
|
|
||||||
long deleteUser(String id, String deleteUser, long deleteTime);
|
long deleteUser(String id, String deleteUser, long deleteTime);
|
||||||
|
|
||||||
List<OptionDTO> selectUserOptionByIds(List<String> userIds);
|
List<OptionDTO> selectUserOptionByIds(List<String> userIds);
|
||||||
|
|
||||||
List<ExcludeOptionDTO> getExcludeSelectOption();
|
List<ExcludeOptionDTO> getExcludeSelectOption();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,7 @@ import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
@ -428,4 +426,11 @@ public class BaseUserService {
|
||||||
public List<ExcludeOptionDTO> getExcludeSelectOption() {
|
public List<ExcludeOptionDTO> getExcludeSelectOption() {
|
||||||
return baseUserMapper.getExcludeSelectOption();
|
return baseUserMapper.getExcludeSelectOption();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getUserNameMap() {
|
||||||
|
List<ExcludeOptionDTO> excludeSelectOption = getExcludeSelectOption();
|
||||||
|
Map<String, String> nameMap = new HashMap<>();
|
||||||
|
excludeSelectOption.forEach(option -> nameMap.put(option.getId(), option.getName()));
|
||||||
|
return nameMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
p.delete_time,
|
p.delete_time,
|
||||||
p.deleted,
|
p.deleted,
|
||||||
p.delete_user,
|
p.delete_user,
|
||||||
|
p.update_user,
|
||||||
p.enable,
|
p.enable,
|
||||||
count(distinct u.id) as memberCount,
|
count(distinct u.id) as memberCount,
|
||||||
o.name as organizationName,
|
o.name as organizationName,
|
||||||
|
|
|
@ -13,6 +13,7 @@ import io.metersphere.sdk.invoker.ProjectServiceInvoker;
|
||||||
import io.metersphere.sdk.log.constants.OperationLogModule;
|
import io.metersphere.sdk.log.constants.OperationLogModule;
|
||||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||||
import io.metersphere.sdk.log.service.OperationLogService;
|
import io.metersphere.sdk.log.service.OperationLogService;
|
||||||
|
import io.metersphere.sdk.service.BaseUserService;
|
||||||
import io.metersphere.sdk.util.BeanUtils;
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
|
@ -52,6 +53,8 @@ public class CommonProjectService {
|
||||||
private UserRoleMapper userRoleMapper;
|
private UserRoleMapper userRoleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private UserRolePermissionMapper userRolePermissionMapper;
|
private UserRolePermissionMapper userRolePermissionMapper;
|
||||||
|
@Resource
|
||||||
|
private BaseUserService baseUserService;
|
||||||
private final ProjectServiceInvoker serviceInvoker;
|
private final ProjectServiceInvoker serviceInvoker;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -173,6 +176,7 @@ public class CommonProjectService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProjectDTO> buildUserInfo(List<ProjectDTO> projectList) {
|
public List<ProjectDTO> buildUserInfo(List<ProjectDTO> projectList) {
|
||||||
|
Map<String, String> userMap = baseUserService.getUserNameMap();
|
||||||
projectList.forEach(projectDTO -> {
|
projectList.forEach(projectDTO -> {
|
||||||
if (StringUtils.isNotBlank(projectDTO.getModuleSetting())) {
|
if (StringUtils.isNotBlank(projectDTO.getModuleSetting())) {
|
||||||
projectDTO.setModuleIds(JSON.parseArray(projectDTO.getModuleSetting(), String.class));
|
projectDTO.setModuleIds(JSON.parseArray(projectDTO.getModuleSetting(), String.class));
|
||||||
|
@ -183,7 +187,9 @@ public class CommonProjectService {
|
||||||
if (CollectionUtils.isNotEmpty(userIds) && userIds.contains(projectDTO.getCreateUser())) {
|
if (CollectionUtils.isNotEmpty(userIds) && userIds.contains(projectDTO.getCreateUser())) {
|
||||||
projectDTO.setProjectCreateUserIsAdmin(true);
|
projectDTO.setProjectCreateUserIsAdmin(true);
|
||||||
}
|
}
|
||||||
|
projectDTO.setCreateUser(userMap.get(projectDTO.getCreateUser()));
|
||||||
|
projectDTO.setUpdateUser(userMap.get(projectDTO.getUpdateUser()));
|
||||||
|
projectDTO.setDeleteUser(userMap.get(projectDTO.getDeleteUser()));
|
||||||
});
|
});
|
||||||
return projectList;
|
return projectList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,19 @@ import io.metersphere.sdk.constants.InternalUserRole;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.sdk.controller.handler.ResultHolder;
|
import io.metersphere.sdk.controller.handler.ResultHolder;
|
||||||
import io.metersphere.sdk.dto.*;
|
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||||
|
import io.metersphere.sdk.dto.ProjectDTO;
|
||||||
|
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||||
|
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.sdk.util.Pager;
|
import io.metersphere.sdk.util.Pager;
|
||||||
|
import io.metersphere.system.domain.User;
|
||||||
import io.metersphere.system.domain.UserRoleRelation;
|
import io.metersphere.system.domain.UserRoleRelation;
|
||||||
import io.metersphere.system.domain.UserRoleRelationExample;
|
import io.metersphere.system.domain.UserRoleRelationExample;
|
||||||
import io.metersphere.system.dto.OrganizationDTO;
|
import io.metersphere.system.dto.OrganizationDTO;
|
||||||
import io.metersphere.system.dto.UserExtend;
|
import io.metersphere.system.dto.UserExtend;
|
||||||
|
import io.metersphere.system.mapper.UserMapper;
|
||||||
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
||||||
import io.metersphere.system.request.OrganizationProjectRequest;
|
import io.metersphere.system.request.OrganizationProjectRequest;
|
||||||
import io.metersphere.system.request.ProjectAddMemberRequest;
|
import io.metersphere.system.request.ProjectAddMemberRequest;
|
||||||
|
@ -75,6 +80,8 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
private UserRoleRelationMapper userRoleRelationMapper;
|
private UserRoleRelationMapper userRoleRelationMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private OrganizationService organizationService;
|
private OrganizationService organizationService;
|
||||||
|
@Resource
|
||||||
|
private UserMapper userMapper;
|
||||||
|
|
||||||
private OrganizationDTO getDefault() {
|
private OrganizationDTO getDefault() {
|
||||||
return organizationService.getDefault();
|
return organizationService.getDefault();
|
||||||
|
@ -347,7 +354,8 @@ public class OrganizationProjectControllerTests extends BaseTest {
|
||||||
projectDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ProjectDTO.class);
|
projectDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ProjectDTO.class);
|
||||||
//拿到所有的createUser
|
//拿到所有的createUser
|
||||||
List<String> createUsers = projectDTOS.stream().map(ProjectDTO::getCreateUser).toList();
|
List<String> createUsers = projectDTOS.stream().map(ProjectDTO::getCreateUser).toList();
|
||||||
Assertions.assertTrue(List.of("test").containsAll(createUsers));
|
User user = userMapper.selectByPrimaryKey("test");
|
||||||
|
Assertions.assertTrue(List.of(user.getName()).containsAll(createUsers));
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
requestPostPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ, getProjectList, projectRequest);
|
requestPostPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ, getProjectList, projectRequest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,18 @@ import io.metersphere.sdk.constants.InternalUserRole;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.sdk.controller.handler.ResultHolder;
|
import io.metersphere.sdk.controller.handler.ResultHolder;
|
||||||
import io.metersphere.sdk.dto.*;
|
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||||
|
import io.metersphere.sdk.dto.ProjectDTO;
|
||||||
|
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||||
|
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.sdk.util.Pager;
|
import io.metersphere.sdk.util.Pager;
|
||||||
|
import io.metersphere.system.domain.User;
|
||||||
import io.metersphere.system.domain.UserRoleRelation;
|
import io.metersphere.system.domain.UserRoleRelation;
|
||||||
import io.metersphere.system.domain.UserRoleRelationExample;
|
import io.metersphere.system.domain.UserRoleRelationExample;
|
||||||
import io.metersphere.system.dto.UserExtend;
|
import io.metersphere.system.dto.UserExtend;
|
||||||
|
import io.metersphere.system.mapper.UserMapper;
|
||||||
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
||||||
import io.metersphere.system.request.ProjectAddMemberRequest;
|
import io.metersphere.system.request.ProjectAddMemberRequest;
|
||||||
import io.metersphere.system.request.ProjectMemberRequest;
|
import io.metersphere.system.request.ProjectMemberRequest;
|
||||||
|
@ -70,6 +75,8 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
private ProjectMapper projectMapper;
|
private ProjectMapper projectMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private UserRoleRelationMapper userRoleRelationMapper;
|
private UserRoleRelationMapper userRoleRelationMapper;
|
||||||
|
@Resource
|
||||||
|
private UserMapper userMapper;
|
||||||
|
|
||||||
private void requestPost(String url, Object param, ResultMatcher resultMatcher) throws Exception {
|
private void requestPost(String url, Object param, ResultMatcher resultMatcher) throws Exception {
|
||||||
mockMvc.perform(MockMvcRequestBuilders.post(url)
|
mockMvc.perform(MockMvcRequestBuilders.post(url)
|
||||||
|
@ -333,7 +340,8 @@ public class SystemProjectControllerTests extends BaseTest {
|
||||||
projectDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ProjectDTO.class);
|
projectDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ProjectDTO.class);
|
||||||
//拿到所有的createUser
|
//拿到所有的createUser
|
||||||
List<String> createUsers = projectDTOS.stream().map(ProjectDTO::getCreateUser).toList();
|
List<String> createUsers = projectDTOS.stream().map(ProjectDTO::getCreateUser).toList();
|
||||||
Assertions.assertTrue(List.of("test").containsAll(createUsers));
|
User user = userMapper.selectByPrimaryKey("test");
|
||||||
|
Assertions.assertTrue(List.of(user.getName()).containsAll(createUsers));
|
||||||
// @@校验权限
|
// @@校验权限
|
||||||
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, getProjectList, projectRequest);
|
requestPostPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, getProjectList, projectRequest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,10 @@ replace into user(id, name, email, password, create_time, update_time, language,
|
||||||
last_project_id, create_user, update_user)
|
last_project_id, create_user, update_user)
|
||||||
VALUES ('admin2', 'test2', 'admin2@metersphere.io', MD5('admin2@metersphere.io'),
|
VALUES ('admin2', 'test2', 'admin2@metersphere.io', MD5('admin2@metersphere.io'),
|
||||||
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
||||||
|
replace into user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source,
|
||||||
|
last_project_id, create_user, update_user)
|
||||||
|
VALUES ('test', 'test', 'admin3@metersphere.io', MD5('admin2@metersphere.io'),
|
||||||
|
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
||||||
|
|
||||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,module_setting) VALUES ('projectId', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000, '["apiTest","uiTest"]');
|
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,module_setting) VALUES ('projectId', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000, '["apiTest","uiTest"]');
|
||||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES ('projectId1', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目1', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES ('projectId1', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目1', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||||
|
|
|
@ -15,6 +15,10 @@ into user(id, name, email, password, create_time, update_time, language, last_or
|
||||||
last_project_id, create_user, update_user)
|
last_project_id, create_user, update_user)
|
||||||
VALUES ('admin2', 'test2', 'admin2@metersphere.io', MD5('admin2@metersphere.io'),
|
VALUES ('admin2', 'test2', 'admin2@metersphere.io', MD5('admin2@metersphere.io'),
|
||||||
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
||||||
|
replace into user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source,
|
||||||
|
last_project_id, create_user, update_user)
|
||||||
|
VALUES ('test', 'test', 'admin3@metersphere.io', MD5('admin2@metersphere.io'),
|
||||||
|
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
||||||
|
|
||||||
replace
|
replace
|
||||||
INTO user_role_relation VALUES ('c3bb9b4f-46d8-4952-9681-8889974487w','admin1','project_admin','projectId1','1684747668375','1684747668375');
|
INTO user_role_relation VALUES ('c3bb9b4f-46d8-4952-9681-8889974487w','admin1','project_admin','projectId1','1684747668375','1684747668375');
|
||||||
|
|
Loading…
Reference in New Issue