Преглед на файлове

feat:新增法律法规附件下载

aihua преди 3 години
родител
ревизия
f905fd2b82
променени са 1 файла, в които са добавени 18 реда и са изтрити 7 реда
  1. 18 7
      src/main/java/com/chinaitop/depot/risk/controller/LawsRegulationsInfoBaseController.java

+ 18 - 7
src/main/java/com/chinaitop/depot/risk/controller/LawsRegulationsInfoBaseController.java

@@ -6,20 +6,18 @@ import io.swagger.annotations.Api;
6 6
 import io.swagger.annotations.ApiImplicitParam;
7 7
 import io.swagger.annotations.ApiImplicitParams;
8 8
 import io.swagger.annotations.ApiOperation;
9
-import lombok.RequiredArgsConstructor;
9
+import org.apache.commons.lang3.StringUtils;
10 10
 import org.springframework.beans.factory.annotation.Autowired;
11 11
 import org.springframework.beans.factory.annotation.Value;
12
-import org.springframework.boot.context.properties.ConfigurationProperties;
13 12
 import org.springframework.context.annotation.Bean;
14
-import org.springframework.http.HttpEntity;
15
-import org.springframework.http.HttpHeaders;
16
-import org.springframework.http.MediaType;
17
-import org.springframework.http.ResponseEntity;
13
+import org.springframework.http.*;
18 14
 import org.springframework.web.bind.annotation.RequestMapping;
19 15
 import org.springframework.web.bind.annotation.RequestMethod;
20 16
 import org.springframework.web.bind.annotation.RestController;
21 17
 import org.springframework.web.client.RestTemplate;
22 18
 
19
+import javax.servlet.http.HttpServletResponse;
20
+
23 21
 /**
24 22
  *
25 23
  * 法律规章信息库
@@ -47,7 +45,6 @@ public class LawsRegulationsInfoBaseController {
47 45
             @ApiImplicitParam(name = "pageSize", value = "页面大小", defaultValue = "10", paramType = "query")
48 46
     })
49 47
     public com.chinaitop.depot.unissoft.model.ResponseEntity<Object> getLawRegulationInfo(Integer pageNum, Integer pageSize) {
50
-        //
51 48
         String url = "http://" + host + ":" + port + "/api/safety-app/prod_system/page_info/" + pageNum + "/" + pageSize;
52 49
 
53 50
         HttpHeaders headers = new HttpHeaders();
@@ -60,6 +57,20 @@ public class LawsRegulationsInfoBaseController {
60 57
         return com.chinaitop.depot.unissoft.model.ResponseEntity.ok(response.getData());
61 58
     }
62 59
 
60
+    @RequestMapping(value = "/download", method = RequestMethod.GET)
61
+    @ApiOperation(value = "法律规章信息附件下载", notes = "下载法律规章信息附件")
62
+    @ApiImplicitParams({
63
+            @ApiImplicitParam(name = "fileId", value = "文件下载ID", paramType = "query")
64
+    })
65
+    public ResponseEntity<byte[]> downlaodFile(String fileId) {
66
+        if (StringUtils.isBlank(fileId)) {
67
+            return (ResponseEntity<byte[]>) ResponseEntity.notFound();
68
+        }
69
+        String url =  "http://" + host + ":" + port + "/api/file/file/download?id=" + fileId;
70
+        HttpEntity<String> request = new HttpEntity<>("{}");
71
+        return restTemplate.exchange(url, HttpMethod.GET, request, byte[].class);
72
+    }
73
+
63 74
     @Bean
64 75
     public RestTemplate restTemplate() {
65 76
         return new RestTemplate();