Commit 2c871b2e 2c871b2ea9695bcc00282fd265ea66ba8123c463 by 文鑫

更换网关开放平台地址

1 parent 2c1550de
......@@ -109,7 +109,7 @@ public class ApiController {
.map(t -> t.getJSONObject("userInfo"))
.map(t -> t.getString("phone"))
.filter(StrUtil::isNotBlank)
.orElseThrow(() -> new RuntimeException("获取手机号失败"));
.orElse("");
}
......@@ -121,9 +121,12 @@ public class ApiController {
* @return 用户信息
*/
@PostMapping("/user/info")
public DecodeBody<Object> getUserInfoByAuthCode(@RequestBody JSONObject data) {
public Object getUserInfoByAuthCode(@RequestBody JSONObject data) {
//通过authCode获取用户手机号
String phone = getPhone(data.getString("authCode"));
if (StrUtil.isBlank(phone)) {
return DecodeBody.fail("-1", "获取手机号失败");
}
//判断手机号是否已经注册
DecodeBody<JSONObject> register = userService.checkIsRegisterByPhoneNum(MapBuilder.<String, String>create()
.put("phoneNum", phone).build());
......
......@@ -15,4 +15,12 @@ public class DecodeBody<T> {
private String errmsg;
private T data;
public static <T> DecodeBody<T> fail(String errcode, String mesg) {
DecodeBody<T> body = new DecodeBody<>();
body.setErrcode("-1");
body.setErrmsg(mesg);
return body;
}
}
......
......@@ -66,8 +66,7 @@ public interface UserService {
*/
@Post("/cpc-ms-service-user/login/yk/privateLogin")
@Encode("${key}")
@Decode("${key}")
DecodeBody<Object> privateLogin(@EncodeBody Map<String, ?> body);
JSONObject privateLogin(@EncodeBody Map<String, ?> body);
}
......
......@@ -4,7 +4,7 @@ interface:
appIv: kfalxHTE3Np6PbQbbZhLnA==
appKey: Rd+oZa5bYfhiNK9O0dc0ng==
appSecret: x6en8WE3
url: http://23.210.52.243:44207/gateway/open/api/do
url: https://open-platform-zw.cqdcg.com/gateway/open/api/do
forest:
variables:
......
......@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.digital.szzz.gateway.sdk.bean.GatewayResponse;
import com.topdraw.dockingapi.controller.ApiController;
import com.topdraw.dockingapi.entity.DecodeBody;
import com.topdraw.dockingapi.http.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
......@@ -22,22 +21,22 @@ class DockingApiApplicationTests {
@Test
void contextLoads() {
JSONObject param = new JSONObject();
param.put("phoneNum","15636524584");
param.put("phoneNum", "15636524584");
System.out.println(userService.checkIsRegisterByPhoneNum(param));
}
@Test
void testApi() {
JSONObject param = new JSONObject();
param.put("userId","8798981653125");
param.put("userId", "8798981653125");
GatewayResponse authCodeByUserId = apiController.getAuthCodeByUserId(param);
String data = authCodeByUserId.getData();
JSONObject j = JSON.parseObject(data, JSONObject.class);
String string = j.getJSONObject("data")
.getString("authCode");
JSONObject p = new JSONObject();
p.put("authCode",string);
DecodeBody<Object> userInfoByAuthCode = apiController.getUserInfoByAuthCode(p);
p.put("authCode", string);
Object userInfoByAuthCode = apiController.getUserInfoByAuthCode(p);
System.out.println("----------------------------------------------------");
System.out.println(JSON.toJSONString(userInfoByAuthCode));
......