Browse Source

Merge branch 'master' of http://192.168.101.10:13000/boman/boman-framwork

sr 4 years ago
parent
commit
24b150b938

+ 1 - 1
boman-api/boman-api-gen/pom.xml

@@ -22,11 +22,11 @@
             <groupId>com.boman</groupId>
             <artifactId>boman-common-core</artifactId>
         </dependency>
-
         <dependency>
             <groupId>com.boman</groupId>
             <artifactId>boman-modules-gen</artifactId>
             <version>2.5.0</version>
+            <scope>compile</scope>
         </dependency>
 
     </dependencies>

+ 2 - 1
boman-auth/src/main/resources/bootstrap-test.yml

@@ -15,6 +15,7 @@ spring:
       discovery:
         # 服务注册地址
         server-addr: 192.168.101.10:8848
+        namespace: 9690deba-607a-472c-9444-5a6a3b660db3
       config:
         # 配置中心地址
         server-addr: 192.168.101.10:8848
@@ -23,4 +24,4 @@ spring:
         # 共享配置
         shared-configs:
           - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
-        namespace: 9690deba-607a-472c-9444-5a6a3b660db3
+        namespace: 9690deba-607a-472c-9444-5a6a3b660db3

+ 1 - 0
boman-gateway/src/main/resources/bootstrap-test.yml

@@ -17,6 +17,7 @@ spring:
       discovery:
         # 服务注册地址
         server-addr: 192.168.101.10:8848
+        namespace: 9690deba-607a-472c-9444-5a6a3b660db3
       config:
         # 配置中心地址
         server-addr: 192.168.101.10:8848

+ 1 - 1
boman-modules/boman-file/src/main/java/com/boman/file/utils/FileUploadUtils.java

@@ -88,7 +88,7 @@ public class FileUploadUtils
     {
         String fileName = file.getOriginalFilename();
         String extension = getExtension(file);
-        fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
+        fileName = DateUtils.datePath() + "/" + System.currentTimeMillis() + "." + extension;
         return fileName;
     }
 

+ 8 - 3
boman-modules/boman-gen/pom.xml

@@ -74,13 +74,18 @@
     </dependencies>
 
     <build>
+        <finalName>${project.artifactId}</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
-                <configuration>
-                    <classifier>execute</classifier>
-                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
             </plugin>
         </plugins>
     </build>

+ 1 - 0
boman-modules/boman-gen/src/main/resources/bootstrap-test.yml

@@ -15,6 +15,7 @@ spring:
       discovery:
         # 服务注册地址
         server-addr: 192.168.101.10:8848
+        namespace: 9690deba-607a-472c-9444-5a6a3b660db3
       config:
         # 配置中心地址
         server-addr: 192.168.101.10:8848

+ 2 - 1
boman-modules/boman-system/src/main/resources/bootstrap-test.yml

@@ -10,9 +10,10 @@ spring:
     nacos:
       discovery:
         server-addr: 192.168.101.10:8848
+        namespace: 9690deba-607a-472c-9444-5a6a3b660db3
       config:
         server-addr: 192.168.101.10:8848
         file-extension: yml
         shared-configs:
           - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
-        namespace: 9690deba-607a-472c-9444-5a6a3b660db3
+        namespace: 9690deba-607a-472c-9444-5a6a3b660db3

+ 6 - 0
boman-web-core/src/main/java/com/boman/web/core/constant/FormDataConstant.java

@@ -136,6 +136,8 @@ public class FormDataConstant {
 
     /**  需要查字典表的框框 */
     public static final List<String> NEED_QUERY_DICT_LIST = Lists.newArrayList(RADIO, CHECKBOX, SELECT);
+    /**  需要转换时间类型的 */
+    public static final List<String> NEED_CONVERT_DATE_LIST = Lists.newArrayList(DATETIME);
 
     /**  hr 日志、基础信息..... */
     public static final String HR = "hr";
@@ -154,5 +156,9 @@ public class FormDataConstant {
     public static final String SINGLE_OBJ_TYPES = "types";
 
 
+    /** 附件的url */
+    public static final String URL = "url";
+
+
 
 }

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

@@ -3,6 +3,7 @@ package com.boman.web.core.service;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.boman.common.core.constant.GenConstants;
 import com.boman.common.core.utils.DateUtils;
 import com.boman.common.core.utils.SecurityUtils;
 import com.boman.common.core.utils.collection.CollectionUtils;
@@ -18,6 +19,7 @@ import com.boman.gen.domain.GenTable;
 import com.boman.gen.domain.GenTableColumn;
 import com.boman.gen.domain.GenTableRelation;
 import com.boman.system.api.RemoteDictDataService;
+import com.boman.system.api.domain.SysFile;
 import com.boman.web.core.constant.FormDataConstant;
 import com.boman.web.core.constant.MaskConstant;
 import com.boman.web.core.constant.SubmitConstant;
@@ -241,6 +243,9 @@ public class TableServiceCmdService {
         }
         // 拿到所有有fk的列
         List<GenTableColumn> fkColumns = filter(columns, col -> ObjectUtils.isNotEmpty(col.getForeignKey()));
+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(fkColumns)) {
+            return;
+        }
 
         for (GenTableColumn column : fkColumns) {
             JSONObject jsonObject = new JSONObject();
@@ -288,13 +293,44 @@ public class TableServiceCmdService {
 
         for (JSONObject jsonObject : result) {
             for (GenTableColumn column : columns) {
-                if (jsonObject.containsKey(column.getColumnName()) && DATETIME.equalsIgnoreCase(column.getColumnType())) {
+                if (jsonObject.containsKey(column.getColumnName()) && NEED_CONVERT_DATE_LIST.contains(column.getColumnType())) {
                     getStrByTimeStamp(jsonObject, column.getColumnName());
                 }
             }
         }
     }
 
+
+    /**
+     * 功能描述: 处理附件,把数据拿出来转换成name、url形式
+     *
+     * @param result 被转的数据
+     */
+    private void handlerAnnex(List<JSONObject> result, List<GenTableColumn> columns) {
+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(result)) {
+            return;
+        }
+
+        for (JSONObject jsonObject : result) {
+            for (GenTableColumn column : columns) {
+                if (jsonObject.containsKey(column.getColumnName())) {
+                    String value = jsonObject.getString(column.getColumnName());
+                    JSONArray fileList = JSON.parseArray(value);
+                    ArrayList<SysFile> files = Lists.newArrayListWithCapacity(2);
+                    for (Object obj : fileList) {
+                        JSONObject fileItem = (JSONObject) obj;
+                        SysFile file = new SysFile();
+                        file.setName(fileItem.getString(SINGLE_OBJ_NAME));
+                        file.setUrl(fileItem.getString(URL));
+                        files.add(file);
+                    }
+
+                    jsonObject.put(column.getColumnName(), files);
+                }
+            }
+        }
+    }
+
     /**
      * 功能描述: 把返回值中含有字典值的转为可视化的心事
      *
@@ -357,7 +393,7 @@ public class TableServiceCmdService {
 
         // 默认查所有字段,不支持自定义
         JSONObject json = selectService.selectById(tableName, pkName, id);
-
+        requireNonNull(json, "id 为[" + id + "]的数据不存在, 表名为[" + tableName + "]");
         List<GenTableColumn> parentColumns = filter(columns, col -> HR.equalsIgnoreCase(col.getHtmlType()));
         // 处理成hr的形式
         for (GenTableColumn hrColumn : parentColumns) {
@@ -369,6 +405,11 @@ public class TableServiceCmdService {
                         handlerSysDictData(Collections.singletonList(json), Collections.singletonList(column));
                         handlerDate(Collections.singletonList(json), Collections.singletonList(column));
                         handlerForeignKey(Collections.singletonList(json), Collections.singletonList(column));
+                        if (GenConstants.HTML_IMAGE_UPLOAD.equalsIgnoreCase(column.getHtmlType())
+                                || GenConstants.HTML_FILE_UPLOAD.equalsIgnoreCase(column.getHtmlType()) ) {
+                            handlerAnnex(Collections.singletonList(json), Collections.singletonList(column));
+                        }
+
                         column.setColumnValue(json.get(column.getColumnName()));
                     }
 
@@ -773,6 +814,7 @@ public class TableServiceCmdService {
 
     public AjaxResult getByTableName(String tableName, List<GenTableColumn> allColumns) {
         List<GenTableColumn> parentColumns = filter(allColumns, col -> HR.equalsIgnoreCase(col.getHtmlType()));
+        allColumns = filterData(allColumns, 0, MaskConstant.LIST_VISIBLE::equals);
 
         // 把孩子放入父亲的怀抱
         for (GenTableColumn hrColumn : parentColumns) {
@@ -789,6 +831,7 @@ public class TableServiceCmdService {
         for (GenTableColumn hrColumn : parentColumns) {
             packDictDataToColumns(hrColumn.getHrChildren(), ObjectUtils::isNotEmpty);
         }
+
         JSONObject result = new JSONObject();
         result.put(BUTTON_LIST, getButton(tableName));
         result.put(SHOW_DATA, parentColumns);
@@ -796,7 +839,9 @@ public class TableServiceCmdService {
     }
 
     public void packDictDataToColumns(List<GenTableColumn> columns, Predicate<String> predicate) {
-        requireNonNull(columns, "columns 为空");
+        if (isEmpty(columns)) {
+            return;
+        }
         for (GenTableColumn column : columns) {
             String dictType = column.getDictType();
             if (predicate.test(dictType)) {

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

@@ -29,9 +29,9 @@ public class IdUtils {
 
         // 查数据库
         StandardlyMapper mapper = SpringUtils.getBean(StandardlyMapper.class);
-        Long maxId = mapper.selectMaxId(tableName, pkName);
-        if (null == maxId || maxId <= 0) {
-            maxId = 1L;
+        long maxId = mapper.selectMaxId(tableName, pkName);
+        if (maxId <= 0) {
+            maxId = 1;
             redisService.setCacheObject(sequencesKey, maxId);
         } else {
             redisService.increment(sequencesKey, ++maxId);

+ 1 - 0
boman-web-core/src/main/resources/bootstrap-test.yml

@@ -10,6 +10,7 @@ spring:
     nacos:
       discovery:
         server-addr: 192.168.101.10:8848
+        namespace: 9690deba-607a-472c-9444-5a6a3b660db3
       config:
         server-addr: 192.168.101.10:8848
         file-extension: yml