fix: 用例导入tag表头为空导入失败
This commit is contained in:
parent
6446024cf8
commit
2b5483dc23
|
@ -0,0 +1,9 @@
|
|||
package io.metersphere.excel.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
public @interface NotRequired {
|
||||
}
|
|
@ -2,6 +2,7 @@ package io.metersphere.excel.domain;
|
|||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import io.metersphere.excel.annotation.NotRequired;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
|
@ -40,6 +41,7 @@ public class TestCaseExcelDataCn extends TestCaseExcelData {
|
|||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("标签")
|
||||
@NotRequired
|
||||
@Length(min = 0, max = 1000)
|
||||
private String tags;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.excel.domain;
|
|||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import io.metersphere.excel.annotation.NotRequired;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
|
@ -38,6 +39,12 @@ public class TestCaseExcelDataTw extends TestCaseExcelData {
|
|||
@Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}")
|
||||
private String priority;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("標簽")
|
||||
@NotRequired
|
||||
@Length(min = 0, max = 1000)
|
||||
private String tags;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("測試方式")
|
||||
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.excel.domain;
|
|||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import io.metersphere.excel.annotation.NotRequired;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
|
@ -39,6 +40,12 @@ public class TestCaseExcelDataUs extends TestCaseExcelData {
|
|||
@Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}")
|
||||
private String priority;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("Tag")
|
||||
@NotRequired
|
||||
@Length(min = 0, max = 1000)
|
||||
private String tags;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("Method")
|
||||
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
|
||||
|
|
|
@ -6,15 +6,13 @@ import com.alibaba.excel.event.AnalysisEventListener;
|
|||
import com.alibaba.excel.exception.ExcelAnalysisException;
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.excel.annotation.NotRequired;
|
||||
import io.metersphere.excel.domain.ExcelErrData;
|
||||
import io.metersphere.excel.domain.TestCaseExcelData;
|
||||
import io.metersphere.excel.domain.UserExcelData;
|
||||
import io.metersphere.excel.utils.ExcelValidateHelper;
|
||||
import io.metersphere.i18n.Translator;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> {
|
||||
|
@ -131,7 +129,10 @@ public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> {
|
|||
for (String v : excelProperty.value()) {
|
||||
value.append(v);
|
||||
}
|
||||
result.add(value.toString());
|
||||
// 检查是否必有的头部信息
|
||||
if (field.getAnnotation(NotRequired.class) == null) {
|
||||
result.add(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
@setTreeNodes="setTreeNodes"
|
||||
@exportTestCase="exportTestCase"
|
||||
@saveAsEdit="editTestCase"
|
||||
@refreshAll="refreshAll"
|
||||
:type="'edit'"
|
||||
ref="nodeTree"
|
||||
/>
|
||||
|
|
|
@ -101,7 +101,6 @@ export default {
|
|||
this.$emit("refreshTable");
|
||||
},
|
||||
refreshAll() {
|
||||
this.selectRows.clear();
|
||||
this.$emit('refreshAll');
|
||||
},
|
||||
handleCommand(e) {
|
||||
|
|
Loading…
Reference in New Issue