外部服务管理测试

20230922-ljl-fixBug
qiushengjie 1 year ago
parent b4d150c6c4
commit eab6a3abac

@ -28,7 +28,7 @@ public class DsTestJavaRequestService implements ExtensionServiceHandler<ItemDTO
@Override
public BaseResponse<String> handle(BaseRequest<ItemDTO> req) {
MultiValueMap<String, Object> params = new UniqueKeyMultiValueMap<>();
HashMap<String, Object> params = new HashMap<>();
// List arrayString = new ArrayList<String>();
// arrayString.add("arrayString1");
@ -38,7 +38,7 @@ public class DsTestJavaRequestService implements ExtensionServiceHandler<ItemDTO
// HashMap<String, Object> mapStringString = new HashMap<>();
// mapStringString.put("A","mapStringString1");
// mapStringString.put("B","mapStringString2");
// params.add("mapStringString", mapStringString);
// params.put("mapStringString", mapStringString);
//
// List arrayInt64 = new ArrayList<Integer>();
// arrayInt64.add(10000);
@ -49,7 +49,7 @@ public class DsTestJavaRequestService implements ExtensionServiceHandler<ItemDTO
// params.add("int32", String.valueOf(10000));
// params.add("int64", String.valueOf(10000));
// params.add("double", String.valueOf(10.1));
params.add("string", "test");
params.put("string", "test");
// params.put("boolean", JSON.toJSONString(true));
// params.put("struct", );

@ -2,17 +2,16 @@ package com.ms.api.tool;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSON;
import com.ms.api.common.UniqueKeyMultiValueMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Set;
/**
@ -61,7 +60,7 @@ public class DsJsonRequestTemplate {
headers.set("x-app-name", "msddMicro");
// 使用json方式更符合外部服务管理
headers.setContentType(MediaType.APPLICATION_JSON);
MultiValueMap<String,Object> params = (UniqueKeyMultiValueMap<String,Object>)body;
HashMap<String,Object> params = (HashMap<String,Object>)body;
// 构建签名
Set<String> keySet = params.keySet();
String[] keyArray = keySet.toArray(new String[0]);
@ -69,7 +68,7 @@ public class DsJsonRequestTemplate {
StringBuilder sb = new StringBuilder();
sb.append(dsToken);
for (String s : keyArray) {
sb.append(s).append(JSON.toJSONString(params.getFirst(s)));
sb.append(s).append(JSON.toJSONString(params.get(s)));
}
sb.append(dsToken);
String sign = SecureUtil.md5(sb.toString());

Loading…
Cancel
Save