Browse Source

表单配置模块bug修复

dzx 1 year ago
parent
commit
b38efa05c0

+ 5 - 1
src/main/java/com/xjrsoft/module/form/service/impl/FormExecuteServiceImpl.java

@@ -872,6 +872,11 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
 
     @Transactional
     public Long insertFormData(Map<String, Object> formData, FormTemplate template) {
+        for (Map.Entry<String, Object> entry : formData.entrySet()) {
+            if (entry.getValue().toString().isEmpty()) {
+                entry.setValue(null);
+            }
+        }
         String formJson = template.getFormJson();
         //自定义表单配置
         FormDesignConfig formDesignConfig = JSONUtil.toBean(formJson, FormDesignConfig.class);
@@ -901,7 +906,6 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
             List<String> autoCodeList = new ArrayList<>();
             // 处理字段值
             Map<String, Object> toSaveFormData = handleFormDataForSave(formData, formDesignConfig, tableName, autoCodeList);
-
             //formData 默认插入雪花Id主键
             if (pk.isPresent()) {
                 formData.put(pk.get().getName(), keyValue);

+ 14 - 3
src/main/java/com/xjrsoft/module/textbook/controller/TextbookController.java

@@ -37,8 +37,14 @@ import javax.validation.Valid;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.text.ParseException;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -239,8 +245,11 @@ public class TextbookController {
     @PostMapping
     @ApiOperation(value = "新增教材管理")
     @SaCheckPermission("textbook:add")
-    public RT<Boolean> add(@Valid @RequestBody AddTextbookDto dto){
+    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));
         boolean isSuccess = textbookService.add(textbook);
         return RT.ok(isSuccess);
     }
@@ -248,9 +257,11 @@ public class TextbookController {
     @PutMapping
     @ApiOperation(value = "修改教材管理")
     @SaCheckPermission("textbook:edit")
-    public RT<Boolean> update(@Valid @RequestBody UpdateTextbookDto dto){
-
+    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 ));
         return RT.ok(textbookService.update(textbook));
 
     }

+ 1 - 1
src/main/java/com/xjrsoft/module/textbook/dto/AddTextbookDto.java

@@ -141,7 +141,7 @@ public class AddTextbookDto implements Serializable {
 
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @ApiModelProperty("出版日期")
-    private LocalDate publishingDate;
+    private String publishingDate;
 
     @ApiModelProperty("分类号")
     private String category;