Commit 6c948840 authored by 张永's avatar 张永

上传

parent 5cc0dd71
......@@ -3,6 +3,7 @@ package com.egolm.admin.controller;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -28,6 +29,7 @@ import com.egolm.admin.util.AdminContstrant;
import com.egolm.common.DateUtil;
import com.egolm.common.FileUtil;
import com.egolm.common.HttpUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import io.swagger.annotations.Api;
......@@ -73,15 +75,14 @@ public class OSSFileController {
})
@RequestMapping(value = "/upload",method=RequestMethod.POST) //
public String upload(@RequestParam("file") MultipartFile file,HttpServletRequest request) throws IOException {
String[] codes = new String[2];
codes[0] = AdminContstrant.OSS_UPLOAD_CONFIG_KEY;
codes[1] = AdminContstrant.OSS_UPLOAD_SECRET_KEY;
List<TSystemCtrl> listCtl = systemCtlService.getTSystemCtrlByCode(codes);
List<String> codeList = new ArrayList<String>();
codeList.add(AdminContstrant.OSS_UPLOAD_CONFIG_KEY);
codeList.add(AdminContstrant.OSS_UPLOAD_SECRET_KEY);
System.out.println("-----"+StringUtil.join(",",codeList));
List<Map<String,Object>> listCtl = systemCtlService.getTSystemCtrlByCode(codeList);
if(listCtl.isEmpty() || listCtl.size() !=2 ) {
return Rjx.jsonErr().setCode(-100).setMessage("请检查"+codes[0]+ "和"+codes[1]+" 参数是否配置").toJson();
return Rjx.jsonErr().setCode(-100).setMessage("请检查"+StringUtil.join(",",codeList)+"参数是否配置").toJson();
}
String ossUrl = ""; //上传的URL
......@@ -92,17 +93,17 @@ public class OSSFileController {
String secret = ""; // 自建OSS平台分配的 密钥
for(TSystemCtrl ctrl:listCtl) {
String code = ctrl.getsCode();
if(code.equals(codes[0])) {
ossUrl = ctrl.getsValue1();
httpUrl = ctrl.getsValue2();
documentID = ctrl.getsValue3();
dir = ctrl.getsValue4();
for(Map<String,Object> ctrlMap:listCtl) {
String code = ctrlMap.get("sCode")+"";
if(code.equals(AdminContstrant.OSS_UPLOAD_CONFIG_KEY)) {
ossUrl = ctrlMap.get("sValue1")+""; //ctrl.getsValue1();
httpUrl = ctrlMap.get("sValue2")+"";//ctrl.getsValue2();
documentID = ctrlMap.get("sValue3")+"";// ctrl.getsValue3();
dir = ctrlMap.get("sValue4")+"";// ctrl.getsValue4();
}
if(code.equals(codes[1])) {
appID = ctrl.getsValue1();
secret = ctrl.getsValue2();
if(code.equals(AdminContstrant.OSS_UPLOAD_SECRET_KEY)) {
appID = ctrlMap.get("sValue1")+""; //ctrl.getsValue1();
secret =ctrlMap.get("sValue2")+""; // ctrl.getsValue2();
}
}
......@@ -175,14 +176,14 @@ public class OSSFileController {
public String testUpload(HttpServletRequest request) throws IOException {
String uFilePath = request.getParameter("uFilePath");
String[] codes = new String[2];
codes[0] = AdminContstrant.OSS_UPLOAD_CONFIG_KEY;
codes[1] = AdminContstrant.OSS_UPLOAD_SECRET_KEY;
List<String> codeList = new ArrayList<String>();
codeList.add(AdminContstrant.OSS_UPLOAD_CONFIG_KEY);
codeList.add(AdminContstrant.OSS_UPLOAD_SECRET_KEY);
List<TSystemCtrl> listCtl = systemCtlService.getTSystemCtrlByCode(codes);
List<Map<String,Object>> listCtl = systemCtlService.getTSystemCtrlByCode(codeList);
if(listCtl.isEmpty() || listCtl.size() !=2 ) {
return Rjx.jsonErr().setCode(-100).setMessage("请检查"+codes[0]+ "和"+codes[1]+" 参数是否配置").toJson();
return Rjx.jsonErr().setCode(-100).setMessage("请检查"+StringUtil.join(",",codeList)+"参数是否配置").toJson();
}
String ossUrl = ""; //上传的URL
......@@ -193,17 +194,17 @@ public class OSSFileController {
String secret = ""; // 自建OSS平台分配的 密钥
for(TSystemCtrl ctrl:listCtl) {
String code = ctrl.getsCode();
if(code.equals(codes[0])) {
ossUrl = ctrl.getsValue1();
httpUrl = ctrl.getsValue2();
documentID = ctrl.getsValue3();
dir = ctrl.getsValue4();
for(Map<String,Object> ctrlMap:listCtl) {
String code = ctrlMap.get("sCode")+"";
if(code.equals(AdminContstrant.OSS_UPLOAD_CONFIG_KEY)) {
ossUrl = ctrlMap.get("sValue1")+""; //ctrl.getsValue1();
httpUrl = ctrlMap.get("sValue2")+"";//ctrl.getsValue2();
documentID = ctrlMap.get("sValue3")+"";// ctrl.getsValue3();
dir = ctrlMap.get("sValue4")+"";// ctrl.getsValue4();
}
if(code.equals(codes[1])) {
appID = ctrl.getsValue1();
secret = ctrl.getsValue2();
if(code.equals(AdminContstrant.OSS_UPLOAD_SECRET_KEY)) {
appID = ctrlMap.get("sValue1")+""; //ctrl.getsValue1();
secret =ctrlMap.get("sValue2")+""; // ctrl.getsValue2();
}
}
......
......@@ -7,5 +7,5 @@ import com.egolm.admin.pojo.TSystemCtrl;
public interface SystemCtlService {
public List<TSystemCtrl> getTSystemCtrlByCode(String[] codes);
public List<Map<String,Object>> getTSystemCtrlByCode(List<String> codeList);
}
......@@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
import com.egolm.admin.pojo.TSystemCtrl;
import com.egolm.admin.service.SystemCtlService;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
/**
......@@ -26,9 +27,11 @@ public class SystemCtlServiceImpl implements SystemCtlService {
private JdbcTemplate jdbcTemplate;
@Override
public List<TSystemCtrl> getTSystemCtrlByCode(String[] codes) {
String sql = "select * from tSystemCtrl where sCode in ? and nTag&1=0";
return jdbcTemplate.queryForList(sql, TSystemCtrl.class, codes);
public List<Map<String,Object>> getTSystemCtrlByCode(List<String> codeList) {
String orgStr = StringUtil.join( "','","'","'",codeList);
System.out.println(orgStr);
String sql = "select * from tSystemCtrl where sCode in ("+orgStr+") and nTag&1=0";
return jdbcTemplate.queryForList(sql);
}
}
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