fix(用例管理): 导入成员类型自定义字段问题
--bug=1039660 --user=王旭 【用例管理】功能用例-Excel导入-有成员字段-导入的Excel提示填写ID或邮箱-事实上现在用户没有ID,并且输入邮箱导入也成功不了,现在输入用户姓名可以导入成功 https://www.tapd.cn/55049933/s/1500724
This commit is contained in:
parent
ceaca62faf
commit
6426d1429d
|
@ -33,7 +33,7 @@ public class CustomFieldMemberValidator extends AbstractCustomFieldValidator {
|
|||
);
|
||||
userNameMap = new HashMap<>();
|
||||
memberOption.stream()
|
||||
.forEach(user -> userNameMap.put(user.getName().toLowerCase(), user.getId()));
|
||||
.forEach(user -> userNameMap.put(user.getEmail().toLowerCase(), user.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1153,7 +1153,7 @@ public class FunctionalCaseService {
|
|||
caseBlobMapper.insertSelective(caseBlob);
|
||||
|
||||
//自定义字段
|
||||
List<FunctionalCaseCustomField> customFields = handleImportCustomField(functionalCaseExcelData, caseId, customFieldMapper, customFieldsMap);
|
||||
List<FunctionalCaseCustomField> customFields = handleImportCustomField(functionalCaseExcelData, caseId, customFieldMapper, customFieldsMap, userId);
|
||||
|
||||
caseIds.add(functionalCase.getId());
|
||||
historyLogDTOS.add(new FunctionalCaseHistoryLogDTO(functionalCase, caseBlob, customFields, new ArrayList<>(), new ArrayList<>()));
|
||||
|
@ -1181,7 +1181,7 @@ public class FunctionalCaseService {
|
|||
* @param customFieldMapper 自定义字段mapper
|
||||
* @param customFieldsMap 当前默认模板的自定义字段
|
||||
*/
|
||||
private List<FunctionalCaseCustomField> handleImportCustomField(FunctionalCaseExcelData functionalCaseExcelData, String caseId, FunctionalCaseCustomFieldMapper customFieldMapper, Map<String, TemplateCustomFieldDTO> customFieldsMap) {
|
||||
private List<FunctionalCaseCustomField> handleImportCustomField(FunctionalCaseExcelData functionalCaseExcelData, String caseId, FunctionalCaseCustomFieldMapper customFieldMapper, Map<String, TemplateCustomFieldDTO> customFieldsMap, String userId) {
|
||||
List<FunctionalCaseCustomField> customFields = new ArrayList<>();
|
||||
//需要保存的自定义字段
|
||||
Map<String, Object> customData = functionalCaseExcelData.getCustomData();
|
||||
|
@ -1199,6 +1199,13 @@ public class FunctionalCaseService {
|
|||
}, () -> {
|
||||
setCustomFieldValue(v.getDefaultValue(), caseCustomField);
|
||||
});
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(v.getType(), CustomFieldType.MEMBER.name()) && caseCustomField.getValue().contains("CREATE_USER")) {
|
||||
caseCustomField.setValue(userId);
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(v.getType(), CustomFieldType.MULTIPLE_MEMBER.name()) && caseCustomField.getValue().contains("CREATE_USER")) {
|
||||
caseCustomField.setValue(caseCustomField.getValue().replace("CREATE_USER", userId));
|
||||
}
|
||||
customFields.add(caseCustomField);
|
||||
customFieldMapper.insertSelective(caseCustomField);
|
||||
});
|
||||
|
@ -1339,7 +1346,7 @@ public class FunctionalCaseService {
|
|||
caseBlobMapper.updateByPrimaryKeyWithBLOBs(caseBlob);
|
||||
|
||||
//自定义字段
|
||||
List<FunctionalCaseCustomField> customFields = handleUpdateCustomField(functionalCaseExcelData, functionalCase.getId(), customFieldMapper, customFieldsMap);
|
||||
List<FunctionalCaseCustomField> customFields = handleUpdateCustomField(functionalCaseExcelData, functionalCase.getId(), customFieldMapper, customFieldsMap, userId);
|
||||
|
||||
// 记录新值
|
||||
historyLogDTOS.add(new FunctionalCaseHistoryLogDTO(functionalCase, caseBlob, customFields, new ArrayList<>(), new ArrayList<>()));
|
||||
|
@ -1359,11 +1366,11 @@ public class FunctionalCaseService {
|
|||
}
|
||||
}
|
||||
|
||||
private List<FunctionalCaseCustomField> handleUpdateCustomField(FunctionalCaseExcelData functionalCaseExcelData, String caseId, FunctionalCaseCustomFieldMapper customFieldMapper, Map<String, TemplateCustomFieldDTO> customFieldsMap) {
|
||||
private List<FunctionalCaseCustomField> handleUpdateCustomField(FunctionalCaseExcelData functionalCaseExcelData, String caseId, FunctionalCaseCustomFieldMapper customFieldMapper, Map<String, TemplateCustomFieldDTO> customFieldsMap, String userId) {
|
||||
FunctionalCaseCustomFieldExample fieldExample = new FunctionalCaseCustomFieldExample();
|
||||
fieldExample.createCriteria().andCaseIdEqualTo(caseId);
|
||||
customFieldMapper.deleteByExample(fieldExample);
|
||||
List<FunctionalCaseCustomField> customFields = handleImportCustomField(functionalCaseExcelData, caseId, customFieldMapper, customFieldsMap);
|
||||
List<FunctionalCaseCustomField> customFields = handleImportCustomField(functionalCaseExcelData, caseId, customFieldMapper, customFieldsMap, userId);
|
||||
return customFields;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
<select id="getProjectUserList" resultType="io.metersphere.system.domain.User">
|
||||
SELECT distinct
|
||||
u.id,
|
||||
u.NAME
|
||||
u.NAME,
|
||||
u.email
|
||||
FROM `user` u
|
||||
LEFT JOIN user_role_relation urr ON u.id = urr.user_id
|
||||
WHERE urr.source_id = #{sourceId}
|
||||
|
|
Loading…
Reference in New Issue