Commit 67114fea by zhouhaibao

[+]引入导出工具类

1 parent b37ea21a
package cn.com.glsx.process.util;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
@SuppressWarnings("serial")
public class FileUploadServerData implements Serializable {
public static final int UPLOAD_SUCCSSS = 0; // "上传文件成功!",
public static final int UPLOAD_FAILURE = 1; // "上传文件失败!"),
//private static final int UPLOAD_TYPE_ERROR = 2; // "上传文件类型错误!"),
//private static final int UPLOAD_OVERSIZE = 3; // "上传文件过大!"),
//private static final int UPLOAD_ZEROSIZE = 4; // "上传文件为空!"),
//private static final int UPLOAD_NOTFOUND = 5; // "上传文件路径错误!")
private Integer status = 0;
private String message = "";
private String url = "";
private String systemSign;
private String filePath;
private String param1;
private String param2;
private String param3;
private String secureUrl;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getSystemSign() {
return systemSign;
}
public void setSystemSign(String systemSign) {
this.systemSign = systemSign;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getParam1() {
return param1;
}
public void setParam1(String param1) {
this.param1 = param1;
}
public String getParam2() {
return param2;
}
public void setParam2(String param2) {
this.param2 = param2;
}
public String getParam3() {
return param3;
}
public void setParam3(String param3) {
this.param3 = param3;
}
public String getSecureUrl() {
return secureUrl;
}
public void setSecureUrl(String secureUrl) {
this.secureUrl = secureUrl;
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("{");
sb.append("status:" + this.status + ",");
sb.append("message:'" + this.message + "',");
sb.append("url:'" + this.url + "',");
sb.append("systemSign:'" + this.systemSign + "',");
sb.append("filePath:'" + this.filePath + "',");
sb.append("param1:'" + this.param1 + "',");
sb.append("param2:'" + this.param2 + "',");
sb.append("param3:'" + this.param3 + "'");
sb.append("secureUrl:'" + this.secureUrl + "'");
sb.append("}");
return sb.toString();
}
public FileUploadServerData() {
}
public FileUploadServerData(HttpServletRequest request) {
this.systemSign = request.getParameter("systemSign");
this.filePath = request.getParameter("filePath");
this.param1 = request.getParameter("param1");
this.param2 = request.getParameter("param2");
this.param3 = request.getParameter("param3");
}
}
package cn.com.glsx.process.util;
import org.apache.commons.codec.binary.Base64;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.List;
/**
* @author wangxw
* @version 1.0.0
* @ClassName FileUploadUtil.java
* @description: 文件上传操作类
* @createTime 2019年11月24日 14:29:00
*/
public class FileUploadUtil {
public static final String FILE_UPLOAD_URL = "http://gfs.glsx.com.cn/file/upstring";
private static final String FILE_ZIP_URL = "http://gfs.glsx.com.cn/file/zip";
private static final String FILE_UPLOAD_TEST_URL = "http://gfs.test.glsx.com.cn/file/upstring";
// blib 供应链
// biz 业务
private static final String dir_content = "biz";
/**
* 将文件上传至文件服务器
* @param uploadData
* @param fileType
* @return
*/
public static FileUploadServerData uploadToFileSystem(String fileName, byte[] uploadData, String fileType) {
RestTemplate restTemplate = new RestTemplate();
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
form.add("systemSign", dir_content);
form.add("param1", fileName);
form.add("files", fileType + "@" + Base64.encodeBase64String(uploadData));
// return restTemplate.postForObject(FILE_UPLOAD_URL, form, FileUploadServerData.class);
return restTemplate.postForObject(FILE_UPLOAD_URL, form, FileUploadServerData.class);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!