|
@@ -13,6 +13,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
|
|
@@ -52,12 +53,17 @@ public class CommonApi {
|
|
|
public Object queryApi(@RequestHeader Map<String, String> token, @RequestBody Map<String, Object> params) {
|
|
|
Map<String, Object> stringObjectMap;
|
|
|
if (params.containsKey("id") && !params.containsKey("serviceId")) {
|
|
|
- params.put("serviceId",params.get("id"));
|
|
|
- params.put("event", "0");
|
|
|
- params.remove("id");
|
|
|
+ Map<String, Object> callBack = new HashMap<>();
|
|
|
+ callBack.put("serviceId", "200241");
|
|
|
+ callBack.put("dataContent", params);
|
|
|
+ callBack.put("event", "0");
|
|
|
+ stringObjectMap = commonInterface(token, callBack, "0");
|
|
|
+ } else {
|
|
|
+ stringObjectMap = commonInterface(token, params, "0");
|
|
|
}
|
|
|
- return commonInterface(token, params, "0");
|
|
|
+ return stringObjectMap;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 新增入口CRUD
|
|
|
*/
|
|
@@ -92,22 +98,25 @@ public class CommonApi {
|
|
|
* 统一接收处理
|
|
|
*/
|
|
|
private Map<String, Object> commonInterface(Map<String, String> token, Map<String, Object> params, String defaultEvent) {
|
|
|
- if (token.containsKey("token")) {
|
|
|
- String appToken = token.get("token");
|
|
|
- String verificationToke = authApplication.verificationToken(appToken);
|
|
|
- if (!MapTools.isNumber(verificationToke)) {
|
|
|
- HashMap<String, Object> errMap = new HashMap<>();
|
|
|
- errMap.put("code", "-1");
|
|
|
- errMap.put("message", "应用token验证失败:" + verificationToke);
|
|
|
- return errMap;
|
|
|
- }
|
|
|
- } else {
|
|
|
- String verificationToke = authApplication.verificationUserToken(token);
|
|
|
- if (!MapTools.isBlank(verificationToke)) {
|
|
|
- HashMap<String, Object> errMap = new HashMap<>();
|
|
|
- errMap.put("code", "-1");
|
|
|
- errMap.put("message", "用户令牌验证失败:" + verificationToke);
|
|
|
- return errMap;
|
|
|
+ if (!params.containsKey("id")) {
|
|
|
+ if (token.containsKey("token")) {
|
|
|
+ String appToken = token.get("token");
|
|
|
+ String verificationToke = authApplication.verificationToken(appToken);
|
|
|
+ if (!MapTools.isNumber(verificationToke)) {
|
|
|
+ HashMap<String, Object> errMap = new HashMap<>();
|
|
|
+ errMap.put("code", "-1");
|
|
|
+ errMap.put("message", "应用token验证失败:" + verificationToke);
|
|
|
+ return errMap;
|
|
|
+ }
|
|
|
+ params.remove("id");
|
|
|
+ } else {
|
|
|
+ String verificationToke = authApplication.verificationUserToken(token);
|
|
|
+ if (!MapTools.isBlank(verificationToke)) {
|
|
|
+ HashMap<String, Object> errMap = new HashMap<>();
|
|
|
+ errMap.put("code", "-1");
|
|
|
+ errMap.put("message", "用户令牌验证失败:" + verificationToke);
|
|
|
+ return errMap;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
Object event = params.get("event");//获取参数中的事件标识
|
|
@@ -164,13 +173,24 @@ public class CommonApi {
|
|
|
|
|
|
|
|
|
@PostMapping("/upload")
|
|
|
- public Object upload(@RequestParam(value = "file") MultipartFile excelFile, @RequestParam(value = "serviceId") String serviceID, @RequestParam(value = "token") String token) throws Exception {
|
|
|
+ public Object upload(@RequestParam(value = "file") MultipartFile excelFile, @RequestParam(value = "serviceId") String serviceID ,@RequestHeader Map<String,Object> requestHeader) throws Exception {
|
|
|
if (excelFile.isEmpty()) {
|
|
|
return MapTools.processFail("文件夹为空,重新上传");
|
|
|
} else {
|
|
|
+ String userName = "";
|
|
|
+ if (requestHeader.containsKey("user_id")){
|
|
|
+ MyDbHelper myDbHelper = ObjectMap.getordropMyDbHelper(AppConfig.REMOTE_DB_CONNECT);
|
|
|
+ Map<String, Object> userId = myDbHelper.queryByParamsReturnList("SELECT user_name FROM t_user WHERE user_id = ?", Objects.toString(requestHeader.get("user_id")));
|
|
|
+ Object o = userId.get("returnData");
|
|
|
+ if (o instanceof List<?> tpList && !tpList.isEmpty() && tpList.get(0) instanceof Map currentMap ){
|
|
|
+ userName = Objects.toString(currentMap.get("user_name"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
String fileName = excelFile.getOriginalFilename();
|
|
|
InputStream is = excelFile.getInputStream();
|
|
|
- Map<String, Object> uploadFile = importExcelUtils.upload(fileName, is);
|
|
|
+ Map<String, Object> uploadFile = importExcelUtils.upload(fileName, is,userName);
|
|
|
if ("-1".equals(uploadFile.get("code"))) {
|
|
|
return uploadFile;
|
|
|
}
|