瀏覽代碼

增加创建者id跟更改者id

侯茂昌 1 年之前
父節點
當前提交
47b2662e2d

+ 3 - 9
ruoyi-admin/src/main/java/com/ruoyi/web/controller/dragForm/CommonController.java

@@ -71,16 +71,9 @@ public class CommonController extends BaseController {
      */
     @GetMapping("/getTableList")
     public TableDataInfo queryTableList(CommonEntity commonEntity) throws TenantDataSource {
-        DragTable dragTable = new DragTable();
-        dragTable.setTableKey(commonEntity.getQueryMap().get("tableKey").toString());
-        String sqlKey = dragTableService.selectDragTableList(dragTable).get(0).getSqlKey();
-        TableSql tableSql = iTableSqlService.selectTableSqlByTSqlKey(sqlKey);
+        TableSql tableSql = iTableSqlService.selectTableSqlByTSqlKey(commonEntity.getQueryMap().get("sqlkey").toString());
         startPage();  // 校验是否sqlserver 否执行 是执行另一种方式的分页
-        Map<String, Object> map = new HashMap<>();
-        map.put("sqlkey", sqlKey);
-        commonEntity.setQueryMap(map);
         return getDataTable(commonService.queryTableList(commonEntity, tableSql));
-
     }
 
 
@@ -89,7 +82,8 @@ public class CommonController extends BaseController {
      */
     @GetMapping("/dragTableInfo")
     public AjaxResult dragTableInfo(CommonEntity commonEntity) {
-        return AjaxResult.success(dragTableService.dragTableInfo(commonEntity.getQueryMap().get("sqlkey").toString()));
+        //根据tableKey查询sqlKey
+        return AjaxResult.success(dragTableService.dragTableInfo(commonEntity.getQueryMap().get("tableKey").toString()));
     }
 
     /**

+ 2 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/dragForm/DragTableController.java

@@ -29,6 +29,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
 @RestController
 @RequestMapping("/system/table")
 public class DragTableController extends BaseController {
+
     @Autowired
     private IDragTableService dragTableService;
 
@@ -102,7 +103,7 @@ public class DragTableController extends BaseController {
         //新增动态表格信息
         dragTableService.addDragTable(dragTableVo);
         //新增动态表格样式
-        dragTableStyleService.batchInsertDragTableStyle(dragTableVo);
+        //dragTableStyleService.batchInsertDragTableStyle(dragTableVo);
         return AjaxResult.success();
     }
 

+ 16 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/dragForm/DragTableGroupController.java

@@ -7,7 +7,9 @@ import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.system.entity.DragTableGroup;
+import com.ruoyi.system.entity.vo.DragTableGroupVo;
 import com.ruoyi.system.service.IDragTableGroupService;
+import com.ruoyi.system.service.impl.DragTableServiceImpl;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +32,8 @@ public class DragTableGroupController extends BaseController {
     @Autowired
     private IDragTableGroupService dragTableGroupService;
 
+
+
     /**
      * 查询拖拽格组列表
      */
@@ -71,13 +75,22 @@ public class DragTableGroupController extends BaseController {
     /**
      * 新增拖拽格组
      */
-    @PreAuthorize("@ss.hasPermi('system:group:add')")
+    //@PreAuthorize("@ss.hasPermi('system:group:add')")
+    //@Log(title = "拖拽格组", businessType = BusinessType.INSERT)
+    //@PostMapping
+    //@ApiOperation(value = "新增拖拽格组")
+    //public AjaxResult add(@RequestBody DragTableGroup dragTableGroup)
+    //{
+    //    return toAjax(dragTableGroupService.insertDragTableGroup(dragTableGroup));
+    //}
+
+    //@PreAuthorize("@ss.hasPermi('system:group:add')")
     @Log(title = "拖拽格组", businessType = BusinessType.INSERT)
     @PostMapping
     @ApiOperation(value = "新增拖拽格组")
-    public AjaxResult add(@RequestBody DragTableGroup dragTableGroup)
+    public AjaxResult add(@RequestBody DragTableGroupVo dragTableGroupVo)
     {
-        return toAjax(dragTableGroupService.insertDragTableGroup(dragTableGroup));
+        return toAjax(dragTableGroupService.insertDragTableGroup(dragTableGroupVo));
     }
 
     /**

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/entity/DragTableGroup.java

@@ -25,7 +25,7 @@ public class DragTableGroup extends BaseEntity {
     @Excel(name = "表格组描述")
     private String groupDescription;
 
-    /** 存放表格联动信息 */
+    /** 存放表格联动信息 {tablekey:dfasdfa,顺序:1} */
     @Excel(name = "存放表格联动信息")
     private String groupTableInfo;
 

+ 77 - 0
ruoyi-system/src/main/java/com/ruoyi/system/entity/vo/DragTableGroupVo.java

@@ -0,0 +1,77 @@
+package com.ruoyi.system.entity.vo;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+import java.util.List;
+
+/**
+ * @author hmc
+ * @date 2023-11-03 15:55
+ * @Description:
+ */
+public class DragTableGroupVo extends BaseEntity {
+
+    /** 主键 */
+    private Long id;
+    /** 表格组名称 */
+    private String groupName;
+
+    /** 表格组描述 */
+    private String groupDescription;
+
+    /** 存放表格联动信息 [{tablekey:kh123,顺序:1},{tablekey:kh123,顺序:2}] */
+    private String groupTableInfo;
+
+    //动态表格实体类集合
+    public List<DragTableVo> dragTables;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getGroupName() {
+        return groupName;
+    }
+
+    public void setGroupName(String groupName) {
+        this.groupName = groupName;
+    }
+
+    public String getGroupDescription() {
+        return groupDescription;
+    }
+
+    public void setGroupDescription(String groupDescription) {
+        this.groupDescription = groupDescription;
+    }
+
+    public String getGroupTableInfo() {
+        return groupTableInfo;
+    }
+
+    public void setGroupTableInfo(String groupTableInfo) {
+        this.groupTableInfo = groupTableInfo;
+    }
+
+    public List<DragTableVo> getDragTables() {
+        return dragTables;
+    }
+
+    public void setDragTables(List<DragTableVo> dragTables) {
+        this.dragTables = dragTables;
+    }
+
+    @Override
+    public String toString() {
+        return "DragTableGroupVo{" +
+                "id=" + id +
+                ", groupName='" + groupName + '\'' +
+                ", groupDescription='" + groupDescription + '\'' +
+                ", groupTableInfo='" + groupTableInfo + '\'' +
+                ", dragTables=" + dragTables +
+                "} " + super.toString();
+    }
+}

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/DragTableGroupMapper.java

@@ -1,6 +1,7 @@
 package com.ruoyi.system.mapper;
 
 import com.ruoyi.system.entity.DragTableGroup;
+import com.ruoyi.system.entity.vo.DragTableGroupVo;
 
 import java.util.List;
 

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/DragTableMapper.java

@@ -73,4 +73,9 @@ public interface DragTableMapper
      * 获取动态表单详情
      */
     DragTableVo selectDragTableVoByTId(Long tId);
+
+    /**
+     * 获取动态表单详情
+     */
+    DragTable selectDragTableSqlKeyByTableKey(String tableKey);
 }

+ 3 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/IDragTableGroupService.java

@@ -1,6 +1,7 @@
 package com.ruoyi.system.service;
 
 import com.ruoyi.system.entity.DragTableGroup;
+import com.ruoyi.system.entity.vo.DragTableGroupVo;
 
 import java.util.List;
 
@@ -30,10 +31,10 @@ public interface IDragTableGroupService {
     /**
      * 新增拖拽格组
      *
-     * @param dragTableGroup 拖拽格组
+     * @param dragTableGroupVo 拖拽格组
      * @return 结果
      */
-    public int insertDragTableGroup(DragTableGroup dragTableGroup);
+    public int insertDragTableGroup(DragTableGroupVo dragTableGroupVo);
 
     /**
      * 修改拖拽格组

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IDragTableService.java

@@ -89,4 +89,9 @@ public interface IDragTableService
      * 删除动态表格信息
      */
     void deleteDragTable(List<Long> tIds,List<String> sqlKeys);
+
+    /**
+     * 根据tableKey查询sqlKey
+     */
+    DragTable selectSqlKeyByTableKey(String tableKey);
 }

+ 23 - 4
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DragTableGroupServiceImpl.java

@@ -1,11 +1,17 @@
 package com.ruoyi.system.service.impl;
 
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.system.entity.DragTable;
 import com.ruoyi.system.entity.DragTableGroup;
+import com.ruoyi.system.entity.vo.DragTableGroupVo;
+import com.ruoyi.system.entity.vo.DragTableVo;
 import com.ruoyi.system.mapper.DragTableGroupMapper;
+import com.ruoyi.system.mapper.DragTableMapper;
 import com.ruoyi.system.service.IDragTableGroupService;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -21,6 +27,12 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
     @Autowired
     private DragTableGroupMapper dragTableGroupMapper;
 
+    @Autowired
+    private DragTableMapper dragTableMapper;
+
+    @Autowired
+    private DragTableServiceImpl dragTableService;
+
     /**
      * 查询拖拽格组
      *
@@ -48,16 +60,23 @@ public class DragTableGroupServiceImpl implements IDragTableGroupService {
     /**
      * 新增拖拽格组
      *
-     * @param dragTableGroup 拖拽格组
+     * @param dragTableGroupVo 拖拽格组
      * @return 结果
      */
     @Override
-    public int insertDragTableGroup(DragTableGroup dragTableGroup)
+    @Transactional(rollbackFor = Exception.class)
+    public int insertDragTableGroup(DragTableGroupVo dragTableGroupVo)
     {
-        dragTableGroup.setCreateTime(DateUtils.getNowDate());
+        //表格组实体类拷贝数据
+        DragTableGroup dragTableGroup=new DragTableGroup();
+        BeanUtils.copyProperties(dragTableGroupVo,dragTableGroup);
+        //添加动态表格列表
+        List<DragTableVo> dragTables = dragTableGroupVo.getDragTables();
+        dragTables.forEach(item->{
+            dragTableService.addDragTable(item);
+        });
         return dragTableGroupMapper.insertDragTableGroup(dragTableGroup);
     }
-
     /**
      * 修改拖拽格组
      *

+ 11 - 4
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DragTableServiceImpl.java

@@ -126,11 +126,12 @@ public class DragTableServiceImpl implements IDragTableService {
     }
 
     @Override
-    public CommonEntity dragTableInfo(String sqlKey) {
-        DragTable dragTable = dragTableMapper.selectDragTableBySqlKey(sqlKey);
+    public CommonEntity dragTableInfo(String tableKey) {
+        //DragTable dragTable = dragTableMapper.selectDragTableBySqlKey(sqlKey);
+        DragTable dragTable = dragTableMapper.selectDragTableSqlKeyByTableKey(tableKey);
         Map<String, Object> resultMap = new HashMap<>();
         resultMap.put("template", dragTable);
-//        resultMap.put("where",dragTableConditionMapper.selectDragTableConditionByTid(dragTable.gettId()));
+        //resultMap.put("where",dragTableConditionMapper.selectDragTableConditionByTid(dragTable.gettId()));
         List<DragTableCondition> dragTableConditions = dragTableConditionMapper.selectDragTableConditionByTid(dragTable.gettId());
         dragTableConditions.forEach(d -> {
             // 0 查询字典 1 查询表数据
@@ -141,7 +142,8 @@ public class DragTableServiceImpl implements IDragTableService {
             }
         });
         resultMap.put("where", dragTableConditions);
-        resultMap.put("querySql", tableSqlMapper.selectTableSqlByTSqlKey(sqlKey));
+        //resultMap.put("querySql", tableSqlMapper.selectTableSqlByTSqlKey(sqlKey));
+        resultMap.put("querySql", tableSqlMapper.selectTableSqlByTSqlKey(dragTable.getSqlKey()));
         // 表格样式信息
         DragTableStyle dragTableStyle = new DragTableStyle();
         dragTableStyle.setTableKey(dragTable.getTableKey());
@@ -319,4 +321,9 @@ public class DragTableServiceImpl implements IDragTableService {
         //delete drag_table_condition
         dragTableConditionMapper.deleteDragTableConditionBytIds(tIds);
     }
+
+    @Override
+    public DragTable selectSqlKeyByTableKey(String tableKey) {
+        return dragTableMapper.selectDragTableSqlKeyByTableKey(tableKey);
+    }
 }