Переглянути джерело

数据字典从缓存中拿

shiqian 4 роки тому
батько
коміт
b0a38fdf9a

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

@@ -132,6 +132,10 @@ public class ObjectUtils {
         return input != null && !input.isEmpty();
     }
 
+    public static boolean isEmpty(JSONObject input){
+        return !isNotEmpty(input);
+    }
+
     public static boolean isNotEmpty(JSONArray input){
         return input != null && !input.isEmpty();
     }

+ 17 - 6
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysDictDataServiceImpl.java

@@ -1,12 +1,15 @@
 package com.boman.system.service.impl;
 
-import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
 import com.boman.domain.SysDictData;
 import com.boman.system.mapper.SysDictDataMapper;
 import com.boman.system.service.ISysDictDataService;
+import com.boman.system.service.ISysDictTypeService;
 import com.boman.system.utils.DictUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * 字典 业务层处理
@@ -18,6 +21,8 @@ public class SysDictDataServiceImpl implements ISysDictDataService
 {
     @Autowired
     private SysDictDataMapper dictDataMapper;
+    @Resource
+    private ISysDictTypeService dictTypeService;
 
     /**
      * 根据条件分页查询字典数据
@@ -39,9 +44,15 @@ public class SysDictDataServiceImpl implements ISysDictDataService
      * @return 字典标签
      */
     @Override
-    public String selectDictLabel(String dictType, String dictValue)
-    {
-        return dictDataMapper.selectDictLabel(dictType, dictValue);
+    public String selectDictLabel(String dictType, String dictValue) {
+        List<SysDictData> datas = dictTypeService.selectDictDataByType(dictType);
+        for (SysDictData data : datas) {
+            if (data.getDictValue().equalsIgnoreCase(dictValue)) {
+                return data.getDictLabel();
+            }
+        }
+
+        return null;
     }
 
     /**

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

@@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
 import java.util.*;
 import java.util.function.Consumer;
 
-import static com.boman.common.core.utils.obj.ObjectUtils.escapeStr;
+import static com.boman.common.core.utils.obj.ObjectUtils.*;
 import static com.boman.web.core.constant.FormDataConstant.*;
 
 /**
@@ -529,7 +529,7 @@ public interface StandardlyMapper {
             packCondition(packCondition, wholeSql);
 
             wholeSql.append(" order by ").append(orderBy).append(" limit ").append(limit);
-            if (ObjectUtils.isNotEmpty(offset)) {
+            if (isNotEmpty(offset)) {
                 wholeSql.append(", ").append(offset);
             }
 
@@ -542,13 +542,20 @@ public interface StandardlyMapper {
             JSONObject param = (JSONObject) para.get("param");
             String tableName = (String) para.get("tableName");
 
+            String result;
             StringBuilder wholeSql = new StringBuilder();
-            wholeSql.append("select * from ").append(tableName).append(" where ");
-            for (Map.Entry<String, Object> entry : param.entrySet()) {
-                wholeSql.append(entry.getKey()).append(" = ").append(entry.getValue()).append(" and ");
+            wholeSql.append("select * from ").append(tableName);
+            if (isEmpty(param)) {
+                result = wholeSql.toString();
+            } else {
+                wholeSql.append(" where ");
+                for (Map.Entry<String, Object> entry : param.entrySet()) {
+                    wholeSql.append(entry.getKey()).append(" = ").append(entry.getValue()).append(" and ");
+                }
+
+                result = StringUtils.substringBeforeLast(wholeSql.toString(), "and");
             }
 
-            String result = StringUtils.substringBeforeLast(wholeSql.toString(), "and");
             LOGGER.info("查询拼出的sql语句为:{}", result);
             return result;
         }
@@ -563,7 +570,7 @@ public interface StandardlyMapper {
             wholeSql.append("select ");
             // showData
             StringBuilder showDataSql = new StringBuilder();
-            if (ObjectUtils.isNotEmpty(showData)) {
+            if (isNotEmpty(showData)) {
                 for (String columnName : showData) {
                     showDataSql.append(columnName).append(", ");
                 }
@@ -609,7 +616,7 @@ public interface StandardlyMapper {
          * @param wholeSql      sql
          */
         private void packCondition(JSONObject packCondition, StringBuilder wholeSql) {
-            if (ObjectUtils.isNotEmpty(packCondition)) {
+            if (isNotEmpty(packCondition)) {
                 wholeSql.append(" where ");
                 StringBuilder conditionSql = new StringBuilder();
                 for (Map.Entry<String, Object> entry : packCondition.entrySet()) {