wangliang пре 4 година
родитељ
комит
770ce5328b

+ 0 - 17
themis-business/src/main/java/com/qmth/themis/business/annotation/ExcelNotNull.java

@@ -1,17 +0,0 @@
-package com.qmth.themis.business.annotation;
-
-import java.lang.annotation.*;
-
-/**
- * @Description: excel字段不为空注解
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2020/7/19
- */
-@Documented
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ExcelNotNull {
-
-}

+ 5 - 5
themis-business/src/main/java/com/qmth/themis/business/dto/ExamStudentImportDto.java

@@ -1,8 +1,8 @@
 package com.qmth.themis.business.dto;
 
-import com.qmth.themis.business.annotation.ExcelNotNull;
 import com.qmth.themis.business.annotation.ExcelNote;
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 /**
@@ -14,19 +14,19 @@ import java.io.Serializable;
  */
 public class ExamStudentImportDto implements Serializable {
 
-    @ExcelNotNull
+    @NotNull
     @ExcelNote(value = "姓名")
     private String name; //姓名
 
-    @ExcelNotNull
+    @NotNull
     @ExcelNote(value = "证件号")
     private String identity; //证件号
 
-    @ExcelNotNull
+    @NotNull
     @ExcelNote(value = "科目代码")
     private String courseCode; //科目代码
 
-    @ExcelNotNull
+    @NotNull
     @ExcelNote(value = "科目名称")
     private String courseName; //科目名称
 

+ 6 - 7
themis-business/src/main/java/com/qmth/themis/business/dto/RoomCodeExportDto.java

@@ -1,15 +1,14 @@
 package com.qmth.themis.business.dto;
 
-import com.qmth.themis.business.annotation.ExcelNotNull;
 import com.qmth.themis.business.annotation.ExcelNote;
 
 /**
-* @Description: 考场导出 dto
-* @Param:  
-* @return:  
-* @Author: wangliang
-* @Date: 2020/7/20 
-*/ 
+ * @Description: 考场导出 dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/7/20
+ */
 public class RoomCodeExportDto {
 
     @ExcelNote(value = "考场代码")

+ 3 - 3
themis-business/src/main/java/com/qmth/themis/business/dto/RoomCodeImportDto.java

@@ -1,8 +1,8 @@
 package com.qmth.themis.business.dto;
 
-import com.qmth.themis.business.annotation.ExcelNotNull;
 import com.qmth.themis.business.annotation.ExcelNote;
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 /**
@@ -14,11 +14,11 @@ import java.io.Serializable;
  */
 public class RoomCodeImportDto implements Serializable {
 
-    @ExcelNotNull
+    @NotNull
     @ExcelNote(value = "考场代码")
     private String roomCode; //考场代码
 
-    @ExcelNotNull
+    @NotNull
     @ExcelNote(value = "考场名称")
     private String roomName; //考场名称
 

+ 4 - 4
themis-business/src/main/java/com/qmth/themis/business/util/ExcelUtil.java

@@ -1,6 +1,5 @@
 package com.qmth.themis.business.util;
 
-import com.qmth.themis.business.annotation.ExcelNotNull;
 import com.qmth.themis.business.annotation.ExcelNote;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
@@ -13,6 +12,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.LinkedMultiValueMap;
 
+import javax.validation.constraints.NotNull;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
@@ -83,7 +83,7 @@ public class ExcelUtil {
                                         if (j < fields.length - 1) {
                                             fields[j].setAccessible(true);
                                             fields[j].set(o, obj);
-                                            Annotation annotation = fields[j].getAnnotation(ExcelNotNull.class);
+                                            Annotation annotation = fields[j].getAnnotation(NotNull.class);
                                             ExcelNote note = fields[j].getAnnotation(ExcelNote.class);
                                             if (Objects.isNull(obj) && Objects.nonNull(annotation)) {
                                                 excelErrorList.add(y, new ExcelError(j + 1, "excel第" + (y + 1) + "个sheet第" + (j + 1) + "行[" + note.value() + "]为空"));
@@ -106,7 +106,7 @@ public class ExcelUtil {
                                     } else {
                                         fields[j].setAccessible(true);
                                         fields[j].set(o, obj);
-                                        Annotation annotation = fields[j].getAnnotation(ExcelNotNull.class);
+                                        Annotation annotation = fields[j].getAnnotation(NotNull.class);
                                         ExcelNote note = fields[j].getAnnotation(ExcelNote.class);
                                         if (Objects.isNull(obj) && Objects.nonNull(annotation)) {
                                             excelErrorList.add(y, new ExcelError(i + 1, "excel第" + (y + 1) + "个sheet第" + (i + 1) + "行[" + note.value() + "]为空"));
@@ -195,7 +195,7 @@ public class ExcelUtil {
         for (int i = 0; i < fields.length; i++) {
             Field field = fields[i];
             field.setAccessible(true);
-            Annotation annotation = field.getAnnotation(ExcelNotNull.class);
+            Annotation annotation = field.getAnnotation(NotNull.class);
             ExcelNote note = field.getAnnotation(ExcelNote.class);
             if (Objects.isNull(field.get(obj)) && Objects.nonNull(annotation)) {
                 excelErrorList.add(new ExcelError(index + 1, "excel第" + (sheetIndex + 1) + "个sheet第" + (index + 1) + "行[" + note.value() + "]为空"));