RequestUtils.java
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
*
* Copyright (c) 2001-2019 泛微软件.
* 泛微协同商务系统,版权所有.
*
*/
package com.weaver.esb.util;
import java.util.*;
/**
* <p>Title: ${file_name}</p>
* <p>Description: </p>
*
* @author SJZ
* @version 1.0
* @date 2019/5/31
*/
public class RequestUtils {
/**
* 参数处理
* @param params 参数定义
* @param values 映射内容对应值
* @return
*/
public static Map<String,Object> formartParams( List<RequestParamBean> params, Map<String,Object> values){
Map<String,Object> data = new HashMap<>();
for( RequestParamBean paramBean : params){
String assign = paramBean.getAssign();
if(assign != null && !assign.isEmpty()) {
Object value = values.get(paramBean.getAssign());
if (paramBean.isArrs() && value instanceof List) {
List<Object> list = (List) value;
List<Map<String, Object>> childData = new ArrayList<>();
Map<String, Object> tempValues = new HashMap<>();
tempValues.putAll(values);
for (Object obj : list) {
if(obj instanceof Map) {
tempValues.putAll((Map<String, Object>) obj);
childData.add(formartParams(paramBean.getChilds(), tempValues));
}
}
data.put(paramBean.getParamName(), childData);
} else {
data.put(paramBean.getParamName(), value);
}
} else if (paramBean.getChilds() != null && !paramBean.getChilds().isEmpty()) {
Map<String, Object> childData = formartParams(paramBean.getChilds(), values);
data.put(paramBean.getParamName(), childData);
} else {
data.put(paramBean.getParamName(), "");
}
}
return data;
}
}