Ver código fonte

修改配置方法

hanqingsong 1 ano atrás
pai
commit
6ebf9c5f24

+ 2 - 1
src/main/java/com/chinaitop/depot/basic/mapper/DRyxxsjyMapper.java

@@ -3,6 +3,7 @@ package com.chinaitop.depot.basic.mapper;
3 3
 import com.chinaitop.depot.basic.model.DRyxxsjyVO;
4 4
 import com.chinaitop.depot.basic.model.vo.*;
5 5
 import com.chinaitop.depot.basic.param.DRyxxsjyPageParam;
6
+import org.apache.ibatis.annotations.Param;
6 7
 import org.springframework.stereotype.Repository;
7 8
 
8 9
 import java.util.List;
@@ -32,5 +33,5 @@ public interface DRyxxsjyMapper {
32 33
 
33 34
     List<ZwlxbgjlVO> getZwlxbgjlListById(String sfzh);
34 35
 
35
-    String getSptFileUrl();
36
+    String getSptFileUrl(@Param("orgId") Integer orgId, @Param("sptFileUrl") String sptFileUrl);
36 37
 }

+ 2 - 2
src/main/java/com/chinaitop/depot/basic/mapper/DRyxxsjyMapper.xml

@@ -136,7 +136,7 @@
136 136
         where
137 137
             zw.rysfzh = #{sfzh}
138 138
     </select>
139
-    <select id="getSptFileUrl" parameterType="object" resultType="java.lang.String">
140
-      select s_val from sys_code where org_id = 10 and s_code = 'sptFileUrl'
139
+    <select id="getSptFileUrl" parameterType="java.lang.Object" resultType="java.lang.String">
140
+      select s_val from sys_code where org_id = #{orgId} and s_code = #{sptFileUrl}
141 141
     </select>
142 142
 </mapper>

+ 8 - 5
src/main/java/com/chinaitop/depot/basic/service/impl/DRyxxsjyServiceImpl.java

@@ -45,9 +45,12 @@ public class DRyxxsjyServiceImpl implements DRyxxsjyService {
45 45
             return dRyxxsjyVO;
46 46
         }
47 47
 
48
+        // 查询url
49
+        String sptFile = dRyxxsjyMapper.getSptFileUrl(10, "sptFileUrl");
50
+
48 51
         // 获取文件
49 52
         if (StringUtils.hasText(dRyxxsjyVO.getAvatorUrl())) {
50
-            FileObject data = fileUrlUtil.getData(dRyxxsjyVO.getAvatorUrl());
53
+            FileObject data = fileUrlUtil.getData(dRyxxsjyVO.getAvatorUrl(), sptFile);
51 54
             if (!ObjectUtils.isEmpty(data)) {
52 55
                 dRyxxsjyVO.setFileUrl(data.getLink());
53 56
                 dRyxxsjyVO.setFileName(data.getName());
@@ -72,7 +75,7 @@ public class DRyxxsjyServiceImpl implements DRyxxsjyService {
72 75
             // 文件
73 76
             rotaterotateVOList.forEach(rotateVO -> {
74 77
                 if (StringUtils.hasText(rotateVO.getSerialNumber())) {
75
-                    FileObject data = fileUrlUtil.getData(rotateVO.getSerialNumber());
78
+                    FileObject data = fileUrlUtil.getData(rotateVO.getSerialNumber(), sptFile);
76 79
                     if (!ObjectUtils.isEmpty(data)) {
77 80
                         rotateVO.setFileUrl(data.getLink());
78 81
                         rotateVO.setFileName(data.getName());
@@ -92,7 +95,7 @@ public class DRyxxsjyServiceImpl implements DRyxxsjyService {
92 95
             // 文件
93 96
             reportVOList.forEach(reportVO -> {
94 97
                 if (StringUtils.hasText(reportVO.getFjid())) {
95
-                    FileObject data = fileUrlUtil.getData(reportVO.getFjid());
98
+                    FileObject data = fileUrlUtil.getData(reportVO.getFjid(), sptFile);
96 99
                     if (!ObjectUtils.isEmpty(data)) {
97 100
                         reportVO.setFileUrl(data.getLink());
98 101
                         reportVO.setFileName(data.getName());
@@ -107,7 +110,7 @@ public class DRyxxsjyServiceImpl implements DRyxxsjyService {
107 110
             // 文件
108 111
             certificatesVOList.forEach(certificatesVO -> {
109 112
                 if (StringUtils.hasText(certificatesVO.getFjid())) {
110
-                    FileObject data = fileUrlUtil.getData(certificatesVO.getFjid());
113
+                    FileObject data = fileUrlUtil.getData(certificatesVO.getFjid(), sptFile);
111 114
                     if (!ObjectUtils.isEmpty(data)) {
112 115
                         certificatesVO.setFileUrl(data.getLink());
113 116
                         certificatesVO.setFileName(data.getName());
@@ -121,7 +124,7 @@ public class DRyxxsjyServiceImpl implements DRyxxsjyService {
121 124
             List<RyfjFileVO> ryfjFileVOList = new ArrayList<>();
122 125
             String[] ryfjs = ryfjStrS.split(",");
123 126
             for (String ryfj : ryfjs) {
124
-                FileObject data = fileUrlUtil.getData(dRyxxsjyVO.getRyfj());
127
+                FileObject data = fileUrlUtil.getData(dRyxxsjyVO.getRyfj(), sptFile);
125 128
                 if (!ObjectUtils.isEmpty(data)) {
126 129
                     RyfjFileVO ryfjFileVO = new RyfjFileVO();
127 130
                     ryfjFileVO.setRyfjFileUrl(data.getLink());

+ 6 - 2
src/main/java/com/chinaitop/depot/utils/CustomFilter.java

@@ -1,3 +1,4 @@
1
+/*
1 2
 package com.chinaitop.depot.utils;
2 3
 
3 4
 import java.io.IOException;
@@ -81,12 +82,14 @@ public class CustomFilter implements Filter {
81 82
         }
82 83
     }
83 84
 
84
-	/**
85
+	*/
86
+/**
85 87
      * 判断本次请求的数据类型是否为上传文件
86 88
      *
87 89
      * @param request request
88 90
      * @return boolean
89
-     */
91
+     *//*
92
+
90 93
     private boolean isMultipart(ServletRequest request) {
91 94
     	boolean flag = request.getContentType().toLowerCase().startsWith("multipart/");
92 95
         if (request.getContentType() != null && flag) {
@@ -97,3 +100,4 @@ public class CustomFilter implements Filter {
97 100
    }
98 101
 
99 102
 }
103
+*/

+ 1 - 6
src/main/java/com/chinaitop/depot/utils/FileUrlUtil.java

@@ -1,7 +1,6 @@
1 1
 package com.chinaitop.depot.utils;
2 2
 
3 3
 import com.alibaba.fastjson.JSON;
4
-import com.chinaitop.depot.basic.mapper.DRyxxsjyMapper;
5 4
 import com.chinaitop.depot.basic.param.FileObject;
6 5
 import com.chinaitop.depot.basic.param.FileParam;
7 6
 import org.springframework.stereotype.Component;
@@ -21,8 +20,6 @@ import javax.annotation.Resource;
21 20
 public class FileUrlUtil {
22 21
     @Resource
23 22
     private RestTemplate restTemplate;
24
-    @Resource
25
-    private DRyxxsjyMapper dRyxxsjyMapper;
26 23
 
27 24
     /**
28 25
      * 获取市平台文件url
@@ -30,11 +27,9 @@ public class FileUrlUtil {
30 27
      * @param fileId
31 28
      * @return
32 29
      */
33
-    public FileObject getData(String fileId) {
30
+    public FileObject getData(String fileId, String sptFile) {
34 31
         MultiValueMap<String, Object> sendMap = new LinkedMultiValueMap<>();
35 32
         sendMap.add("id", fileId);
36
-        // 查询数据
37
-        String sptFile = dRyxxsjyMapper.getSptFileUrl();
38 33
 
39 34
         String forObject = restTemplate.postForObject(String.format("%s%s", sptFile, "/file/findById"), sendMap, String.class);
40 35
         if (!ObjectUtils.isEmpty(forObject)) {

+ 9 - 3
src/main/java/com/chinaitop/depot/utils/WebConfig.java

@@ -1,3 +1,4 @@
1
+/*
1 2
 package com.chinaitop.depot.utils;
2 3
 
3 4
 import org.springframework.boot.web.servlet.FilterRegistrationBean;
@@ -6,20 +7,24 @@ import org.springframework.context.annotation.Configuration;
6 7
 import java.util.ArrayList;
7 8
 import java.util.List;
8 9
 
10
+*/
9 11
 /**
10 12
  * @desc 注册bean, 将自定义过滤器添加到过滤器链中
11 13
  * @Author hf
12 14
  * @date 2019/3/11
13 15
  * @return
14
- */
16
+ *//*
17
+
15 18
 @Configuration
16 19
 public class WebConfig {
17 20
 
18
-   /**
21
+   */
22
+/**
19 23
     * 注册过滤器,有两种方式:
20 24
     * 1) 使用 @Component 注解<br>
21 25
     * 2) 添加到过滤器链中,此方式适用于使用第三方的过滤器。将过滤器写到 WebConfig 类中,如下:
22
-    */
26
+    *//*
27
+
23 28
    @Bean
24 29
    public FilterRegistrationBean filterRegistrationBean() {
25 30
 
@@ -37,3 +42,4 @@ public class WebConfig {
37 42
    }
38 43
 
39 44
 }
45
+*/