Merge remote-tracking branch 'origin/master'
commit
e5c0df0b2f
@ -1,47 +1,45 @@
|
||||
package com.ms.api;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.common.SPIBaseService;
|
||||
import com.ms.api.dto.ItemDTO;
|
||||
import com.ms.api.tool.DsJsonRequestTemplate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@ExtensionService("testSpi")
|
||||
@Slf4j
|
||||
public class TestSpiService extends SPIBaseService implements ExtensionServiceHandler<ItemDTO, JSONObject> {
|
||||
@Autowired
|
||||
private DsJsonRequestTemplate dsJsonRequestTemplate;
|
||||
public class TestSpiService implements ExtensionServiceHandler<ItemDTO, Ret> {
|
||||
|
||||
@Override
|
||||
public BaseResponse<JSONObject> handle(BaseRequest<ItemDTO> req) {
|
||||
initHandle(req);
|
||||
getAuthCode();
|
||||
String res = null;
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("platformItemId", 1);
|
||||
params.put("sourceItemId", 33);
|
||||
params.put("authCode", authCode);
|
||||
try {
|
||||
res = dsJsonRequestTemplate.execute("/micro_move/add_platform_item_to_source_item_relation", params);
|
||||
log.info(res);
|
||||
} catch (Exception e) {
|
||||
public BaseResponse<Ret> handle(BaseRequest<ItemDTO> req) {
|
||||
|
||||
String resourceFileName = "/getProductCatTree.txt"; // 注意路径的开头是一个斜杠
|
||||
String lines = null;
|
||||
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);
|
||||
lines = lines + line;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return R.ok(JSON.parseObject(res));
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("line", lines);
|
||||
|
||||
return R.ok(Ret.success(result));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue