dzx il y a 1 an
Parent
commit
c1cad9102c

+ 9 - 4
src/main/java/com/xjrsoft/module/textbook/controller/TextbookController.java

@@ -247,9 +247,12 @@ public class TextbookController {
     @SaCheckPermission("textbook:add")
     public RT<Boolean> add(@Valid @RequestBody AddTextbookDto dto) throws ParseException {
         String publishingDateStr = dto.getPublishingDate();
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         Textbook textbook = BeanUtil.toBean(dto, Textbook.class);
-        textbook.setPublishingDate(sdf.parse(publishingDateStr));
+        if(publishingDateStr != null && !"".equals(publishingDateStr)){
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            textbook.setPublishingDate(sdf.parse(publishingDateStr));
+        }
+
         boolean isSuccess = textbookService.add(textbook);
         return RT.ok(isSuccess);
     }
@@ -259,9 +262,11 @@ public class TextbookController {
     @SaCheckPermission("textbook:edit")
     public RT<Boolean> update(@Valid @RequestBody UpdateTextbookDto dto) throws ParseException {
         String publishingDateStr = dto.getPublishingDate();
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         Textbook textbook = BeanUtil.toBean(dto, Textbook.class);
-        textbook.setPublishingDate(sdf.parse(publishingDateStr ));
+        if(publishingDateStr != null && !"".equals(publishingDateStr)){
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            textbook.setPublishingDate(sdf.parse(publishingDateStr));
+        }
         return RT.ok(textbookService.update(textbook));
 
     }