Commit e68668a2 authored by guozhipeng's avatar guozhipeng

上传文件

parent 32fb5585
...@@ -2790,8 +2790,7 @@ sap.ui.define( ...@@ -2790,8 +2790,7 @@ sap.ui.define(
var headers = {};//headers: headers, var headers = {};//headers: headers,
if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) { if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) {
headers = { headers = {
'x-csrf-token': that.getStorage().get("csrfToken"), 'x-csrf-token': that.getStorage().get("csrfToken")
'Content-Type': 'application/json'
}; };
} }
headers.language=that.language; headers.language=that.language;
...@@ -3360,8 +3359,7 @@ sap.ui.define( ...@@ -3360,8 +3359,7 @@ sap.ui.define(
var headers = {};//headers: headers, var headers = {};//headers: headers,
if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) { if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) {
headers = { headers = {
'x-csrf-token': that.getStorage().get("csrfToken"), 'x-csrf-token': that.getStorage().get("csrfToken")
'Content-Type': 'application/json'
}; };
} }
headers.language=that.language; headers.language=that.language;
......
...@@ -348,8 +348,7 @@ sap.ui.define( ...@@ -348,8 +348,7 @@ sap.ui.define(
var headers = {};//headers: headers, var headers = {};//headers: headers,
if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) { if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) {
headers = { headers = {
'x-csrf-token': that.getStorage().get("csrfToken"), 'x-csrf-token': that.getStorage().get("csrfToken")
'Content-Type': 'application/json'
}; };
} }
headers.language=that.language; headers.language=that.language;
......
...@@ -341,8 +341,7 @@ sap.ui.define( ...@@ -341,8 +341,7 @@ sap.ui.define(
var headers = {};//headers: headers, var headers = {};//headers: headers,
if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) { if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) {
headers = { headers = {
'x-csrf-token': that.getStorage().get("csrfToken"), 'x-csrf-token': that.getStorage().get("csrfToken")
'Content-Type': 'application/json'
}; };
} }
headers.language=that.language; headers.language=that.language;
......
...@@ -2048,16 +2048,21 @@ sap.ui.define( ...@@ -2048,16 +2048,21 @@ sap.ui.define(
let userAuthentication = this.loginInfo.userAuthentication; let userAuthentication = this.loginInfo.userAuthentication;
let appKey = userAuthentication.appKey; let appKey = userAuthentication.appKey;
var headers = {};//headers: headers,
if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) {
headers = {
'x-csrf-token': that.getStorage().get("csrfToken")
};
}
headers.language=that.language;
headers.appKey=appKey;
$.ajax({ $.ajax({
url: this.baseUrl + "attachment/batchUpload", url: this.baseUrl + "attachment/batchUpload",
type: "POST", type: "POST",
headers: headers,
data: formData, data: formData,
processData: false, processData: false,
contentType: false, contentType: false,
headers: {
'appKey':appKey
},
success: function(res) { success: function(res) {
if(res.success){ if(res.success){
let fileList = res.result; let fileList = res.result;
......
...@@ -1871,16 +1871,21 @@ sap.ui.define( ...@@ -1871,16 +1871,21 @@ sap.ui.define(
let userAuthentication = this.loginInfo.userAuthentication; let userAuthentication = this.loginInfo.userAuthentication;
let appKey = userAuthentication.appKey; let appKey = userAuthentication.appKey;
var headers = {};//headers: headers,
if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) {
headers = {
'x-csrf-token': that.getStorage().get("csrfToken")
};
}
headers.language=that.language;
headers.appKey=appKey;
$.ajax({ $.ajax({
url: this.baseUrl + "attachment/batchUpload", url: this.baseUrl + "attachment/batchUpload",
type: "POST", type: "POST",
headers: headers,
data: formData, data: formData,
processData: false, processData: false,
contentType: false, contentType: false,
headers: {
'appKey':appKey
},
success: function(res) { success: function(res) {
if(res.success){ if(res.success){
let fileList = res.result; let fileList = res.result;
......
...@@ -4331,8 +4331,7 @@ sap.ui.define( ...@@ -4331,8 +4331,7 @@ sap.ui.define(
var headers = {};//headers: headers, var headers = {};//headers: headers,
if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) { if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) {
headers = { headers = {
'x-csrf-token': that.getStorage().get("csrfToken"), 'x-csrf-token': that.getStorage().get("csrfToken")
'Content-Type': 'application/json'
}; };
} }
headers.language=that.language; headers.language=that.language;
......
...@@ -146,6 +146,11 @@ common(){ ...@@ -146,6 +146,11 @@ common(){
starttime=`date +%s` starttime=`date +%s`
secondsToTime "${starttime}" "${starttime}" secondsToTime "${starttime}" "${starttime}"
#登录BTP 输入密码: Gzp@123456 后回车。
echo -e "\033[30;42m 登录BTP test 子账户 输入密码: Gzp@123456 后回车 \033[0m"
# 登录BTP命令:
cf login -a https://api.cf.cn40.platform.sapcloud.cn -o "Shenzhen-Lianchuangjie-Technology-Co-Ltd-test-cnrc164l" -s gzpTest -u zhipeng.guo@boscloud.cn
#校验登录状态 #校验登录状态
account=$(cf services) account=$(cf services)
accountMatch='.*succeeded.*' accountMatch='.*succeeded.*'
......
...@@ -36,6 +36,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -36,6 +36,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartResolver;
import static customer.lianchuangjie.common.util.ConvertUtils.getSuffix; import static customer.lianchuangjie.common.util.ConvertUtils.getSuffix;
...@@ -54,6 +55,8 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentDao, Attachment ...@@ -54,6 +55,8 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentDao, Attachment
private AttachmentProductBatchDao attachmentProductBatchDao; private AttachmentProductBatchDao attachmentProductBatchDao;
@Autowired @Autowired
private GoldSampleDao goldSampleDao; private GoldSampleDao goldSampleDao;
@Autowired
private MultipartResolver multipartResolver;
/** /**
* 批量上传 * 批量上传
...@@ -65,10 +68,19 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentDao, Attachment ...@@ -65,10 +68,19 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentDao, Attachment
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result<?> batchUpload(HttpServletRequest request, String language) { public Result<?> batchUpload(HttpServletRequest request, String language) {
String message = ""; String message = "";
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
List<JSONObject> results = new ArrayList<>(); List<JSONObject> results = new ArrayList<>();
// 获取原始请求对象
HttpServletRequest originalRequest = request;
while (originalRequest instanceof javax.servlet.http.HttpServletRequestWrapper) {
originalRequest = (HttpServletRequest) ((javax.servlet.http.HttpServletRequestWrapper) originalRequest).getRequest();
log.info("[originalRequest instanceof javax.servlet.http.HttpServletRequestWrapper]true");
}
if (multipartResolver.isMultipart(originalRequest)) {
log.info("[multipartResolver.isMultipart(originalRequest)]true");
MultipartHttpServletRequest multipartRequest = multipartResolver.resolveMultipart(originalRequest);
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
log.info("[fileMap.entrySet()]for");
JSONObject item = new JSONObject(); JSONObject item = new JSONObject();
MultipartFile file = entity.getValue();// 获取上传文件对象 MultipartFile file = entity.getValue();// 获取上传文件对象
try { try {
...@@ -99,6 +111,9 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentDao, Attachment ...@@ -99,6 +111,9 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentDao, Attachment
} }
} }
} }
} else {
log.info("[multipartResolver.isMultipart(originalRequest)]false");
}
if (results.size() > 0) { if (results.size() > 0) {
Result<Object> ok = Result.ok(MessageUtil.get("success", new Object[] { message }, language)); Result<Object> ok = Result.ok(MessageUtil.get("success", new Object[] { message }, language));
ok.setResult(results); ok.setResult(results);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment