refactor(系统设置): 类名优化
This commit is contained in:
parent
4192b7dfe5
commit
86581e4580
|
@ -6,7 +6,7 @@ import lombok.Data;
|
|||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class CustomFieldDao extends CustomField implements Serializable {
|
||||
public class CustomFieldDTO extends CustomField implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -4,7 +4,7 @@ package io.metersphere.system.resolver.field;
|
|||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
@ -20,13 +20,13 @@ public abstract class AbstractCustomFieldResolver {
|
|||
* @param customField
|
||||
* @param value
|
||||
*/
|
||||
abstract public void validate(CustomFieldDao customField, Object value);
|
||||
abstract public void validate(CustomFieldDTO customField, Object value);
|
||||
|
||||
protected void throwValidateException(String name) {
|
||||
throw new MSException(FIELD_VALIDATE_ERROR, Translator.getWithArgs(FIELD_VALIDATE_ERROR.getMessage(), name));
|
||||
}
|
||||
|
||||
protected void validateRequired(CustomFieldDao customField, Object value) {
|
||||
protected void validateRequired(CustomFieldDTO customField, Object value) {
|
||||
if (!customField.getRequired()) {
|
||||
return;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public abstract class AbstractCustomFieldResolver {
|
|||
}
|
||||
}
|
||||
|
||||
protected void validateArrayRequired(CustomFieldDao customField, Object value) {
|
||||
protected void validateArrayRequired(CustomFieldDTO customField, Object value) {
|
||||
if (!customField.getRequired()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@ package io.metersphere.system.resolver.field;
|
|||
|
||||
|
||||
import io.metersphere.sdk.util.DateUtils;
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class CustomFieldDateResolver extends AbstractCustomFieldResolver {
|
||||
|
||||
@Override
|
||||
public void validate(CustomFieldDao customField, Object value) {
|
||||
public void validate(CustomFieldDTO customField, Object value) {
|
||||
validateRequired(customField, value);
|
||||
validateString(customField.getName(), value);
|
||||
try {
|
||||
|
|
|
@ -2,13 +2,13 @@ package io.metersphere.system.resolver.field;
|
|||
|
||||
|
||||
import io.metersphere.sdk.util.DateUtils;
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class CustomFieldDateTimeResolver extends AbstractCustomFieldResolver {
|
||||
|
||||
@Override
|
||||
public void validate(CustomFieldDao customField, Object value) {
|
||||
public void validate(CustomFieldDTO customField, Object value) {
|
||||
validateRequired(customField, value);
|
||||
try {
|
||||
if (value != null && StringUtils.isNotBlank(value.toString())) {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package io.metersphere.system.resolver.field;
|
||||
|
||||
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
|
||||
public class CustomFieldFloatResolver extends AbstractCustomFieldResolver {
|
||||
|
||||
@Override
|
||||
public void validate(CustomFieldDao customField, Object value) {
|
||||
public void validate(CustomFieldDTO customField, Object value) {
|
||||
validateRequired(customField, value);
|
||||
if (value != null && !(value instanceof Number)) {
|
||||
throwValidateException(customField.getName());
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package io.metersphere.system.resolver.field;
|
||||
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
|
||||
public class CustomFieldIntegerResolver extends AbstractCustomFieldResolver {
|
||||
@Override
|
||||
public void validate(CustomFieldDao customField, Object value) {
|
||||
public void validate(CustomFieldDTO customField, Object value) {
|
||||
validateRequired(customField, value);
|
||||
if (value != null && !(value instanceof Integer)) {
|
||||
throwValidateException(customField.getName());
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package io.metersphere.system.resolver.field;
|
||||
|
||||
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
|
||||
public class CustomFieldMemberResolver extends AbstractCustomFieldResolver {
|
||||
|
||||
@Override
|
||||
public void validate(CustomFieldDao customField, Object value) {
|
||||
public void validate(CustomFieldDTO customField, Object value) {
|
||||
validateRequired(customField, value);
|
||||
validateString(customField.getName(), value);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ package io.metersphere.system.resolver.field;
|
|||
|
||||
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
|
||||
public class CustomFieldMultipleMemberResolver extends CustomFieldMemberResolver {
|
||||
|
||||
@Override
|
||||
public void validate(CustomFieldDao customField, Object value) {
|
||||
public void validate(CustomFieldDTO customField, Object value) {
|
||||
validateArrayRequired(customField, value);
|
||||
validateArray(customField.getName(), value);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package io.metersphere.system.resolver.field;
|
|||
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.domain.CustomFieldOption;
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -12,7 +12,7 @@ import java.util.stream.Collectors;
|
|||
public class CustomFieldMultipleSelectResolver extends CustomFieldSelectResolver {
|
||||
|
||||
@Override
|
||||
public void validate(CustomFieldDao customField, Object value) {
|
||||
public void validate(CustomFieldDTO customField, Object value) {
|
||||
validateArrayRequired(customField, value);
|
||||
validateArray(customField.getName(), value);
|
||||
List<CustomFieldOption> options = getOptions(customField.getId());
|
||||
|
|
|
@ -2,13 +2,13 @@ package io.metersphere.system.resolver.field;
|
|||
|
||||
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
|
||||
public class CustomFieldMultipleTextResolver extends AbstractCustomFieldResolver {
|
||||
|
||||
|
||||
@Override
|
||||
public void validate(CustomFieldDao customField, Object value) {
|
||||
public void validate(CustomFieldDTO customField, Object value) {
|
||||
validateArrayRequired(customField, value);
|
||||
validateArray(customField.getName(), value);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package io.metersphere.system.resolver.field;
|
|||
|
||||
import io.metersphere.sdk.util.CommonBeanFactory;
|
||||
import io.metersphere.system.domain.CustomFieldOption;
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
import io.metersphere.system.service.BaseCustomFieldOptionService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
@ -14,7 +14,7 @@ import java.util.stream.Collectors;
|
|||
public class CustomFieldSelectResolver extends AbstractCustomFieldResolver {
|
||||
|
||||
@Override
|
||||
public void validate(CustomFieldDao customField, Object value) {
|
||||
public void validate(CustomFieldDTO customField, Object value) {
|
||||
validateRequired(customField, value);
|
||||
if (value == null) {
|
||||
return;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package io.metersphere.system.resolver.field;
|
||||
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
|
||||
public class CustomFieldTextResolver extends AbstractCustomFieldResolver {
|
||||
|
||||
@Override
|
||||
public void validate(CustomFieldDao customField, Object value) {
|
||||
public void validate(CustomFieldDTO customField, Object value) {
|
||||
validateRequired(customField, value);
|
||||
validateString(customField.getName(), value);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import io.metersphere.sdk.util.BeanUtils;
|
|||
import io.metersphere.system.domain.CustomField;
|
||||
import io.metersphere.system.domain.TemplateCustomField;
|
||||
import io.metersphere.system.domain.TemplateCustomFieldExample;
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
import io.metersphere.system.dto.sdk.request.TemplateCustomFieldRequest;
|
||||
import io.metersphere.system.mapper.TemplateCustomFieldMapper;
|
||||
import io.metersphere.system.resolver.field.AbstractCustomFieldResolver;
|
||||
|
@ -106,11 +106,11 @@ public class BaseTemplateCustomFieldService {
|
|||
private String parseDefaultValue(TemplateCustomFieldRequest field) {
|
||||
CustomField customField = baseCustomFieldService.getWithCheck(field.getFieldId());
|
||||
AbstractCustomFieldResolver customFieldResolver = CustomFieldResolverFactory.getResolver(customField.getType());
|
||||
CustomFieldDao customFieldDao = BeanUtils.copyBean(new CustomFieldDao(), customField);
|
||||
customFieldDao.setRequired(false);
|
||||
CustomFieldDTO customFieldDTO = BeanUtils.copyBean(new CustomFieldDTO(), customField);
|
||||
customFieldDTO.setRequired(false);
|
||||
if (BooleanUtils.isNotFalse(validateDefaultValue.get())) {
|
||||
// 创建项目时不校验默认值
|
||||
customFieldResolver.validate(customFieldDao, field.getDefaultValue());
|
||||
customFieldResolver.validate(customFieldDTO, field.getDefaultValue());
|
||||
}
|
||||
return customFieldResolver.parse2String(field.getDefaultValue());
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import io.metersphere.sdk.constants.TemplateScene;
|
|||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.system.domain.CustomField;
|
||||
import io.metersphere.system.dto.CustomFieldDao;
|
||||
import io.metersphere.system.dto.CustomFieldDTO;
|
||||
import io.metersphere.system.dto.sdk.request.CustomFieldOptionRequest;
|
||||
import io.metersphere.system.resolver.field.AbstractCustomFieldResolver;
|
||||
import io.metersphere.system.resolver.field.CustomFieldResolverFactory;
|
||||
|
@ -129,8 +129,8 @@ public class BaseCustomFieldTestService {
|
|||
|
||||
AbstractCustomFieldResolver customFieldResolver = CustomFieldResolverFactory.getResolver(customFieldType.name());
|
||||
CustomField customField = getCustomFields().get(customFieldType);
|
||||
CustomFieldDao customFieldDao = BeanUtils.copyBean(new CustomFieldDao(), customField);
|
||||
customFieldDao.setRequired(true);
|
||||
CustomFieldDTO customFieldDTO = BeanUtils.copyBean(new CustomFieldDTO(), customField);
|
||||
customFieldDTO.setRequired(true);
|
||||
String valueStr = customFieldResolver.parse2String(objectValueMap.get(customFieldType));
|
||||
Object objectValue = customFieldResolver.parse2Value(valueStr);
|
||||
// 校验 parse2String 和 parse2Value 是否正确
|
||||
|
@ -157,8 +157,8 @@ public class BaseCustomFieldTestService {
|
|||
private void invokeValidate(Map<CustomFieldType, Object> valueMap, CustomFieldType customFieldType) {
|
||||
AbstractCustomFieldResolver customFieldResolver = CustomFieldResolverFactory.getResolver(customFieldType.name());
|
||||
CustomField customField = getCustomFields().get(customFieldType);
|
||||
CustomFieldDao customFieldDao = BeanUtils.copyBean(new CustomFieldDao(), customField);
|
||||
customFieldDao.setRequired(true);
|
||||
customFieldResolver.validate(customFieldDao, valueMap.get(customFieldType));
|
||||
CustomFieldDTO customFieldDTO = BeanUtils.copyBean(new CustomFieldDTO(), customField);
|
||||
customFieldDTO.setRequired(true);
|
||||
customFieldResolver.validate(customFieldDTO, valueMap.get(customFieldType));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue