Jelajahi Sumber

1.导入学生添加生日格式校验

yuanliang 1 tahun lalu
induk
melakukan
30334c64b5

+ 8 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java

@@ -59,6 +59,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.text.MessageFormat;
+import java.text.ParseException;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
@@ -438,6 +439,13 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
             if (!subjectNames.contains(student.getSubjectName())) {
                 errMsg.add(String.format("第%s行声部不支持", msgRowNo));
             }
+            try {
+                if(!StringUtils.isEmpty(student.getBirthday())){
+                    LocalDate.parse(student.getBirthday(), DateTimeFormatter.ISO_LOCAL_DATE);
+                }
+            }catch (Exception e) {
+                errMsg.add(String.format("第%s行生日格式错误", msgRowNo));
+            }
 
             if (errMsg.size() > 100) {
                 break;