healchow commented on code in PR #7793:
URL: https://github.com/apache/inlong/pull/7793#discussion_r1160579045


##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongStreamController.java:
##########
@@ -183,4 +191,22 @@ public Response<List<StreamField>> 
parseFields(@RequestBody ParseFieldRequest pa
         return Response.success(streamService.parseFields(parseFieldRequest));
     }
 
+    @RequestMapping(value = "/stream/fieldsImportTemplate", method = 
RequestMethod.GET)
+    @ApiOperation(value = "Download fields import template")
+    public void downloadFieldsImportTemplate(HttpServletResponse response) {

Review Comment:
   Suggest return true of false for the API method, you can wrap it with 
`Response`.



##########
inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongStreamController.java:
##########
@@ -183,4 +191,22 @@ public Response<List<StreamField>> 
parseFields(@RequestBody ParseFieldRequest pa
         return Response.success(streamService.parseFields(parseFieldRequest));
     }
 
+    @RequestMapping(value = "/stream/fieldsImportTemplate", method = 
RequestMethod.GET)
+    @ApiOperation(value = "Download fields import template")
+    public void downloadFieldsImportTemplate(HttpServletResponse response) {
+        String date = 
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss"));
+        String fileName = 
String.format("InLong-stream-fields-template-%s.xlsx", date);
+        response.setHeader("Content-Disposition",
+                "attachment;filename=" + fileName);
+        response.setContentType("multipart/form-data");
+
+        try {
+            ServletOutputStream outputStream = response.getOutputStream();
+            ExcelTool.write(StreamField.class, outputStream);
+
+        } catch (IOException e) {
+            log.error("Can not properly download Excel file", e);

Review Comment:
   If error, please throw an `BusinessException`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to