|
@@ -1,7 +1,19 @@
|
|
|
package com.hrsk.cloud.eg.app.api;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.hrsk.cloud.eg.domain.api.*;
|
|
|
+import com.hrsk.cloud.eg.domain.api.common.ApiPayloadTypeEnum;
|
|
|
+import com.hrsk.cloud.eg.infrastructure.clinent.utils.HessianUtils;
|
|
|
+import com.hrsk.cloud.eg.infrastructure.repository.database.entity.EgApiEndpointDo;
|
|
|
+import com.hrsk.cloud.eg.infrastructure.repository.database.mapper.EgApiEndpointMapper;
|
|
|
+import com.hrsk.cloud.eg.infrastructure.service.EgApiEndpointService;
|
|
|
+import com.hrsk.cloud.eg.infrastructure.service.EgApiService;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @author: bianlanzhou
|
|
|
* @create: 2024-08-02 10:57
|
|
@@ -10,70 +22,73 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RestController
|
|
|
@RequestMapping("/api")
|
|
|
public class ApiServiceImpl {
|
|
|
-// @Resource
|
|
|
-// private EgApiEndpointMapper egApiEndpointMapper;
|
|
|
-//
|
|
|
-// @Resource
|
|
|
-// private ApiGateway apiGateway;
|
|
|
-//
|
|
|
-// @GetMapping("/save")
|
|
|
-// public void save(){
|
|
|
-// EgApiEndpointDo egApiEndpointDo = new EgApiEndpointDo();
|
|
|
-// egApiEndpointDo.setApiId(1234L);
|
|
|
-// egApiEndpointDo.setEndpointType("http");
|
|
|
-// egApiEndpointDo.setCreateUid("100000");
|
|
|
-// egApiEndpointDo.setCreateUsername("admin");
|
|
|
-// egApiEndpointDo.setModifyUid("100000");
|
|
|
-// egApiEndpointDo.setModifyUsername("admin");
|
|
|
-// egApiEndpointDo.setEndpointConfig(HessianUtils.serialize(createBean()));
|
|
|
-// egApiEndpointMapper.insert(egApiEndpointDo);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @GetMapping("/request")
|
|
|
-// public void request(){
|
|
|
-// apiGateway.request();
|
|
|
-// }
|
|
|
-//
|
|
|
-// private HttpApiConfig createBean(){
|
|
|
-// FunctionObject md5 = new FunctionObject();
|
|
|
-// md5.setCode("md5");
|
|
|
-// HttpApiConfig hac = new HttpApiConfig()
|
|
|
-// .setUrl("https://baidu.com");
|
|
|
-// hac.setContentType(ApiPayloadTypeEnum.APPLICATION_JSON.getCode());
|
|
|
-// hac.setType("http");
|
|
|
-// List<KeyValueObject> h = Lists.newArrayList();
|
|
|
-// KeyValueObject h1 = new KeyValueObject();
|
|
|
-// h1.setKey("secretKey");
|
|
|
-// h1.setType("text");
|
|
|
-// h1.setValue("Khw99%$l%-2gF7P4jXglp_-jQqQirtYnOY5D");
|
|
|
-// h.add(h1);
|
|
|
-// KeyValueObject h2 = new KeyValueObject();
|
|
|
-// h2.setKey("merchantNo");
|
|
|
-// h2.setType("spel");
|
|
|
-// h2.setValue("#param.realName");
|
|
|
-// h.add(h2);
|
|
|
-// List<ValueObject> p = Lists.newArrayList();
|
|
|
-// ValueObject p1 = new ValueObject();
|
|
|
-// p1.setType("text");
|
|
|
-// p1.setValue("123");
|
|
|
-// ValueObject p2 = new ValueObject();
|
|
|
-// p2.setType("text");
|
|
|
-// p2.setValue("456");
|
|
|
-// p2.getFunctions().add(md5);
|
|
|
-// p.add(p1);
|
|
|
-// p.add(p2);
|
|
|
-// List<KeyValueObject> s = Lists.newArrayList();
|
|
|
-// KeyValueObject s1 = new KeyValueObject();
|
|
|
-// s1.setKey("username");
|
|
|
-// s1.setType("spel");
|
|
|
-// s1.setValue("#param.username");
|
|
|
-// KeyValueObject s2 = new KeyValueObject();
|
|
|
-// s2.setKey("channel");
|
|
|
-// s2.setType("spel");
|
|
|
-// s2.setValue("#param.channel");
|
|
|
-// s.add(s2);
|
|
|
-// hac.setPath(p).setSearch(s).setHeader(h).setMethod("GET");
|
|
|
-// hac.setContent("{\"merchant\":\"xxxxxxfffff\",\"phone\":\"#{\\\"value\\\":\\\"#param.userMobile\\\",\\\"type\\\": \\\"spel\\\",\\\"functions\\\":[ {\\\"code\\\": \\\"md5\\\"}]}\"}");
|
|
|
-// return hac;
|
|
|
-// }
|
|
|
+ @Resource
|
|
|
+ private EgApiService egApiService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private EgApiEndpointService egApiEndpointService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ApiGateway apiGateway;
|
|
|
+
|
|
|
+ @GetMapping("/save")
|
|
|
+ public void save(){
|
|
|
+ EgApiEndpointDo egApiEndpointDo = new EgApiEndpointDo();
|
|
|
+ egApiEndpointDo.setApiId(1234L);
|
|
|
+ egApiEndpointDo.setApiCode("http");
|
|
|
+ egApiEndpointDo.setCreateUid("100000");
|
|
|
+ egApiEndpointDo.setCreateUsername("admin");
|
|
|
+ egApiEndpointDo.setModifyUid("100000");
|
|
|
+ egApiEndpointDo.setModifyUsername("admin");
|
|
|
+ egApiEndpointDo.setApiConfig(HessianUtils.serialize(createBean()));
|
|
|
+ egApiEndpointService.save(egApiEndpointDo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/request")
|
|
|
+ public void request(){
|
|
|
+ apiGateway.request();
|
|
|
+ }
|
|
|
+
|
|
|
+ private HttpApiConfig createBean(){
|
|
|
+ FunctionObject md5 = new FunctionObject();
|
|
|
+ md5.setCode("md5");
|
|
|
+ HttpApiConfig hac = new HttpApiConfig()
|
|
|
+ .setUrl("https://baidu.com");
|
|
|
+ hac.setContentType(ApiPayloadTypeEnum.APPLICATION_JSON.getCode());
|
|
|
+ hac.setType("http");
|
|
|
+ List<KeyValueObject> h = Lists.newArrayList();
|
|
|
+ KeyValueObject h1 = new KeyValueObject();
|
|
|
+ h1.setKey("secretKey");
|
|
|
+ h1.setType("text");
|
|
|
+ h1.setValue("Khw99%$l%-2gF7P4jXglp_-jQqQirtYnOY5D");
|
|
|
+ h.add(h1);
|
|
|
+ KeyValueObject h2 = new KeyValueObject();
|
|
|
+ h2.setKey("merchantNo");
|
|
|
+ h2.setType("spel");
|
|
|
+ h2.setValue("#param.realName");
|
|
|
+ h.add(h2);
|
|
|
+ List<ValueObject> p = Lists.newArrayList();
|
|
|
+ ValueObject p1 = new ValueObject();
|
|
|
+ p1.setType("text");
|
|
|
+ p1.setValue("123");
|
|
|
+ ValueObject p2 = new ValueObject();
|
|
|
+ p2.setType("text");
|
|
|
+ p2.setValue("456");
|
|
|
+ p2.getFunctions().add(md5);
|
|
|
+ p.add(p1);
|
|
|
+ p.add(p2);
|
|
|
+ List<KeyValueObject> s = Lists.newArrayList();
|
|
|
+ KeyValueObject s1 = new KeyValueObject();
|
|
|
+ s1.setKey("username");
|
|
|
+ s1.setType("spel");
|
|
|
+ s1.setValue("#param.username");
|
|
|
+ KeyValueObject s2 = new KeyValueObject();
|
|
|
+ s2.setKey("channel");
|
|
|
+ s2.setType("spel");
|
|
|
+ s2.setValue("#param.channel");
|
|
|
+ s.add(s2);
|
|
|
+ hac.setPath(p).setSearch(s).setHeader(h).setMethod("GET");
|
|
|
+ hac.setContent("{\"merchant\":\"xxxxxxfffff\",\"phone\":\"#{\\\"value\\\":\\\"#param.userMobile\\\",\\\"type\\\": \\\"spel\\\",\\\"functions\\\":[ {\\\"code\\\": \\\"md5\\\"}]}\"}");
|
|
|
+ return hac;
|
|
|
+ }
|
|
|
}
|