Selaa lähdekoodia

objselect 还在构造

shiqian 4 vuotta sitten
vanhempi
commit
9aef4952de

+ 7 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/obj/ObjectUtils.java

@@ -54,6 +54,13 @@ public class ObjectUtils {
         return input;
     }
 
+    public static int requireNonNull(int input) {
+        if (input <= 0) {
+            throw new IllegalArgumentException("所传参数为空");
+        }
+        return input;
+    }
+
 
     public static JSONObject requireNonNull(JSONObject input) {
         if (input == null || input.isEmpty()) {

+ 10 - 0
boman-modules/boman-system/src/main/java/com/boman/system/common/FormDataConstant.java

@@ -10,4 +10,14 @@ public class FormDataConstant {
      * 删除数据时,需要删除的业务表的主键
      */
     public static final String ID_LIST = "idList";
+
+    /**
+     * 查询的条件
+     */
+    public static final String CONDITION = "condition";
+
+    /**
+     * 查询后需要返回到前台的字段
+     */
+    public static final String SHOW_DATA = "showData";
 }

+ 28 - 2
boman-modules/boman-system/src/main/java/com/boman/system/common/TableServiceCmdService.java

@@ -1,10 +1,10 @@
 package com.boman.system.common;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.boman.common.core.utils.StringUtils;
 import com.boman.common.core.utils.collection.CollectionUtils;
-import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.common.redis.RedisKey;
 import com.boman.common.redis.service.RedisService;
 import com.boman.gen.domain.GenTable;
@@ -20,7 +20,9 @@ import org.springframework.stereotype.Component;
 import java.util.Arrays;
 import java.util.List;
 
-import static  com.boman.common.core.utils.obj.ObjectUtils.*;
+import static com.boman.common.core.utils.obj.ObjectUtils.requireNonNull;
+import static com.boman.common.core.utils.obj.ObjectUtils.requiredNonNull;
+import static com.boman.system.common.FormDataConstant.*;
 
 /**
  * @author shiqian
@@ -111,4 +113,28 @@ public class TableServiceCmdService {
         return ValueHolder.ok(rowResult);
     }
 
+    /**
+     * 功能描述: 获取单表单数据
+     *
+     * @param condition condition
+     * @return com.boman.system.common.ValueHolder
+     */
+    public ValueHolder<RowResult> getObject(BaseTableSaveDTO dto) {
+        requireNonNull(dto.getTable());
+
+        // 拿到每个字段对应的查询类型,是 = 或者 like 或者 > 或者 <
+        GenTable genTable = redisService.getCacheObject(RedisKey.TABLE_INFO + requireNonNull(dto.getTable()));
+        requireNonNull(genTable);
+        JSONObject fixedData = dto.getFixedData();
+        requireNonNull(fixedData);
+        // 查询条件
+        JSONObject condition = fixedData.getJSONObject(CONDITION);
+        // 需要返回到前台的列
+        JSONArray showData = fixedData.getJSONArray(SHOW_DATA);
+
+
+
+
+        return ValueHolder.ok("");
+    }
 }

+ 12 - 0
boman-modules/boman-system/src/main/java/com/boman/system/controller/ObjController.java

@@ -60,6 +60,18 @@ public class ObjController {
         return tableServiceCmdService.objectLogicDelete(baseTableSaveDTO);
     }
 
+    /**
+     * 功能描述: 获取单表单数据
+     *
+     * @param condition condition
+     * @return com.boman.system.common.ValueHolder
+     */
+    @ApiOperation(value = "获取单表单数据")
+    @PostMapping("/getObject")
+    public ValueHolder<RowResult> getObject(@RequestBody BaseTableSaveDTO condition) {
+        return tableServiceCmdService.getObject(condition);
+    }
+
 
 
 }

+ 40 - 0
boman-modules/boman-system/src/main/java/com/boman/system/mapper/StandardlyMapper.java

@@ -1,6 +1,7 @@
 package com.boman.system.mapper;
 
 import com.alibaba.fastjson.JSONObject;
+import com.boman.common.core.utils.obj.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.annotations.*;
 import org.apache.ibatis.annotations.Param;
@@ -85,6 +86,25 @@ public interface StandardlyMapper {
     @Select("select max(${pkName}) from ${tableName}")
     Long selectMaxId(@Param("tableName") String tableName, @Param("pkName") String pkName);
 
+    /**
+     * 功能描述: 自定义查询,需要查询的字段和value都在condition中
+     *
+     * @param tableName tableName
+     * @param condition condition
+     * @param limit     分页
+     * @param offset    分页
+     * @return java.util.List<com.alibaba.fastjson.JSONObject>
+     */
+    @SelectProvider(type = StandardlyMapper.SqlProvider.class, method = "selectByCondition")
+    List<JSONObject> selectByCondition(@Param("tableName") String tableName
+            , @Param("condition") JSONObject condition
+            , @Param("showData") JSONObject showData
+            , @Param("limit") int limit
+            , @Param("offset") int offset);
+
+
+
+
     public static class SqlProvider {
         static final String[] READONLY_COLUMNS = new String[]{"OWNERID", "OWNERNAME", "OWNERENAME", "CREATIONDATE", "ID"};
 
@@ -383,5 +403,25 @@ public interface StandardlyMapper {
                 throw new IllegalArgumentException("model 无效");
             }
         }
+
+//        @Param("tableName") String tableName, @Param("condition") JSONObject condition, @Param("limit") int limit, @Param("offset") int offset
+        public String selectByCondition(Map<String, Object> para) {
+            JSONObject condition = (JSONObject) para.get("condition");
+            ObjectUtils.requireNonNull(condition);
+            String tableName = (String) para.get("tableName");
+            ObjectUtils.requireNonNull(tableName);
+            int limit = (int) para.get("limit");
+            ObjectUtils.requireNonNull(limit);
+            int offset = (int) para.get("offset");
+            ObjectUtils.requireNonNull(offset);
+
+            StringBuilder sql = new StringBuilder();
+            sql.append("select ");
+
+
+
+
+            return "";
+        }
     }
 }