Bladeren bron

表单设计对接

chenc 3 jaren geleden
bovenliggende
commit
3fade89f2d

+ 25 - 0
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/mapper/TbTableInfoMapper.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.activiti.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.jeecg.modules.activiti.entity.TbTableInfo;
 import java.util.List;
@@ -11,4 +12,28 @@ import java.util.Map;
 public interface TbTableInfoMapper extends BaseMapper<TbTableInfo> {
     @Select("select * from tb_table_info")
     List<Map> getList();
+
+    @Select("SELECT TABLE_NAME as tableName,TABLE_COMMENT as tableComment FROM INFORMATION_SCHEMA.TABLES  WHERE TABLE_SCHEMA = 'jeecg-boot'")
+    List<Map<String,Object>> getTableList();
+
+    /**
+    * @Author chenchuang
+    * @Description //TODO 通过表明获取主表字段
+    * @Date 2021/7/9 16:54
+    * @Param [tableName]
+    * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
+    */
+    @Select("select  COLUMN_NAME as columnName, column_comment as columnComment from information_schema.columns where table_name =#{tableName}")
+    List<Map<String,Object>> getTableColumnList(@Param("tableName") String tableName);
+
+    /**
+    * @Author chenchuang
+    * @Description //TODO 通过主表外键名称获取子表字段
+    * @Date 2021/7/9 16:53
+    * @Param [tableItemPrantId]
+    * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
+    */
+    @Select("select  COLUMN_NAME as columnName, column_comment as columnComment from information_schema.columns where table_name in (\n" +
+            "SELECT a.table_name FROM information_schema.columns as a WHERE column_name=#{tableItemPrantId})")
+    List<Map<String,Object>> getTableItemColumnList(@Param("tableItemPrantId") String tableItemPrantId);
 }

+ 4 - 0
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/service/ITbTableInfoService.java

@@ -7,4 +7,8 @@ import java.util.Map;
 
 public interface ITbTableInfoService  extends IService<TbTableInfo> {
     List<Map> getList();
+
+    List<Map<String,Object>> getTableList();
+
+    List<Map<String,Object>> getTableColumnList( String tableName);
 }

+ 4 - 2
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/service/Impl/ActBusinessServiceImpl.java

@@ -194,8 +194,10 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
 
 
                             for (String filed : fileds2) {
-                                filedIdB.append(",`"+filed+"`");
-                                filedIdVB.append(",'"+jobj.getString(filed)+"'");
+                                if(!filed.equals("sort")&&!filed.equals("id")&&!filed.equals(tableName+"_id")&&!(jobj.getString(filed)==null||jobj.getString(filed).equals("null"))){
+                                    filedIdB.append(",`"+filed+"`");
+                                    filedIdVB.append(",'"+jobj.getString(filed)+"'");
+                                }
                             }
 
                             //排序

+ 18 - 0
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/service/Impl/TbTableInfoServiceImpl.java

@@ -6,6 +6,8 @@ import org.jeecg.modules.activiti.mapper.TbTableInfoMapper;
 import org.jeecg.modules.activiti.service.ITbTableInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 
@@ -18,4 +20,20 @@ public class TbTableInfoServiceImpl extends ServiceImpl<TbTableInfoMapper, TbTab
     public List<Map> getList() {
         return tbTableInfoMapper.getList();
     }
+
+    @Override
+    public List<Map<String,Object>> getTableList() {
+        return tbTableInfoMapper.getTableList();
+    }
+
+    @Override
+    public List<Map<String, Object>> getTableColumnList(String tableName) {
+        List<Map<String, Object>> tableColumnList=tbTableInfoMapper.getTableColumnList(tableName);
+        List<Map<String, Object>> tableItemColumnList=tbTableInfoMapper.getTableItemColumnList(tableName+"_id");
+        tableColumnList.addAll(tableItemColumnList);
+        HashSet h = new HashSet(tableColumnList);
+        tableColumnList.clear();
+        tableColumnList.addAll(h);
+        return tableColumnList;
+    }
 }

+ 2 - 2
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/ActBusinessController.java

@@ -109,7 +109,7 @@ public class ActBusinessController {
                 for(int i = 0; i < tableNamesChidArr.length; i++){
                     list = actBusinessService.getChildList(tableId, tableNamesChidArr[i], tableName+"_id");
                     int j = i+1;
-                    applyForm.put("childList"+ j + "&" +tableName, list);
+                    applyForm.put("child&" +tableNamesChidArr[i], list);
                 }
             }
             return Result.ok(applyForm);
@@ -123,7 +123,7 @@ public class ActBusinessController {
                 for(int i = 0; i < tableNamesChidArr.length; i++){
                     list = actBusinessService.getChildList(tableId, tableNamesChidArr[i], tableName+"_id");
                     int j = i+1;
-                    applyForm.put("childList"+ j + "&" +tableName, list);
+                    applyForm.put("child&" +tableNamesChidArr[i], list);
                 }
 
             }

+ 44 - 5
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/TbTableInfoController.java

@@ -10,14 +10,11 @@ import org.jeecg.modules.activiti.entity.TbTableInfo;
 import org.jeecg.modules.activiti.service.ITbTableInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/tbTableInfo")
@@ -73,4 +70,46 @@ public class TbTableInfoController {
             tableInfo.setJsonContent(obj);
         return Result.ok(tableInfo);
     }
+
+    /**
+    * @Author chenchuang
+    * @Description //TODO 获取表名和表注释
+    * @Date 2021/7/1 13:44
+    * @Param []
+    * @return org.jeecg.common.api.vo.Result<java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>
+    */
+    @GetMapping("/getTableList")
+    public Result<List<Map<String,Object>>> getTableList(){
+        Result<List<Map<String,Object>>> result=new Result<>();
+        try {
+            List<Map<String,Object>> list=tbTableInfoService.getTableList();
+            result.success("操作成功");
+            result.setResult(list);
+        } catch (Exception e) {
+            result.error500("操作失败");
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    /**
+    * @Author chenchuang
+    * @Description //TODO 根据表明获取字段名称以及字段说明
+    * @Date 2021/7/1 15:22
+    * @Param [tableName]
+    * @return org.jeecg.common.api.vo.Result<java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>
+    */
+    @GetMapping("getTableColumnList")
+    public Result<List<Map<String,Object>>> getTableColumnList(String tableName){
+        Result<List<Map<String,Object>>> result=new Result<>();
+        try {
+            List<Map<String,Object>> list=tbTableInfoService.getTableColumnList(tableName);
+            result.success("操作成功");
+            result.setResult(list);
+        } catch (Exception e) {
+            result.error500("操作失败");
+            e.printStackTrace();
+        }
+        return result;
+    }
 }