Преглед изворни кода

fix bug:/rwd/def/funcid接口不返回dataSource字段

lijie пре 3 година
родитељ
комит
f144a821d0
17 измењених фајлова са 872 додато и 17 уклоњено
  1. 1 0
      dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/define/dao/ObjectInfoMapper.java
  2. 38 2
      dmp-business/dmp-rwd/src/main/resources/mapper/DefineInfoMapper.xml
  3. 23 0
      dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/config/AccountConfig.java
  4. 64 0
      dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/config/FileWebConfigurer.java
  5. 1 0
      dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/config/MinioConfig.java
  6. 46 0
      dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/context/OldFileAppContext.java
  7. 36 0
      dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/context/OldFileContext.java
  8. 93 0
      dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/controller/CompatibleOldFileController.java
  9. 41 0
      dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/handler/OldFileAuthHandler.java
  10. 38 0
      dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/handler/OldFileContextHandler.java
  11. 14 15
      dmp-cloud/dmp-file/src/main/resources/bootstrap.yml
  12. 10 0
      dmp-cloud/dmp-file/src/main/resources/doc/account.txt
  13. 329 0
      dmp-cloud/dmp-file/src/main/resources/doc/documentation.md
  14. 52 0
      dmp-cloud/dmp-file/src/main/resources/doc/template.html
  15. 73 0
      dmp-common/src/main/java/com/persagy/dmp/common/utils/ResourceUtil.java
  16. 2 0
      dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/define/entity/ObjectInfoDefine.java
  17. 11 0
      dmp-comp/dmp-mybatis/src/main/java/com/persagy/dmp/mybatis/config/MybatisPlusConfig.java

+ 1 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/define/dao/ObjectInfoMapper.java

@@ -1,5 +1,6 @@
 package com.persagy.dmp.rwd.define.dao;
 
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.toolkit.Constants;

+ 38 - 2
dmp-business/dmp-rwd/src/main/resources/mapper/DefineInfoMapper.xml

@@ -3,6 +3,41 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.persagy.dmp.rwd.define.dao.ObjectInfoMapper">
+    <!-- 因该对象dataSource字段需要使用自定义Handler处理,
+    且在xml自定义sql使用的是MybatisConfiguration类对象,
+    无法使用mybatis-plus,所以这里定义了一个ResultMap-->
+    <resultMap id="BaseResultMap" type="com.persagy.dmp.define.entity.ObjectInfoDefine">
+        <id property="id" column="id" jdbcType="VARCHAR"/>
+        <result property="code" column="code" jdbcType="VARCHAR"/>
+        <result property="name" column="name" jdbcType="VARCHAR"/>
+        <result property="aliasCode" column="alias_code" jdbcType="VARCHAR"/>
+        <result property="aliasName" column="alias_name" jdbcType="VARCHAR"/>
+        <result property="classCode" column="class_code" jdbcType="VARCHAR"/>
+        <result property="groupCode" column="group_code" jdbcType="VARCHAR"/>
+        <result property="projectId" column="project_id" jdbcType="VARCHAR"/>
+        <result property="category" column="category" jdbcType="VARCHAR"/>
+        <result property="firstTag" column="first_tag" jdbcType="VARCHAR"/>
+        <result property="secondTag" column="second_tag" jdbcType="VARCHAR"/>
+        <result property="priority" column="priority" jdbcType="VARCHAR"/>
+        <result property="inputMode" column="input_mode" jdbcType="VARCHAR"/>
+        <result property="unit" column="unit" jdbcType="VARCHAR"/>
+        <result property="dataType" column="data_type" jdbcType="VARCHAR"/>
+        <result property="isMultiple" column="is_multiple" jdbcType="INTEGER"/>
+        <result property="isRegion" column="is_region" jdbcType="INTEGER"/>
+        <result property="formater" column="formater" jdbcType="VARCHAR"/>
+        <result property="dataSource" column="data_source" jdbcType="OTHER" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
+        <result property="remark" column="remark" jdbcType="VARCHAR"/>
+        <result property="subFlag" column="sub_flag" jdbcType="INTEGER"/>
+        <result property="weakPoint" column="weak_point" jdbcType="INTEGER"/>
+        <result property="showOrder" column="show_order" jdbcType="INTEGER"/>
+        <result property="version" column="version" jdbcType="VARCHAR"/>
+        <result property="creator" column="creator" jdbcType="VARCHAR"/>
+        <result property="creationTime" column="creation_time" jdbcType="CHAR"/>
+        <result property="modifier" column="modifier" jdbcType="VARCHAR"/>
+        <result property="modifiedTime" column="modified_time" jdbcType="CHAR"/>
+        <result property="valid" column="valid" jdbcType="TINYINT"/>
+        <result property="ts" column="ts" jdbcType="TIMESTAMP"/>
+    </resultMap>
     <!-- 类型如果重复则会出现多条,因此这里先用distinct容错.将基础类型的信息点与非基础信息点一起返回,且class_code改为对应的非基础对象类型 -->
     <sql id="SelectColumns">
         distinct
@@ -11,7 +46,8 @@
           dt_define_info.project_id,dt_define_info.category,dt_define_info.first_tag,
           dt_define_info.second_tag, dt_define_info.priority,dt_define_info.input_mode,
           dt_define_info.unit,dt_define_info.data_type,dt_define_info.is_multiple,dt_define_info.is_region,
-          dt_define_info.formater,dt_define_info.data_source,dt_define_info.remark,dt_define_info.sub_flag,
+          dt_define_info.formater,dt_define_info.data_source,
+          dt_define_info.remark,dt_define_info.sub_flag,
           dt_define_info.weak_point,dt_define_info.show_order,dt_define_info.version,dt_define_info.creator,
           dt_define_info.creation_time,dt_define_info.modifier,dt_define_info.modified_time,
           dt_define_info.valid,dt_define_info.ts
@@ -64,7 +100,7 @@
         ) T
         where T.class_code = dt_define_type.code and T.code = dt_define_info.code and T.max_show_level = <include refid="ShowLevelSQL"/>)
     </sql>
-    <select id="queryByClassCodes" resultType="com.persagy.dmp.define.entity.ObjectInfoDefine">
+    <select id="queryByClassCodes" resultMap="BaseResultMap">
         select ${ew.sqlSelect}
         from ( <include refid="InfoTableSQL"/> ) dt_define_info
         WHERE ${ew.expression.sqlSegment}

+ 23 - 0
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/config/AccountConfig.java

@@ -0,0 +1,23 @@
+package com.persagy.dmp.file.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/***
+ * Description: 兼容旧文件服务的账号配置
+ * @author : lijie
+ * @date :2021/11/19 14:21
+ * Update By lijie 2021/11/19 14:21
+ */
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "persagy.common.token")
+public class AccountConfig {
+
+    public static Map<String,String> accountMap;
+
+}

+ 64 - 0
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/config/FileWebConfigurer.java

@@ -0,0 +1,64 @@
+package com.persagy.dmp.file.config;
+
+import com.persagy.dmp.auth.handler.AppContextHandler;
+import com.persagy.dmp.file.controller.CompatibleOldFileController;
+import com.persagy.dmp.file.handler.OldFileAuthHandler;
+import com.persagy.dmp.file.handler.OldFileContextHandler;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.annotation.Order;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+@Order(100)
+public class FileWebConfigurer implements WebMvcConfigurer {
+    /***
+     * Description: 旧文件的上下文处理器
+     * @return : com.persagy.dmp.file.handler.OldFileContextHandler
+     * @author : lijie
+     * @date :2021/11/19 10:12
+     * Update By lijie 2021/11/19 10:12
+     */
+    @Bean
+    public OldFileContextHandler oldFileContextHandler() {
+        return new OldFileContextHandler();
+    }
+    /***
+     * Description: 旧文件的校验处理器
+     * @return : com.persagy.dmp.file.handler.OldFileAuthHandler
+     * @author : lijie
+     * @date :2021/11/19 10:12
+     * Update By lijie 2021/11/19 10:12
+     */
+    @Bean
+    public OldFileAuthHandler oldFileAuthHandler() {
+        return new OldFileAuthHandler();
+    }
+
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        String[] includePaths = {"/range/**","/common/**"};
+        String[] excludePaths = {"/**/*.html", "/**/*.js", "/**/*.css", "/swagger-resources"};
+        // 设置拦截的路径、不拦截的路径、优先级等等
+        registry.addInterceptor(oldFileContextHandler())
+                .order(100)
+                .addPathPatterns(includePaths)
+                .excludePathPatterns(excludePaths);
+        String[] authIncludePaths = {"/common/file_upload",
+                "/range/file_upload",
+                "/range/file_delete",
+                "/common/files_delete",
+                "/common/images_delete",
+                "/common/files_list",
+                "/common/images_list",
+                "/common/image_key_change",
+                "/common/image_upload"};
+        registry.addInterceptor(oldFileAuthHandler())
+                .order(101)
+                .addPathPatterns()
+                .excludePathPatterns(excludePaths);
+    }
+
+
+}

+ 1 - 0
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/config/MinioConfig.java

@@ -5,6 +5,7 @@ import com.persagy.dmp.file.service.impl.MinioStorageServiceImpl;
 import io.minio.MinioClient;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 

+ 46 - 0
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/context/OldFileAppContext.java

@@ -0,0 +1,46 @@
+package com.persagy.dmp.file.context;
+
+import com.persagy.dmp.common.context.AppContext;
+import com.persagy.dmp.common.helper.SpringHelper;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springframework.stereotype.Component;
+
+/**
+ * 默认应用上下文
+ * @author Charlie Yu
+ * @version 1.0 2021-03-04
+ */
+@Component
+public class OldFileAppContext {
+
+    /** 线程级的上下文 */
+    private ThreadLocal<OldFileContext> context = new ThreadLocal<>();
+    /***
+     * Description: 获取文件上下文
+     * @return : com.persagy.dmp.file.context.OldFileContext
+     * @author : lijie
+     * @date :2021/11/18 18:36
+     * Update By lijie 2021/11/18 18:36
+     */
+    public static OldFileContext getContext() {
+        OldFileAppContext fileAppContext = SpringHelper.getBean(OldFileAppContext.class);
+        OldFileContext c = fileAppContext.context.get();
+        if(c == null){
+            c = new OldFileContext();
+            fileAppContext.context.set(c);
+        }
+        return c;
+    }
+    /***
+     * Description: 移除文件上下文
+     * @return : com.persagy.dmp.file.context.OldFileContext
+     * @author : lijie
+     * @date :2021/11/18 18:36
+     * Update By lijie 2021/11/18 18:36
+     */
+    public static void unloadContext() {
+        OldFileAppContext fileAppContext = SpringHelper.getBean(OldFileAppContext.class);
+        fileAppContext.context.remove();
+    }
+}

+ 36 - 0
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/context/OldFileContext.java

@@ -0,0 +1,36 @@
+package com.persagy.dmp.file.context;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/***
+ * Description: 旧文件服务使用的路径对象
+ * @author : lijie
+ * @date :2021/11/18 18:34
+ * Update By lijie 2021/11/18 18:34
+ */
+@Data
+@EqualsAndHashCode
+public class OldFileContext {
+
+    /** 序列id */
+    private static final long serialVersionUID = 697592850956445675L;
+    /** 请求用户id */
+    public static final String SYSTEM_ID = "systemId";
+    /** 密码 */
+    public static final String SECRET = "secret";
+    /** 文件key */
+    public static final String KEY = "key";
+    /** 常用的systemId */
+    public static final String DATA_PLATFORM = "dataPlatform";
+    /** 常用的systemId */
+    public static final String REVIT = "revit";
+
+    /** 集团编码 - 租户 */
+    private String systemId;
+    /** 用户主键 */
+    private String secret;
+    /** 数据源名称 */
+    private String key;
+
+}

+ 93 - 0
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/controller/CompatibleOldFileController.java

@@ -0,0 +1,93 @@
+package com.persagy.dmp.file.controller;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.text.CharSequenceUtil;
+import cn.hutool.core.util.CharsetUtil;
+import cn.hutool.core.util.StrUtil;
+import com.persagy.dmp.common.utils.ResourceUtil;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.io.IOUtils;
+import org.springframework.core.io.Resource;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+
+/***
+ * Description: 兼容旧的文件服务接口
+ * @author : lijie
+ * @date :2021/11/18 10:06
+ * Update By lijie 2021/11/18 10:06
+ */
+@RestController
+@RequiredArgsConstructor
+public class CompatibleOldFileController {
+
+    private static final String DOCUMENTATION= "doc/documentation.md";
+    private static final String TEMPLATE= "doc/template.html";
+    private static final String ERROR_HTML="<html><head>" +
+            "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" +
+            "<title>image-service</title></head></html><body>{}</body>";
+    /***
+     * Description: 获取接口文档
+     * @param response : 响应体
+     * @return : void
+     * @author : lijie
+     * @date :2021/11/19 9:57
+     * Update By lijie 2021/11/19 9:57
+     */
+    @GetMapping(value = "/doc",produces = {"text/html;charset=UTF-8"})
+    public void doc(HttpServletResponse response) throws IOException {
+        Resource[] docResources = ResourceUtil.getResource(DOCUMENTATION, DOCUMENTATION);
+        Resource[] templateResources = ResourceUtil.getResource(TEMPLATE, TEMPLATE);
+        if (templateResources.length<=0
+                || docResources.length<=0
+                || !templateResources[0].exists()
+                || !docResources[0].exists()){
+            response.getWriter()
+                    .write(StrUtil.format(ERROR_HTML,"暂无内容"));
+            return;
+        }
+        Resource docResource = docResources[0];
+        Resource templateResource = templateResources[0];
+        String tempStr = FileUtil.readString(templateResource.getFile(), Charset.defaultCharset());
+        String docContentStr = FileUtil.readString(docResource.getFile(), Charset.defaultCharset());
+        response.getWriter()
+                .write(StrUtil.replace(tempStr, "#replaceMePlease#", docContentStr));
+    }
+    /***
+     * Description: 文件上传
+     * @return : void
+     * @author : lijie
+     * @date :2021/11/19 9:58
+     * Update By lijie 2021/11/19 9:58
+     */
+    @PostMapping(value = "/common/file_upload",produces = {MediaType.APPLICATION_JSON})
+    public void fileUpload(HttpServletResponse response) throws IOException {
+        Resource[] docResources = ResourceUtil.getResource(DOCUMENTATION, DOCUMENTATION);
+        Resource[] templateResources = ResourceUtil.getResource(TEMPLATE, TEMPLATE);
+        if (templateResources.length<=0
+                || docResources.length<=0
+                || !templateResources[0].exists()
+                || !docResources[0].exists()){
+            response.getWriter()
+                    .write(StrUtil.format(ERROR_HTML,"暂无内容"));
+            return;
+        }
+        Resource docResource = docResources[0];
+        Resource templateResource = templateResources[0];
+        String tempStr = FileUtil.readString(templateResource.getFile(), Charset.defaultCharset());
+        String docContentStr = FileUtil.readString(docResource.getFile(), Charset.defaultCharset());
+        response.getWriter()
+                .write(StrUtil.replace(tempStr, "#replaceMePlease#", docContentStr));
+    }
+
+
+
+
+
+}

+ 41 - 0
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/handler/OldFileAuthHandler.java

@@ -0,0 +1,41 @@
+package com.persagy.dmp.file.handler;
+
+import cn.hutool.core.util.StrUtil;
+import com.persagy.dmp.common.exception.BusinessException;
+import com.persagy.dmp.file.config.AccountConfig;
+import com.persagy.dmp.file.context.OldFileAppContext;
+import com.persagy.dmp.file.context.OldFileContext;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class OldFileAuthHandler implements HandlerInterceptor {
+
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        OldFileContext context = OldFileAppContext.getContext();
+        if (StrUtil.isBlank(context.getSystemId()) || StrUtil.isBlank(context.getSecret())){
+            throw new BusinessException("文件服务器密钥有误");
+        }
+        if (!AccountConfig.accountMap.containsKey(context.getSystemId())
+                || !context.getSecret().equals(AccountConfig.accountMap.get(context.getSystemId()))){
+            throw new BusinessException("文件服务器密钥有误");
+        }
+        return true;
+    }
+
+    @Override
+    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
+                           ModelAndView modelAndView) throws Exception {
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
+            throws Exception {
+    }
+
+
+}

+ 38 - 0
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/handler/OldFileContextHandler.java

@@ -0,0 +1,38 @@
+package com.persagy.dmp.file.handler;
+
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.persagy.dmp.file.context.OldFileAppContext;
+import com.persagy.dmp.file.context.OldFileContext;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class OldFileContextHandler implements HandlerInterceptor {
+
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        OldFileContext context = OldFileAppContext.getContext();
+        context.setSystemId(request.getParameter(OldFileContext.SYSTEM_ID));
+        context.setSecret(request.getParameter(OldFileContext.SECRET));
+        context.setKey(request.getParameter(OldFileContext.KEY));
+        return true;
+    }
+
+    @Override
+    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
+                           ModelAndView modelAndView) throws Exception {
+        OldFileAppContext.unloadContext();
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
+            throws Exception {
+        OldFileAppContext.unloadContext();
+    }
+
+
+}

+ 14 - 15
dmp-cloud/dmp-file/src/main/resources/bootstrap.yml

@@ -1,22 +1,21 @@
 spring:
   application:
     name: dmp-file
-#
-#eureka:
-#  client:
-#    service-url:
-#      defaultZone: http://frame:123456@integrated-eureka:9931/integrated-eureka/eureka/
-#      register-with-eureka: true
-#      fetch-registry: true
-#  instance:
-#    hostname: dmp-file
-#    instance-id: ${spring.cloud.client.ip-address}:${server.port}
-#    lease-expiration-duration-in-seconds: 10
-#    lease-renewal-interval-in-seconds: 5
-#    prefer-ip-address: true
+  http:
+    encoding:
+      force: true
+      charset: utf-8
+      enabled: true
 
-#persagy:
-#  common:
+persagy:
+  common:
+    token:
+      accountMap:
+        dev: 123
+        saas: 46f869eea8b31d14
+        superClass: 90b92e6f71b47b31
+        revit: 63afbef6906c342b
+        dataPlatform: 9e0891a7a8c8e885
 #    # 运维平台登陆认证
 #    token:
 #      enabled: false

+ 10 - 0
dmp-cloud/dmp-file/src/main/resources/doc/account.txt

@@ -0,0 +1,10 @@
+#数据平台用户密码
+dev  123
+#saas
+saas  46f869eea8b31d14
+#superClass
+superClass  90b92e6f71b47b31
+#revit
+revit   63afbef6906c342b
+#数据平台通用
+dataPlatform  9e0891a7a8c8e885

+ 329 - 0
dmp-cloud/dmp-file/src/main/resources/doc/documentation.md

@@ -0,0 +1,329 @@
+
+
+#工单图片接口
+    
+##工单图片上传接口
+
+url:image-service/work_order/upload?projectId=Pj1101080001&secret=***&workOrderId=12345&key=www
+
+post体
+
+    图片文件输入流
+    
+返回:
+
+    {  
+       "Result":"success",
+       "ResultMsg":""
+    }
+    
+   
+##工单图片超链接
+   
+url:image-service/work_order/get?projectId=Pj1101080001&workOrderId=12345&key=www
+
+
+#图片接口
+    
+##图片上传接口
+
+url:image-service/common/image_upload?systemId=dev&secret=***&key=www
+
+如果key已存在,url加入参数overwrite=true可以强制覆盖,比如:image-service/common/image_upload?systemId=dev&secret=***&key=www&overwrite=true
+
+post体
+
+    图片文件输入流
+    
+返回:
+
+    {  
+       "Result":"success",
+       "ResultMsg":""
+    }
+    
+   
+##图片超链接
+   
+url:image-service/common/image_get?systemId=dev&key=www&width=1000&height=1000
+
+参数width和height可选,不填则按图片原尺寸返回
+
+##图片key更新接口
+   更新key
+   
+url:image-service/common/image\_key\_change?systemId=dev&secret=***
+
+post体
+
+    {
+    	"from":"150789951269381626421795226631123123.jpg",
+    	"to":"150794642806010256531555205584Koala.jpg"
+    }
+    
+返回
+
+    {
+        "result": "success",
+        "ResultMsg": ""
+    }
+
+##图片文件列表浏览接口
+   浏览已上传的文件
+   
+url:image-service/common/images_list?systemId=dev&secret=***
+
+post体
+
+    {
+    	"prefix":"15",                                           //选填,key的前缀
+    	"maxCount":200,                                          //选填,最多返回记录数,默认为100
+    	"from":"150789948131164438721002079551123123"        //选填,从该记录开始返回,但不包含该记录
+    }
+    
+返回
+
+    {
+        "result": "success",
+        "Count": 10,
+        "Content": [
+            "150789951269381626421795226631123123",
+            "150789990060258615284902043641123123",
+            "150794642806010256531555205584Koala",
+            "150794642806887429525866173211Lighthouse",
+            "150794664351711935679288581014Desert",
+            "150797627222133136666356585921设备管理7",
+            "150797628977096943998988717791设备管理7",
+            "150812247843304793838365003466保险公司名录保存成功",
+            "150812247843680967023875564341供应商名录",
+            "150812247844007977657392621041供应商名录滚动条回滚"
+        ],
+        "ResultMsg": ""
+    }
+    
+##图片文件删除接口
+   删除已上传的图片文件
+   
+url:image-service/common/images_delete?systemId=dev&secret=***
+
+post体
+
+    {
+    	"keys":[                                           //要删除key列表
+    		"150789951269381626421795226631123123",
+    		"150794642806010256531555205584Koala"
+    		]
+    }
+    
+返回
+
+    {
+        "result": "success",
+        "Count": 2,
+        "Content": [                                        //成功删除的key列表
+            "150789951269381626421795226631123123",
+            "150794642806010256531555205584Koala"
+        ],
+        "ResultMsg": ""
+    }
+
+
+#文件接口
+  
+##文件上传接口
+
+url:image-service/common/file_upload?systemId=dev&secret=***&key=www
+
+如果key已存在,url加入参数overwrite=true可以强制覆盖,比如:image-service/common/file_upload?systemId=dev&secret=***&key=www&overwrite=true
+
+post体
+
+    图片文件输入流
+    
+返回:
+
+    {  
+       "Result":"success",
+       "ResultMsg":""
+    }
+    
+   
+##文件下载接口
+   
+url:
+    
+    image-service/common/file_get/{key}?systemId=dev
+    
+    或:
+    
+    image-service/common/file_get?systemId=dev&key=www
+
+例子:
+
+    image-service/common/file_get/www?systemId=dev, 其中key为www;
+     
+    或:
+     
+     image-service/common/file_get?systemId=dev&key=www
+
+
+##文件列表浏览接口
+   浏览已上传的文件
+   
+url:image-service/common/files_list?systemId=dev&secret=***
+
+post体
+
+    {
+    	"prefix":"15",                                           //选填,key的前缀
+    	"maxCount":200,                                          //选填,最多返回记录数,默认为100
+    	"from":"150789948131164438721002079551123123.jpg"        //选填,从该记录开始返回,但不包含该记录
+    }
+    
+返回
+
+    {
+        "result": "success",
+        "Count": 10,
+        "Content": [
+            "150789951269381626421795226631123123.jpg",
+            "150789990060258615284902043641123123.jpg",
+            "150794642806010256531555205584Koala.jpg",
+            "150794642806887429525866173211Lighthouse.jpg",
+            "150794664351711935679288581014Desert.jpg",
+            "150797627222133136666356585921设备管理7.png",
+            "150797628977096943998988717791设备管理7.png",
+            "150812247843304793838365003466保险公司名录保存成功,无数据.png",
+            "150812247843680967023875564341供应商名录.png",
+            "150812247844007977657392621041供应商名录滚动条回滚.png"
+        ],
+        "ResultMsg": ""
+    }
+    
+##文件删除接口
+   删除已上传的文件
+   
+url:image-service/common/files_delete?systemId=dev&secret=***
+
+post体
+
+    {
+    	"keys":[                                           //要删除key列表
+    		"150789951269381626421795226631123123.jpg",
+    		"150794642806010256531555205584Koala.jpg"
+    		]
+    }
+    
+返回
+
+    {
+        "result": "success",
+        "Count": 2,
+        "Content": [                                        //成功删除的key列表
+            "150789951269381626421795226631123123.jpg",
+            "150794642806010256531555205584Koala.jpg"
+        ],
+        "ResultMsg": ""
+    }
+    
+##文件key更新接口
+   更新key,只支持小于1G的文件
+   
+url:image-service/common/file\_key\_change?systemId=dev&secret=***
+
+post体
+
+    {
+    	"from":"150789951269381626421795226631123123.jpg",
+    	"to":"150794642806010256531555205584Koala.jpg"
+    }
+    
+返回
+
+    {
+        "result": "success",
+        "ResultMsg": ""
+    }
+    
+    
+    
+    
+# 分片上传文件接口
+  
+## 申请分片上传接口(获取上传UploadId)
+url: image-service/common/register\_multipart\_upload?systemId=dev&secret=***&key=dir1/dir2/abc.txt&overwrite=true
+
+注册分片上传, 获取一个上传id(UploadId), 需要secret, key表示上传的文件名, 可以包含文件路径, overwrite表示是否覆盖已有的文件(如果存在)
+
+overwrite有一定风险, 只在注册分片时校验, 合并时候如果key被占用, 会覆盖掉之前文件
+
+post体
+
+    无
+    
+返回成功
+
+    {
+        "Result":"success",
+        "ResultMsg":"*****",
+        "UploadId":"***************"
+    }
+返回失败
+
+    {
+        "Result":"failure",
+        "ResultMsg":"*****"
+    }
+
+
+## 上传分片接口
+url: image-service/common/multipart_upload
+
+上传分片
+
+post请求, form-data方式
+
+|key名称       |类型|说明                         |
+|--------------|----|-----------------------------|
+|file          |File|上传的分片文件内容           |
+|uploadId      |Text|UploadId                     |
+|chunkNumber   |Text|当前上传分片的顺序号, 从1开始|
+|chunkSize     |Text|分片的长度                   |
+|md5           |Text|分片文件的MD5值(选填)        |
+    
+返回成功
+
+    {
+        "Result":"success",
+        "TotalCount":11,             // 已经完成的块数量
+        "MD5":"",                    // 服务器计算分片的MD5值
+        "ResultMsg":"*****"
+    }
+返回失败
+
+    {
+        "Result":"failure",
+        "ResultMsg":"*****"
+    }
+
+## 合并分片接口
+
+url: image-service/common/merge_multipart?systemId=dev&secret=***&uploadId=***
+
+合并分片, 需要secret
+
+post请求
+
+    
+返回成功
+
+    {
+        "Result":"success",
+        "ResultMsg":"*****"
+    }
+返回失败
+
+    {
+        "Result":"failure",
+        "ResultMsg":"*****"
+    }

+ 52 - 0
dmp-cloud/dmp-file/src/main/resources/doc/template.html

@@ -0,0 +1,52 @@
+<!-- 插件官网地址:http://ruby-china.org/topics/17028 -->
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <title>image-service</title>
+        <link rel="stylesheet" type="text/css" href="http://service.sagacloud.cn:28888/static-content/markdownToc_files/github2-rightpart.css" media="all">
+        <link rel="stylesheet" type="text/css" href="http://service.sagacloud.cn:28888/static-content/markdownToc_files/github1-contents.css">
+        <link rel="stylesheet" href="http://service.sagacloud.cn:28888/static-content/markdownToc_files/zTreeStyle.css" type="text/css">
+        <style>
+            .ztree li a.curSelectedNode {
+                padding-top: 0px;
+                background-color: #FFE6B0;
+                color: black;
+                height: 16px;
+                border: 1px #FFB951 solid;
+                opacity: 0.8;
+            }
+            .ztree{
+                overflow: auto;
+                height:100%;
+                min-height: 200px;
+                top: 0px;
+            }
+        </style>
+    </head>
+    <body style="">
+        <div>
+            <div style="width:30%;">
+                <ul id="tree" class="ztree" style="width: 260px; overflow: auto; position: fixed; z-index: 2147483647; border: 0px none; left: 0px; bottom: 0px;">
+                <!-- 目录内容在网页另存为之后将插入到此处 -->
+                </ul>
+            </div>
+            <div id="readme" style="width:70%;margin-left:25%;">
+                <article class="markdown-body">
+                    #replaceMePlease#
+                </article>
+            </div>
+        </div>
+    <script src="http://service.sagacloud.cn:28888/static-content/markdownToc_files/jquery-1.10.2.min.js"></script>
+    <script src="http://service.sagacloud.cn:28888/static-content/markdownToc_files/jquery.ztree.all-3.5.min.js"></script>
+    <script src="http://service.sagacloud.cn:28888/static-content/markdownToc_files/jquery.ztree_toc.min.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function(){
+            $('#tree').ztree_toc({
+                is_auto_number:false,
+                documment_selector:'.markdown-body',
+                is_expand_all: true
+            });
+        });
+    </script>
+    </body>
+</html>

+ 73 - 0
dmp-common/src/main/java/com/persagy/dmp/common/utils/ResourceUtil.java

@@ -0,0 +1,73 @@
+package com.persagy.dmp.common.utils;
+
+import cn.hutool.core.util.StrUtil;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.core.io.support.ResourcePatternResolver;
+
+import java.io.IOException;
+
+public class ResourceUtil {
+
+    /**jar同级config目录前缀*/
+    private static final String FILE_CONFIG_PATH="file:./config/{}";
+    /**Classpath路径前缀*/
+    private static final String FILE_CLASSPATH_PATH="classpath:./{}";
+
+    /***
+     * @Description: 校验资源文件是否存在
+     * @param subConfigFilePath : jar包同级目录下的配置文件
+     * @return : com.alibaba.fastjson.JSONArray
+     * @author: lijie
+     * @Date:2020/6/6 19:43
+     * Update By lijie 2020/6/6 19:43
+     */
+    public static boolean checkResoucesExist(String subConfigFilePath) throws IOException {
+        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+        return checkResoucesExist(resolver.getResources(StrUtil.format(FILE_CONFIG_PATH,subConfigFilePath)));
+    }
+    /***
+     * @Description: 校验资源文件是否存在
+     * @return : com.alibaba.fastjson.JSONArray
+     * @author: lijie
+     * @Date:2020/6/6 19:43
+     * Update By lijie 2020/6/6 19:43
+     */
+    public static boolean checkResoucesExist(Resource[] resolverResources) throws IOException {
+        if (resolverResources.length <= 0) {
+            return false;
+        }
+        boolean exist = true;
+        for (Resource resource : resolverResources) {
+            if (!resource.exists()) {
+                exist = false;
+                break;
+            }
+        }
+        return exist;
+    }
+
+    /***
+     * Description: 获取资源文件方法
+     * @param subConfigFilePath : 配置文件路径
+     * @param subClasspathFilePath : classpath下的文件
+     * @return : org.springframework.core.io.Resource[]
+     * @author : lijie
+     * @date :2021/3/1 14:25
+     * Update By lijie 2021/3/1 14:25
+     */
+    public static Resource[] getResource(String subConfigFilePath, String subClasspathFilePath)
+            throws IOException {
+        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+        Resource[] resolverResources = resolver.getResources(StrUtil.format(FILE_CONFIG_PATH,subConfigFilePath));
+        if (checkResoucesExist(resolverResources)){
+            return resolverResources;
+        }
+        Resource[] classPathResources = resolver.getResources(StrUtil.format(FILE_CLASSPATH_PATH, subClasspathFilePath));
+        if (!checkResoucesExist(classPathResources)){
+            return new Resource[0];
+        }
+        return classPathResources;
+    }
+
+}

+ 2 - 0
dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/define/entity/ObjectInfoDefine.java

@@ -7,6 +7,8 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.persagy.dmp.common.model.entity.AuditableEntity;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedJdbcTypes;
 import org.hibernate.validator.constraints.Length;
 
 import javax.validation.constraints.NotNull;

+ 11 - 0
dmp-comp/dmp-mybatis/src/main/java/com/persagy/dmp/mybatis/config/MybatisPlusConfig.java

@@ -1,9 +1,12 @@
 package com.persagy.dmp.mybatis.config;
 
+import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
 import com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer;
 import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
 import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import org.apache.ibatis.type.JdbcType;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.CommandLineRunner;
@@ -55,4 +58,12 @@ public class MybatisPlusConfig implements CommandLineRunner {
     public MybatisPlusPropertiesCustomizer mybatisPlusPropertiesCustomizer() {
         return properties -> properties.setTypeHandlersPackage("com.persagy.**.typehandler");
     }
+
+//    @Bean
+//    public ConfigurationCustomizer configurationCustomizer() {
+//        return properties -> {
+//            properties.getTypeHandlerRegistry().register(Object.class, JdbcType.VARCHAR,JacksonTypeHandler.class);
+//            properties.getTypeHandlerRegistry().register(ArrayNode.class, JdbcType.VARCHAR,JacksonTypeHandler.class);
+//        };
+//    }
 }