diff --git a/udf-starter-file/src/main/java/com/egridcloud/udf/file/domain/FileParam.java b/udf-starter-file/src/main/java/com/egridcloud/udf/file/domain/FileParam.java new file mode 100644 index 0000000..95d4406 --- /dev/null +++ b/udf-starter-file/src/main/java/com/egridcloud/udf/file/domain/FileParam.java @@ -0,0 +1,52 @@ +/** + * FileParam.java + * Created at 2017-05-27 + * Created by Administrator + * Copyright (C) 2016 egridcloud.com, All rights reserved. + */ +package com.egridcloud.udf.file.domain; + +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * 描述 : FileParam + * + * @author Administrator + * + */ +@ApiModel(description = "文件参数") +public class FileParam implements Serializable { + + /** + * 描述 : ID + */ + private static final long serialVersionUID = 1L; + + /** + * 描述 : 文件ID + */ + @ApiModelProperty(value = "文件ID(相对路径的base64编码)", required = true, dataType = "string") + private String id; + + /** + * 描述 : 获取id + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * 描述 : 设置id + * + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + +} diff --git a/udf-starter-file/src/main/java/com/egridcloud/udf/file/web/FileController.java b/udf-starter-file/src/main/java/com/egridcloud/udf/file/web/FileController.java index 81823a7..fa596d9 100644 --- a/udf-starter-file/src/main/java/com/egridcloud/udf/file/web/FileController.java +++ b/udf-starter-file/src/main/java/com/egridcloud/udf/file/web/FileController.java @@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.FileSystemResource; -import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -22,6 +22,7 @@ import com.egridcloud.udf.core.ApplicationConfig; import com.egridcloud.udf.core.RestResponse; import com.egridcloud.udf.file.FileProperties; import com.egridcloud.udf.file.domain.FileInfo; +import com.egridcloud.udf.file.domain.FileParam; import com.egridcloud.udf.file.service.FileService; /** @@ -63,13 +64,14 @@ public class FileController implements IFileController { } @Override - public void load(@PathVariable String fileId, HttpServletResponse response) throws IOException { - this.loadFile(fileId, response); + public void download(@RequestBody FileParam fileParam, HttpServletResponse response) + throws IOException { + this.loadFile(fileParam.getId(), response); } @Override - public RestResponse info(@PathVariable String fileId) throws IOException { - return new RestResponse<>(this.fileService.getFileInfo(fileId)); + public RestResponse info(@RequestBody FileParam fileParam) throws IOException { + return new RestResponse<>(this.fileService.getFileInfo(fileParam.getId())); } /** @@ -79,8 +81,7 @@ public class FileController implements IFileController { * @param response 响应对象 * @throws IOException IOException */ - private void loadFile(@PathVariable String fileId, HttpServletResponse response) - throws IOException { + private void loadFile(String fileId, HttpServletResponse response) throws IOException { //获得文件信息 FileInfo fileInfo = this.fileService.getFileInfo(fileId); //设置response diff --git a/udf-starter-file/src/main/java/com/egridcloud/udf/file/web/IFileController.java b/udf-starter-file/src/main/java/com/egridcloud/udf/file/web/IFileController.java index 77595ef..8d8e9cb 100644 --- a/udf-starter-file/src/main/java/com/egridcloud/udf/file/web/IFileController.java +++ b/udf-starter-file/src/main/java/com/egridcloud/udf/file/web/IFileController.java @@ -10,7 +10,7 @@ import java.io.IOException; import javax.servlet.http.HttpServletResponse; -import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.multipart.MultipartFile; @@ -18,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile; import com.egridcloud.udf.core.RestResponse; import com.egridcloud.udf.file.FileProperties; import com.egridcloud.udf.file.domain.FileInfo; +import com.egridcloud.udf.file.domain.FileParam; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -90,11 +91,10 @@ public interface IFileController { @ApiImplicitParam(paramType = "header", name = "rmsSign", value = "rms认证秘钥", required = true, dataType = "string"), @ApiImplicitParam(paramType = "header", name = "rmsServiceCode", value = "rms接口编号", - required = true, dataType = "string"), - @ApiImplicitParam(paramType = "path", name = "fileId", value = "文件ID", required = true, - dataType = "string") }) - @RequestMapping(value = "{fileId}", method = RequestMethod.GET) - public void load(@PathVariable String fileId, HttpServletResponse response) throws IOException; + required = true, dataType = "string") }) + @RequestMapping(value = "download", method = RequestMethod.POST) + public void download(@RequestBody FileParam fileParam, HttpServletResponse response) + throws IOException; /** * 描述 : 通过文件ID访问文件 @@ -110,10 +110,8 @@ public interface IFileController { @ApiImplicitParam(paramType = "header", name = "rmsSign", value = "rms认证秘钥", required = true, dataType = "string"), @ApiImplicitParam(paramType = "header", name = "rmsServiceCode", value = "rms接口编号", - required = true, dataType = "string"), - @ApiImplicitParam(paramType = "path", name = "fileId", value = "文件ID", required = true, - dataType = "string") }) - @RequestMapping(value = "info/{fileId}", method = RequestMethod.GET) - public RestResponse info(@PathVariable String fileId) throws IOException; + required = true, dataType = "string") }) + @RequestMapping(value = "info", method = RequestMethod.POST) + public RestResponse info(@RequestBody FileParam fileParam) throws IOException; } diff --git a/udf-starter-mail/src/main/java/com/egridcloud/udf/mail/service/MailService.java b/udf-starter-mail/src/main/java/com/egridcloud/udf/mail/service/MailService.java index 0061e17..61aa83c 100644 --- a/udf-starter-mail/src/main/java/com/egridcloud/udf/mail/service/MailService.java +++ b/udf-starter-mail/src/main/java/com/egridcloud/udf/mail/service/MailService.java @@ -7,8 +7,6 @@ package com.egridcloud.udf.mail.service; import java.util.Date; -import java.util.HashMap; -import java.util.Map; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; @@ -31,6 +29,7 @@ import com.egridcloud.udf.mail.domain.AttachmentInfo; import com.egridcloud.udf.mail.domain.InlineInfo; import com.egridcloud.udf.mail.domain.MailInfo; import com.egridcloud.udf.mail.vo.file.FileInfo; +import com.egridcloud.udf.mail.vo.file.FileParam; import com.egridcloud.udf.rms.Rms; /** @@ -107,12 +106,12 @@ public class MailService { String fileId = inlineInfo.getFileId(); String name = inlineInfo.getName(); //构造参数 - Map uriVariables = new HashMap<>(); - uriVariables.put("fileId", fileId); + FileParam fileParam = new FileParam(); + fileParam.setId(fileId); //获得文件 ResponseEntity file = - rms.call("FILE_3", null, null, new ParameterizedTypeReference() { - }, uriVariables); + rms.call("FILE_3", fileParam, null, new ParameterizedTypeReference() { + }, null); //构造resource ByteArrayResource bar = new ByteArrayResource(file.getBody()); //添加静态资源 @@ -127,16 +126,16 @@ public class MailService { String fileId = attachment.getFileId(); String name = attachment.getName(); //构造参数 - Map uriVariables = new HashMap<>(); - uriVariables.put("fileId", fileId); + FileParam fileParam = new FileParam(); + fileParam.setId(fileId); //获得文件信息 - ResponseEntity> fileInfo = rms.call("FILE_4", null, null, + ResponseEntity> fileInfo = rms.call("FILE_4", fileParam, null, new ParameterizedTypeReference>() { - }, uriVariables); + }, null); //获得文件 ResponseEntity file = - rms.call("FILE_3", null, null, new ParameterizedTypeReference() { - }, uriVariables); + rms.call("FILE_3", fileParam, null, new ParameterizedTypeReference() { + }, null); //构造resource ByteArrayResource bar = new ByteArrayResource(file.getBody()); //判断附件名称 diff --git a/udf-starter-mail/src/main/java/com/egridcloud/udf/mail/vo/file/FileParam.java b/udf-starter-mail/src/main/java/com/egridcloud/udf/mail/vo/file/FileParam.java new file mode 100644 index 0000000..2386fe0 --- /dev/null +++ b/udf-starter-mail/src/main/java/com/egridcloud/udf/mail/vo/file/FileParam.java @@ -0,0 +1,52 @@ +/** + * FileParam.java + * Created at 2017-05-27 + * Created by Administrator + * Copyright (C) 2016 egridcloud.com, All rights reserved. + */ +package com.egridcloud.udf.mail.vo.file; + +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * 描述 : FileParam + * + * @author Administrator + * + */ +@ApiModel(description = "文件参数") +public class FileParam implements Serializable { + + /** + * 描述 : ID + */ + private static final long serialVersionUID = 1L; + + /** + * 描述 : 文件ID + */ + @ApiModelProperty(value = "文件ID(相对路径的base64编码)", required = true, dataType = "string") + private String id; + + /** + * 描述 : 获取id + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * 描述 : 设置id + * + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + +}