shiqian 4 lat temu
rodzic
commit
01334f0e22

+ 5 - 40
boman-api/boman-domain/src/main/java/com.boman.domain/dto/QueryBySqlDto.java

@@ -123,45 +123,6 @@ public class QueryBySqlDto {
                 + EQ + queryBySql.getDeputyTableName() + POINT + queryBySql.getDeputyTableNameRelKey();
     }
 
-    /**
-     * 功能描述: 传到mapper层,判断是否需要转义
-     *
-     * @param columns   columns
-     * @param condition condition
-     * @return com.alibaba.fastjson.JSONObject
-     */
-    public static JSONObject packLeftJoinCondition(List<GenTableColumn> columns, JSONObject condition) {
-        if (isEmpty(condition)) {
-            return condition;
-        }
-
-        JSONObject result = new JSONObject(columns.size());
-        for (Map.Entry<String, Object> entry : condition.entrySet()) {
-            String key = entry.getKey();
-            key = getColumnNameFromCondition(key);
-            Object value = entry.getValue();
-            for (GenTableColumn column : columns) {
-                if (!column.getColumnName().equalsIgnoreCase(key)) {
-                    continue;
-                }
-
-                // long string collection 暂时只作此三种类型判断
-                if (!isEmpty(value)) {
-                    // columnType 作为判断需不需要转义的一个标准,防止索引失效
-                    List<Object> objects = new ArrayList<>(3);
-                    objects.add(value);
-                    objects.add(column.getQueryType());
-                    objects.add(column.getColumnType());
-                    result.put(key, objects);
-                    break;
-                }
-            }
-        }
-
-        return result;
-    }
-
-
     /**
      * 功能描述: 表名.属性名  取出属性名
      *
@@ -173,7 +134,7 @@ public class QueryBySqlDto {
             throw new IllegalArgumentException("key为空");
         }
 
-        String[] split = key.split("\\.");
+        String[] split = key.split("\\$");
         assert split.length == 2;
         // split[0] 表名, split[1] 属性名
         return split[1].trim();
@@ -189,6 +150,10 @@ public class QueryBySqlDto {
         }
     }
 
+    public static String packColumn(String tableName, String columnName) {
+        return tableName + POINT + columnName;
+    }
+
 
     /******************************************************** get set ********************************************************/
 

+ 11 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/ObjController.java

@@ -384,4 +384,15 @@ public class ObjController {
         return AjaxResult.success(commonService.delete(dto));
     }
 
+    /**
+     * 功能描述: 通用修改数据
+     *
+     * @param dto dto
+     * @return int
+     */
+    @PostMapping("/insertList")
+    public AjaxResult insertList(@RequestBody InsertListDto dto) {
+        return AjaxResult.success(commonService.insertList(dto));
+    }
+
 }

+ 1 - 1
boman-web-core/src/main/java/com/boman/web/core/mapper/StandardMapper.java

@@ -85,7 +85,7 @@ public interface StandardMapper {
 
     /* ***************************************************** select ******************************************************/
     @Select("select max(${pkName}) from ${tableName}")
-    int selectMaxId(@Param("tableName") String tableName, @Param("pkName") String pkName);
+    Integer selectMaxId(@Param("tableName") String tableName, @Param("pkName") String pkName);
 
     /**
      * 功能描述: 根据id查所有

+ 1 - 1
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -329,7 +329,7 @@ public class TableServiceCmdService {
 
 
     /**
-     * 功能描述: 获取单表单数据
+     * 功能描述: 连表查询,目前两张表
      *
      * @param queryBySql queryBySql
      * @return com.boman.domain.dto.AjaxResult

+ 8 - 2
boman-web-core/src/main/java/com/boman/web/core/utils/ColumnUtils.java

@@ -379,13 +379,19 @@ public class ColumnUtils {
 
         JSONObject packColCondition = new JSONObject(columns.size());
         for (Map.Entry<String, Object> entry : condition.entrySet()) {
-            String columnName = QueryBySqlDto.getColumnNameFromCondition(entry.getKey());
+//            String columnName = QueryBySqlDto.getColumnNameFromCondition(entry.getKey());
+            String key = entry.getKey();
+            String[] split = key.split("\\$");
+            assert split.length == 2;
+            // split[0] 表名, split[1] 属性名
+            String columnName = split[1];
             Object value = entry.getValue();
             for (GenTableColumn column : columns) {
                 // long string collection 暂时只作此三种类型判断
                 if (column.getColumnName().equalsIgnoreCase(columnName) && ObjectUtils.isNotEmpty(value)) {
                     // columnType 作为判断需不需要转义的一个标准,防止索引失效
-                    packColCondition.put(entry.getKey(), Lists.newArrayList(value, column.getQueryType(), column.getColumnType()));
+                    String packColumn = QueryBySqlDto.packColumn(split[0], split[1]);
+                    packColCondition.put(packColumn, Lists.newArrayList(value, column.getQueryType(), column.getColumnType()));
                     break;
                 }
             }

+ 2 - 2
boman-web-core/src/main/java/com/boman/web/core/utils/IdUtils.java

@@ -32,8 +32,8 @@ public class IdUtils {
 
         // 查数据库
         StandardMapper mapper = SpringUtils.getBean(StandardMapper.class);
-        int maxId = mapper.selectMaxId(tableName, pkName);
-        if (maxId <= 0) {
+        Integer maxId = mapper.selectMaxId(tableName, pkName);
+        if (null == maxId || maxId <= 0) {
             maxId = 1;
             redisService.setCacheObject(sequencesKey, maxId);
         } else {