测试读取本地工程文件

20230922-ljl-fixBug
qiushengjie 1 year ago
parent d37ac1509c
commit 23bf419071

@ -1,76 +0,0 @@
package com.ms.api;
import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService;
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
import com.ms.api.common.R;
import com.ms.api.dto.ItemDTO;
import com.ms.api.dto.move.GetCurrentShopMoveSettingRequestDTO;
import com.ms.api.dto.move.GetMoveHistoryProductListRequestDTO;
import com.ms.api.dto.move.SaveBatchMoveTaskRequestDTO;
import com.ms.api.tool.DsJsonRequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
@ExtensionService("dsTestJavaRequest2")
@Slf4j
public class DsTestJavaRequest2Service implements ExtensionServiceHandler<ItemDTO, String> {
@Autowired
private DsJsonRequestTemplate dsJsonRequestTemplate;
@Override
public BaseResponse<String> handle(BaseRequest<ItemDTO> req) {
log.info("");
HashMap<String, Object> params = new HashMap<>();
List<String> arrayString = new ArrayList<>();
arrayString.add("arrayString1");
arrayString.add("arrayString2");
params.put("arrayString", arrayString);
HashMap<String, String> mapStringString = new HashMap<>();
mapStringString.put("A","mapStringString1");
mapStringString.put("B","mapStringString2");
params.put("mapStringString", mapStringString);
List<Integer> arrayInt64 = new ArrayList<>();
arrayInt64.add(10000);
arrayInt64.add(10000);
params.put("arrayInt64", 10000);
params.put("int16", 10000);
params.put("int32", 10000);
params.put("int64", 10000);
params.put("double", 10.1);
params.put("string", 10000);
params.put("struct", new GetCurrentShopMoveSettingRequestDTO());
List<Object> arrayStruct = new LinkedList<>();
arrayStruct.add(new GetCurrentShopMoveSettingRequestDTO());
arrayStruct.add(new GetMoveHistoryProductListRequestDTO());
arrayStruct.add(new SaveBatchMoveTaskRequestDTO());
params.put("arrayStruct", arrayStruct);
Map<String,Object> mapStringStruct = new HashMap<>();
mapStringStruct.put("mapstruct1", new GetCurrentShopMoveSettingRequestDTO());
mapStringStruct.put("mapstruct2", new GetMoveHistoryProductListRequestDTO());
mapStringStruct.put("mapstruct3", new SaveBatchMoveTaskRequestDTO());
params.put("mapStringStruct", mapStringStruct);
String res = null;
try {
res = dsJsonRequestTemplate.execute("/order/testJava", params);
log.info(res);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return R.ok(res);
}
}

@ -1,76 +0,0 @@
package com.ms.api;
import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService;
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
import com.ms.api.common.R;
import com.ms.api.dto.ItemDTO;
import com.ms.api.dto.move.GetCurrentShopMoveSettingRequestDTO;
import com.ms.api.dto.move.GetMoveHistoryProductListRequestDTO;
import com.ms.api.dto.move.SaveBatchMoveTaskRequestDTO;
import com.ms.api.tool.DsJsonRequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
@ExtensionService("dsTestJavaRequest")
@Slf4j
public class DsTestJavaRequestService implements ExtensionServiceHandler<ItemDTO, String> {
@Autowired
private DsJsonRequestTemplate dsJsonRequestTemplate;
@Override
public BaseResponse<String> handle(BaseRequest<ItemDTO> req) {
log.info("");
HashMap<String, Object> params = new HashMap<>();
List<String> arrayString = new ArrayList<>();
arrayString.add("arrayString1");
arrayString.add("arrayString2");
params.put("arrayString", arrayString);
HashMap<String, String> mapStringString = new HashMap<>();
mapStringString.put("A","mapStringString1");
mapStringString.put("B","mapStringString2");
params.put("mapStringString", mapStringString);
List<Integer> arrayInt64 = new ArrayList<>();
arrayInt64.add(10000);
arrayInt64.add(10000);
params.put("arrayInt64", arrayInt64);
params.put("int16", 10000);
params.put("int32", 10000);
params.put("int64", 10000);
params.put("double", 10.1);
params.put("string", 10000);
params.put("struct", new GetCurrentShopMoveSettingRequestDTO());
List<Object> arrayStruct = new LinkedList<>();
arrayStruct.add(new GetCurrentShopMoveSettingRequestDTO());
arrayStruct.add(new GetMoveHistoryProductListRequestDTO());
arrayStruct.add(new SaveBatchMoveTaskRequestDTO());
params.put("arrayStruct", arrayStruct);
Map<String,Object> mapStringStruct = new HashMap<>();
mapStringStruct.put("mapstruct1", new GetCurrentShopMoveSettingRequestDTO());
mapStringStruct.put("mapstruct2", new GetMoveHistoryProductListRequestDTO());
mapStringStruct.put("mapstruct3", new SaveBatchMoveTaskRequestDTO());
params.put("mapStringStruct", mapStringStruct);
String res = null;
try {
res = dsJsonRequestTemplate.execute("/order/testJava", params);
log.info(res);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return R.ok(res);
}
}

@ -0,0 +1,39 @@
package com.ms.api;
import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService;
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
import com.ms.api.common.R;
import com.ms.api.common.Ret;
import com.ms.api.dto.ItemDTO;
import lombok.extern.slf4j.Slf4j;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@ExtensionService("test")
@Slf4j
public class TestService implements ExtensionServiceHandler<ItemDTO, Ret> {
@Override
public BaseResponse<Ret> handle(BaseRequest<ItemDTO> req) {
String resourceFileName = "/application.properties"; // 注意路径的开头是一个斜杠
try (InputStream is = InputStream.class.getResourceAsStream(resourceFileName);
BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
return R.ok(Ret.success());
}
}
Loading…
Cancel
Save