fix 导入用户该维护人不存在

This commit is contained in:
chenjianxing 2020-06-12 13:46:46 +08:00
parent db7707708f
commit 82f7b44a03
1 changed files with 10 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.BeanUtils;
@ -64,6 +65,9 @@ public class TestCaseService {
@Resource
UserMapper userMapper;
@Resource
UserRoleMapper userRoleMapper;
public void addTestCase(TestCaseWithBLOBs testCase) {
testCase.setName(testCase.getName());
TestCaseExample testCaseExample = new TestCaseExample();
@ -196,10 +200,12 @@ public class TestCaseService {
.map(TestCase::getName)
.collect(Collectors.toSet());
UserExample userExample = new UserExample();
userExample.createCriteria().andLastWorkspaceIdEqualTo(currentWorkspaceId);
List<User> users = userMapper.selectByExample(userExample);
Set<String> userIds = users.stream().map(User::getId).collect(Collectors.toSet());
UserRoleExample userRoleExample = new UserRoleExample();
userRoleExample.createCriteria()
.andRoleIdIn(Arrays.asList(RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER))
.andSourceIdEqualTo(currentWorkspaceId);
Set<String> userIds = userRoleMapper.selectByExample(userRoleExample).stream().map(UserRole::getUserId).collect(Collectors.toSet());
EasyExcelListener easyExcelListener = null;
List<ExcelErrData<TestCaseExcelData>> errList = null;