xiaofei пре 6 месеци
родитељ
комит
2ad779ab77

+ 5 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java

@@ -211,11 +211,16 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
         Long schoolId = requestUser.getSchoolId();
         Long requestUserId = requestUser.getId();
 
+        String studentCode = basicExamStudentParam.getStudentCode();
         String paperNumber = basicExamStudentParam.getPaperNumber();
         String teacherName = basicExamStudentParam.getTeacherName();
         String teacherCode = basicExamStudentParam.getTeacherCode();
         String paperType = basicExamStudentParam.getPaperType();
 
+        if(StringUtils.isNotBlank(studentCode) && !studentCode.matches(SystemConstant.REGULAR_EXPRESSION_OF_STUDENT_CODE)){
+            throw ExceptionResultEnum.ERROR.exception("学号只能由字母、数字组成");
+        }
+
         Long teacherId = null;
         if (SystemConstant.strNotNull(teacherCode) && !SystemConstant.strNotNull(teacherName)) {
             errorMsgList.add("任课老师必填");

+ 11 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/ImportLogicServiceImpl.java

@@ -202,6 +202,11 @@ public class ImportLogicServiceImpl implements ImportLogicService {
 //                }
             });
 
+            // 学号校验
+            if (StringUtils.isNotBlank(basicExamStudent.getStudentCode()) && !basicExamStudent.getStudentCode().matches(SystemConstant.REGULAR_EXPRESSION_OF_STUDENT_CODE)) {
+                stringJoiner.add("学号只能由字母、数字组成");
+            }
+
             if (ExamModelEnum.MODEL4.equals(basicExam.getExamModel())) {
                 if (basicExamStudent.getPaperType() == null) {
                     basicExamStudent.setPaperType(SystemConstant.DEFAULT_PAPER_TYPE_A);
@@ -610,6 +615,12 @@ public class ImportLogicServiceImpl implements ImportLogicService {
                     stringJoiner.add(m.getName() + "必填");
                 }
             });
+
+            // 学号校验
+            if (StringUtils.isNotBlank(basicExamStudent.getStudentCode()) && !basicExamStudent.getStudentCode().matches(SystemConstant.REGULAR_EXPRESSION_OF_STUDENT_CODE)) {
+                stringJoiner.add("学号只能由字母、数字组成");
+            }
+
             // 校验任课老师,都填或者都不填
             if (StringUtils.isNotBlank(basicExamStudentImport.getTeacherCode()) && StringUtils.isBlank(basicExamStudentImport.getTeacherName())) {
                 stringJoiner.add(RequiredFieldsEnum.TEACHER_NAME.getName() + "必填");

+ 2 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

@@ -321,7 +321,7 @@ public class SystemConstant {
     //    public static final int MAX_RETRY_CREATE_PDF_COUNT = 5;
     //英文字母、数字、中文括号、英文括号、下划线(_)、减号(-)、中文横线(—)
     public static final String REGULAR_EXPRESSION_OF_CODE = "[a-zA-Z0-9](\\w+)?-?(\\w+)?—?(\\w+)?(\\((\\w+)?-?(\\w+)?—?(\\w+)?\\))?(\\((\\w+)?-?(\\w+)?—?(\\w+)?\\))?(\\w+)?";
-    //    public static final String REGULAR_EXPRESSION_OF_CODE1 = "^[a-zA-Z0-9]+$";
+    public static final String REGULAR_EXPRESSION_OF_STUDENT_CODE = "^[a-zA-Z0-9]+$";
     public static final String REGULAR_EXPRESSION_OF_PHONE = "((\\d{3,4})|(\\(\\d{3,4}\\)-))?\\d{7,8}";
     public static final String REGULAR_EXPRESSION_OF_CODE_PRIMARY_DIMENSION = "[A-Z]";
     public static final String REGULAR_EXPRESSION_OF_CODE_SECOND_DIMENSION = "[A-Z][1-9][0-9]*";
@@ -1154,7 +1154,7 @@ public class SystemConstant {
      * @throws Exception
      */
     public static JSONObject createZip(File zipFile, String zipLocalRootPath, String zipDirName, String password) throws Exception {
-        if(StringUtils.isBlank(password)){
+        if (StringUtils.isBlank(password)) {
             password = SystemConstant.ZIP_ENCRYPT_PWD;
         }
         FileStoreUtil fileStoreUtil = SpringContextHolder.getBean(FileStoreUtil.class);