Ver Fonte

objectTab

shiqian há 4 anos atrás
pai
commit
d2d25efbd1

+ 5 - 0
boman-common/boman-common-redis/src/main/java/com/boman/common/redis/RedisKey.java

@@ -22,4 +22,9 @@ public class RedisKey {
      * eg: relation:tableName
      */
     public static final String RELATION = "relation:";
+
+    /**
+     * gen_table_relation中的数据存到redis中的key
+     */
+    public static final String RELATION_INFO = "relation:info";
 }

+ 7 - 3
boman-modules/boman-gen/src/main/java/com/boman/gen/controller/MyController.java

@@ -58,11 +58,13 @@ public class MyController extends BaseController {
         requiredNonNull(genTableColumns);
         packTableAndInsertToRedis(tableList, genTableColumns);
 
-        // load tableRelation
         List<GenTableRelation> relationList = genTableRelationService.selectGenTableRelationList(new GenTableRelation());
         requiredNonNull(relationList);
-        packRelationAndInsertToRedis(tableList, relationList);
+        // load gen_table_relation表数据到redis
+        redisService.setCacheObject(RedisKey.RELATION_INFO, relationList, 12L, TimeUnit.DAYS);
 
+        // load tableRelation
+        packRelationAndInsertToRedis(tableList, relationList, genTableColumns);
         return AjaxResult.success(tableList);
     }
 
@@ -72,13 +74,15 @@ public class MyController extends BaseController {
      * @param tableList    tableList
      * @param relationList 主表和附表的关联信息
      */
-    private void packRelationAndInsertToRedis(List<GenTable> tableList, List<GenTableRelation> relationList) {
+    private void packRelationAndInsertToRedis(List<GenTable> tableList, List<GenTableRelation> relationList
+            , List<GenTableColumn> tableColumns) {
         for (GenTable table : tableList) {
             List<GenTable> tableListTemp = new ArrayList<>(16);
             for (GenTableRelation relation : relationList) {
                 if (relation.getRelationParentId().equals(table.getTableId())) {
                     Long childId = relation.getRelationChildId();
                     // 存了附表的建表信息和表的所有字段信息
+                    // todo
                     List<GenTable> collect = tableList.stream()
                             .filter(genTable -> genTable.getTableId().equals(childId))
                             .collect(Collectors.toList());

+ 36 - 17
boman-modules/boman-system/src/main/java/com/boman/system/common/TableServiceCmdService.java

@@ -11,8 +11,9 @@ import com.boman.common.redis.service.RedisService;
 import com.boman.gen.controller.MyController;
 import com.boman.gen.domain.GenTable;
 import com.boman.gen.domain.GenTableColumn;
+import com.boman.gen.domain.GenTableRelation;
+import com.boman.gen.service.IGenTableColumnService;
 import com.boman.system.domain.SysDictData;
-import com.boman.system.mapper.StandardlyMapper;
 import com.boman.system.service.*;
 import com.boman.system.utils.IdUtils;
 import com.google.common.collect.Lists;
@@ -54,6 +55,8 @@ public class TableServiceCmdService {
     private  RestTemplate restTemplate;
     @Resource
     private  ISysDictTypeService dictTypeService;
+    @Resource
+    private IGenTableColumnService tableColumnService;
 
     private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);
 
@@ -264,6 +267,12 @@ public class TableServiceCmdService {
         ArrayList<GenTableColumn> queryList = Lists.newArrayListWithCapacity(16);
         for (GenTableColumn column : columns) {
             if (GenTableColumn.IS_QUERY.equalsIgnoreCase(column.getIsQuery())) {
+                String dictType = column.getDictType();
+                if (ObjectUtils.isNotEmpty(dictType)) {
+                    List<SysDictData> sysDictData1 = dictTypeService.selectDictDataByType(dictType);
+                    column.setSysDictData(coverSysDictDataToJSONObject(sysDictData1));
+                }
+
                 queryList.add(column);
             }
         }
@@ -280,21 +289,6 @@ public class TableServiceCmdService {
         return AjaxResult.success(jsonObject);
     }
 
-    /**
-     * 功能描述: 封装查询条件,在拼sql的时候按照此规则去取值
-     * {@link StandardlyMapper.SqlProvider#selectByCondition(java.util.Map)}
-     *
-     * @param value      查询的值
-     * @param queryType  queryType
-     * @param columnType columnType
-     * @return java.lang.String
-     */
-    public String packValue(String value, String queryType, String columnType) {
-        requireNonNull(value);
-        requireNonNull(queryType);
-        return value + "_" + queryType + "_" + columnType;
-    }
-
     /**
      * 功能描述: 获取表单子表
      *
@@ -307,9 +301,13 @@ public class TableServiceCmdService {
         List<GenTable> childTableList = genTable.getRelationList();
         // 此表没有关联子表,查啥查
         requireNonNull(childTableList);
-
+        // todo
         for (GenTable childTable : childTableList) {
             String childTableName = childTable.getTableName();
+            Long childTableTableId = childTable.getTableId();
+            List<GenTableColumn> childColumns = childTable.getColumns();
+            //  column_name = 先根据tableName查到id,再用id到relation中查到relation_child_id, 在用这个值去到tableColumn中查到column_name
+            // select * from childTableName where column_name = objId
 
 
         }
@@ -318,6 +316,27 @@ public class TableServiceCmdService {
         return AjaxResult.success();
     }
 
+    public String getChildColumnNameByParentTableName(GenTable parentGenTable, Long childTableTableId){
+        requireNonNull(parentGenTable.getTableName(), "主表名称为空");
+//        GenTable primaryTable = redisService.getCacheObject(RedisKey.TABLE_INFO + genTable.getTableName());
+        Long parentTableId = parentGenTable.getTableId();
+        List<GenTableRelation> relations = redisService.getCacheObject(RedisKey.RELATION_INFO);
+        relations = relations.stream()
+                .filter(relation -> relation.getRelationParentId().equals(parentTableId))
+                .collect(Collectors.toList());
+
+        for (GenTableRelation relation : relations) {
+            if (relation.getRelationChildId().equals(6L)) {
+                tableColumnService.selectGenTableColumnListByTableId(childTableTableId);
+//                return
+            }
+        }
+
+
+        return "";
+
+    }
+
     /**
      * 功能描述: 表单提交接口
      *