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

上传

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