|
@@ -1,14 +1,19 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
|
|
import com.ruoyi.system.entity.DragForm;
|
|
|
+import com.ruoyi.system.entity.DragTableForm;
|
|
|
import com.ruoyi.system.mapper.DragFormMapper;
|
|
|
+import com.ruoyi.system.mapper.DragTableFormMapper;
|
|
|
import com.ruoyi.system.service.IDragFormService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
import java.io.FileWriter;
|
|
|
import java.io.IOException;
|
|
@@ -28,6 +33,9 @@ public class DragFormServiceImpl implements IDragFormService {
|
|
|
@Autowired
|
|
|
private DragFormMapper dragFormMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private DragTableFormMapper dragTableFormMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询动态表单
|
|
|
*
|
|
@@ -59,14 +67,29 @@ public class DragFormServiceImpl implements IDragFormService {
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertDragForm(DragForm dragForm) {
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult insertDragForm(DragForm dragForm) {
|
|
|
String fileName = RuoYiConfig.getProfile() + UUID.randomUUID().toString() + ".html";
|
|
|
// 创建表单源文件
|
|
|
createForm(fileName, dragForm.getDfHtmlTemplate());
|
|
|
// 使用租户名 加uuid 定义表单文件名称
|
|
|
dragForm.setDfFliePath(fileName);
|
|
|
dragForm.setCreateTime(DateUtils.getNowDate());
|
|
|
- return dragFormMapper.insertDragForm(dragForm);
|
|
|
+
|
|
|
+ //校验dtId是否唯一
|
|
|
+ if(dragTableFormMapper.selectDtIdCount(dragForm.getDtId()) > 0){
|
|
|
+ return AjaxResult.warn("该表格已绑定表单!");
|
|
|
+ }
|
|
|
+ //新增表单
|
|
|
+ dragFormMapper.insertDragForm(dragForm);
|
|
|
+
|
|
|
+
|
|
|
+ //新增关联表
|
|
|
+ DragTableForm dragTableForm = new DragTableForm();
|
|
|
+ dragTableForm.setDfId(Long.valueOf(dragFormMapper.selectDragFormFId()));
|
|
|
+ dragTableForm.setDtId(dragForm.getDtId());
|
|
|
+ dragTableFormMapper.insertDragTableForm(dragTableForm);
|
|
|
+ return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
/**
|