Pārlūkot izejas kodu

根据表名和自定义字段查找 通用接口

shiqian 4 gadi atpakaļ
vecāks
revīzija
de3d8da3ae

+ 3 - 0
boman-api/boman-domain/src/main/java/com.boman.domain/constant/TableNameConst.java

@@ -10,4 +10,7 @@ public class TableNameConst {
     public static final String ID = "id";
 
     public static final String SYS_ROLE_MENU = "sys_role_menu";
+
+    /** 发文表 ***/
+    public static final String BOMAN_MESSAGE = "boman_message";
 }

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

@@ -3,6 +3,7 @@ package com.boman.web.core.controller;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.domain.dto.FormDataDto;
 import com.boman.web.core.service.TableServiceCmdService;
+import com.boman.web.core.service.common.ICommonService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -22,6 +23,8 @@ public class ObjController {
 
     @Autowired
     private TableServiceCmdService tableServiceCmdService;
+    @Autowired
+    private ICommonService commonService;
 
     /**
      * 功能描述: 通用保存接口
@@ -304,5 +307,15 @@ public class ObjController {
         return tableServiceCmdService.objectSubmit(condition, false);
     }
 
+    /**
+     * 功能描述: 根据表名和自定义字段查找
+     *
+     * @param dto dto
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @PostMapping("/one/map")
+    public AjaxResult getOneByMap(@RequestBody FormDataDto dto) {
+        return AjaxResult.success(commonService.getOneByMap(dto.getTable(), dto.getFixedData()));
+    }
 
 }

+ 9 - 9
boman-web-core/src/main/java/com/boman/web/core/mapper/StandardlyMapper.java

@@ -267,7 +267,7 @@ public interface StandardlyMapper {
 
                 sql.WHERE(pkName + " in (" + inSql.toString());
                 String wholeSql = StringUtils.substringBeforeLast(sql.toString(), ",") + "))";
-                LOGGER.info("更改的sql语句为: {}, \r\n 更改的数据为: {}", wholeSql, model);
+                LOGGER.info("更改的sql语句为: {} \r\n 更改的数据为: {}", wholeSql, model);
                 return wholeSql;
             } else {
                 throw new IllegalArgumentException("model 无效");
@@ -345,7 +345,7 @@ public interface StandardlyMapper {
                 }
 
                 String sqlStr = sql.toString();
-                LOGGER.info("新增的sql语句为: {}, \r\n 新增的数据为: {}", sqlStr, model);
+                LOGGER.info("新增的sql语句为: {} \r\n 新增的数据为: {}", sqlStr, model);
                 return sqlStr;
             }
         }
@@ -379,7 +379,7 @@ public interface StandardlyMapper {
             }
 
             String sqlStr = stringBuilder.toString();
-            LOGGER.info("批量新增的sql语句为: {}, \r\n 新增的数据为: {}", sqlStr, dataList);
+            LOGGER.info("批量新增的sql语句为: {} \r\n 新增的数据为: {}", sqlStr, dataList);
             return sqlStr;
         }
 
@@ -408,7 +408,7 @@ public interface StandardlyMapper {
 
             wholeSql.setCharAt(wholeSql.length() - 1, ')');
             String sqlStr = wholeSql.toString();
-            LOGGER.info("批量更新的sql语句为: {}, \r\n 更改的数据为: {}, \r\n idList: {}", sqlStr, models, idList);
+            LOGGER.info("批量更新的sql语句为: {} \r\n 更改的数据为: {} \r\n idList: {}", sqlStr, models, idList);
             return sqlStr;
 
         }
@@ -468,7 +468,7 @@ public interface StandardlyMapper {
 
                 sql.setCharAt(sql.length() - 1, ')');
                 String sqlStr = sql.toString();
-                LOGGER.info("删除的sql语句为: {}, \r\n idList: {}", sqlStr, ids);
+                LOGGER.info("删除的sql语句为: {} \r\n idList: {}", sqlStr, ids);
                 return sqlStr;
             }
         }
@@ -615,7 +615,7 @@ public interface StandardlyMapper {
             }
 
             String result = wholeSql.toString();
-            LOGGER.info("查询拼出的sql语句为:{}, \r\n selectByCondition 查询条件: {}", result, packCondition);
+            LOGGER.info("查询拼出的sql语句为:{} \r\n selectByCondition 查询条件: {}", result, packCondition);
             return result;
         }
 
@@ -637,7 +637,7 @@ public interface StandardlyMapper {
             }
 
             result = limitOne ? result + " limit 1" : result;
-            LOGGER.info("查询拼出的sql语句为:{}, \r\n getByMap 查询条件: {}", result, condition);
+            LOGGER.info("查询拼出的sql语句为: {} \r\n getByMap 查询条件: {}", result, condition);
             return result;
         }
 
@@ -669,7 +669,7 @@ public interface StandardlyMapper {
 
             wholeSql.setCharAt(wholeSql.length() - 1, ')');
             String sqlStr = wholeSql.toString();
-            LOGGER.info("查询拼出的sql语句为:{}, \r\n selectByIdList idList: {}", sqlStr, idList);
+            LOGGER.info("查询拼出的sql语句为:{} \r\n selectByIdList idList: {}", sqlStr, idList);
             return sqlStr;
         }
 
@@ -685,7 +685,7 @@ public interface StandardlyMapper {
             packCondition(packCondition, wholeSql);
 
             String result = wholeSql.toString();
-            LOGGER.info("查询count拼出的sql语句为:{}, \r\n countByCondition 查询条件: {}", result, packCondition);
+            LOGGER.info("查询count拼出的sql语句为: {} \r\n countByCondition 查询条件: {}", result, packCondition);
             return result;
         }
 

+ 16 - 1
boman-web-core/src/main/java/com/boman/web/core/service/select/BaseSelectServiceImpl.java

@@ -10,6 +10,7 @@ import com.boman.domain.dto.FormDataDto;
 import com.boman.web.core.mapper.StandardlyMapper;
 import com.boman.web.core.service.TableServiceCmdService;
 import com.boman.web.core.utils.ColumnUtils;
+import com.boman.web.core.utils.HandlerFormDataUtils;
 import com.google.common.collect.Lists;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -21,6 +22,7 @@ import java.util.Map;
 
 import static com.boman.common.core.utils.obj.ObjectUtils.isEmpty;
 import static com.boman.common.core.utils.obj.ObjectUtils.requireNonNull;
+import static com.boman.web.core.utils.HandlerFormDataUtils.*;
 
 /**
  * @author shiqian
@@ -70,7 +72,14 @@ public class BaseSelectServiceImpl implements IBaseSelectService {
         GenTable gent = cmdService.getTableFromRedisByTableName(RedisKey.TABLE_INFO, tableName);
         ColumnUtils.checkColumn(param, gent.getColumns());
         JSONObject packColCondition = ColumnUtils.packColCondition(gent.getColumns(), param);
-        return mapper.getByMap(tableName, param, packColCondition, false);
+        List<JSONObject> result = mapper.getByMap(tableName, param, packColCondition, false);
+
+        handleBlob(result, gent.getIsContainsBlob());
+        handleDateTimeForQueryList(result, gent.getColumns());
+        handleDictForQueryList(result, gent.getColumns());
+        handleFkForQueryList(result, gent.getColumns());
+
+        return result;
     }
 
 
@@ -90,6 +99,12 @@ public class BaseSelectServiceImpl implements IBaseSelectService {
         ColumnUtils.checkColumn(param, gent.getColumns());
         JSONObject packColCondition = ColumnUtils.packColCondition(gent.getColumns(), param);
         List<JSONObject> result = mapper.getByMap(tableName, param, packColCondition, true);
+
+        handleBlob(result, gent.getIsContainsBlob());
+        handleDateTimeForQueryList(result, gent.getColumns());
+        handleDictForQueryList(result, gent.getColumns());
+        handleFkForQueryList(result, gent.getColumns());
+
         return isEmpty(result) ? null : result.get(0);
     }