mirror of
https://gitee.com/wangkang/udf.git
synced 2026-11-02 09:33:42 +00:00
更新
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<FileInfo> info(@PathVariable String fileId) throws IOException {
|
||||
return new RestResponse<>(this.fileService.getFileInfo(fileId));
|
||||
public RestResponse<FileInfo> 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
|
||||
|
||||
@@ -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<FileInfo> info(@PathVariable String fileId) throws IOException;
|
||||
required = true, dataType = "string") })
|
||||
@RequestMapping(value = "info", method = RequestMethod.POST)
|
||||
public RestResponse<FileInfo> info(@RequestBody FileParam fileParam) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -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<String, String> uriVariables = new HashMap<>();
|
||||
uriVariables.put("fileId", fileId);
|
||||
FileParam fileParam = new FileParam();
|
||||
fileParam.setId(fileId);
|
||||
//获得文件
|
||||
ResponseEntity<byte[]> file =
|
||||
rms.call("FILE_3", null, null, new ParameterizedTypeReference<byte[]>() {
|
||||
}, uriVariables);
|
||||
rms.call("FILE_3", fileParam, null, new ParameterizedTypeReference<byte[]>() {
|
||||
}, null);
|
||||
//构造resource
|
||||
ByteArrayResource bar = new ByteArrayResource(file.getBody());
|
||||
//添加静态资源
|
||||
@@ -127,16 +126,16 @@ public class MailService {
|
||||
String fileId = attachment.getFileId();
|
||||
String name = attachment.getName();
|
||||
//构造参数
|
||||
Map<String, String> uriVariables = new HashMap<>();
|
||||
uriVariables.put("fileId", fileId);
|
||||
FileParam fileParam = new FileParam();
|
||||
fileParam.setId(fileId);
|
||||
//获得文件信息
|
||||
ResponseEntity<RestResponse<FileInfo>> fileInfo = rms.call("FILE_4", null, null,
|
||||
ResponseEntity<RestResponse<FileInfo>> fileInfo = rms.call("FILE_4", fileParam, null,
|
||||
new ParameterizedTypeReference<RestResponse<FileInfo>>() {
|
||||
}, uriVariables);
|
||||
}, null);
|
||||
//获得文件
|
||||
ResponseEntity<byte[]> file =
|
||||
rms.call("FILE_3", null, null, new ParameterizedTypeReference<byte[]>() {
|
||||
}, uriVariables);
|
||||
rms.call("FILE_3", fileParam, null, new ParameterizedTypeReference<byte[]>() {
|
||||
}, null);
|
||||
//构造resource
|
||||
ByteArrayResource bar = new ByteArrayResource(file.getBody());
|
||||
//判断附件名称
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user