更换网关开放平台地址
Showing
5 changed files
with
19 additions
and
10 deletions
| ... | @@ -109,7 +109,7 @@ public class ApiController { | ... | @@ -109,7 +109,7 @@ public class ApiController { |
| 109 | .map(t -> t.getJSONObject("userInfo")) | 109 | .map(t -> t.getJSONObject("userInfo")) |
| 110 | .map(t -> t.getString("phone")) | 110 | .map(t -> t.getString("phone")) |
| 111 | .filter(StrUtil::isNotBlank) | 111 | .filter(StrUtil::isNotBlank) |
| 112 | .orElseThrow(() -> new RuntimeException("获取手机号失败")); | 112 | .orElse(""); |
| 113 | 113 | ||
| 114 | } | 114 | } |
| 115 | 115 | ||
| ... | @@ -121,9 +121,12 @@ public class ApiController { | ... | @@ -121,9 +121,12 @@ public class ApiController { |
| 121 | * @return 用户信息 | 121 | * @return 用户信息 |
| 122 | */ | 122 | */ |
| 123 | @PostMapping("/user/info") | 123 | @PostMapping("/user/info") |
| 124 | public DecodeBody<Object> getUserInfoByAuthCode(@RequestBody JSONObject data) { | 124 | public Object getUserInfoByAuthCode(@RequestBody JSONObject data) { |
| 125 | //通过authCode获取用户手机号 | 125 | //通过authCode获取用户手机号 |
| 126 | String phone = getPhone(data.getString("authCode")); | 126 | String phone = getPhone(data.getString("authCode")); |
| 127 | if (StrUtil.isBlank(phone)) { | ||
| 128 | return DecodeBody.fail("-1", "获取手机号失败"); | ||
| 129 | } | ||
| 127 | //判断手机号是否已经注册 | 130 | //判断手机号是否已经注册 |
| 128 | DecodeBody<JSONObject> register = userService.checkIsRegisterByPhoneNum(MapBuilder.<String, String>create() | 131 | DecodeBody<JSONObject> register = userService.checkIsRegisterByPhoneNum(MapBuilder.<String, String>create() |
| 129 | .put("phoneNum", phone).build()); | 132 | .put("phoneNum", phone).build()); | ... | ... |
| ... | @@ -15,4 +15,12 @@ public class DecodeBody<T> { | ... | @@ -15,4 +15,12 @@ public class DecodeBody<T> { |
| 15 | private String errmsg; | 15 | private String errmsg; |
| 16 | 16 | ||
| 17 | private T data; | 17 | private T data; |
| 18 | |||
| 19 | |||
| 20 | public static <T> DecodeBody<T> fail(String errcode, String mesg) { | ||
| 21 | DecodeBody<T> body = new DecodeBody<>(); | ||
| 22 | body.setErrcode("-1"); | ||
| 23 | body.setErrmsg(mesg); | ||
| 24 | return body; | ||
| 25 | } | ||
| 18 | } | 26 | } | ... | ... |
| ... | @@ -66,8 +66,7 @@ public interface UserService { | ... | @@ -66,8 +66,7 @@ public interface UserService { |
| 66 | */ | 66 | */ |
| 67 | @Post("/cpc-ms-service-user/login/yk/privateLogin") | 67 | @Post("/cpc-ms-service-user/login/yk/privateLogin") |
| 68 | @Encode("${key}") | 68 | @Encode("${key}") |
| 69 | @Decode("${key}") | 69 | JSONObject privateLogin(@EncodeBody Map<String, ?> body); |
| 70 | DecodeBody<Object> privateLogin(@EncodeBody Map<String, ?> body); | ||
| 71 | 70 | ||
| 72 | 71 | ||
| 73 | } | 72 | } | ... | ... |
| ... | @@ -4,7 +4,7 @@ interface: | ... | @@ -4,7 +4,7 @@ interface: |
| 4 | appIv: kfalxHTE3Np6PbQbbZhLnA== | 4 | appIv: kfalxHTE3Np6PbQbbZhLnA== |
| 5 | appKey: Rd+oZa5bYfhiNK9O0dc0ng== | 5 | appKey: Rd+oZa5bYfhiNK9O0dc0ng== |
| 6 | appSecret: x6en8WE3 | 6 | appSecret: x6en8WE3 |
| 7 | url: http://23.210.52.243:44207/gateway/open/api/do | 7 | url: https://open-platform-zw.cqdcg.com/gateway/open/api/do |
| 8 | 8 | ||
| 9 | forest: | 9 | forest: |
| 10 | variables: | 10 | variables: | ... | ... |
| ... | @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON; | ... | @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | import com.digital.szzz.gateway.sdk.bean.GatewayResponse; | 5 | import com.digital.szzz.gateway.sdk.bean.GatewayResponse; |
| 6 | import com.topdraw.dockingapi.controller.ApiController; | 6 | import com.topdraw.dockingapi.controller.ApiController; |
| 7 | import com.topdraw.dockingapi.entity.DecodeBody; | ||
| 8 | import com.topdraw.dockingapi.http.UserService; | 7 | import com.topdraw.dockingapi.http.UserService; |
| 9 | import org.junit.jupiter.api.Test; | 8 | import org.junit.jupiter.api.Test; |
| 10 | import org.springframework.boot.test.context.SpringBootTest; | 9 | import org.springframework.boot.test.context.SpringBootTest; |
| ... | @@ -22,22 +21,22 @@ class DockingApiApplicationTests { | ... | @@ -22,22 +21,22 @@ class DockingApiApplicationTests { |
| 22 | @Test | 21 | @Test |
| 23 | void contextLoads() { | 22 | void contextLoads() { |
| 24 | JSONObject param = new JSONObject(); | 23 | JSONObject param = new JSONObject(); |
| 25 | param.put("phoneNum","15636524584"); | 24 | param.put("phoneNum", "15636524584"); |
| 26 | System.out.println(userService.checkIsRegisterByPhoneNum(param)); | 25 | System.out.println(userService.checkIsRegisterByPhoneNum(param)); |
| 27 | } | 26 | } |
| 28 | 27 | ||
| 29 | @Test | 28 | @Test |
| 30 | void testApi() { | 29 | void testApi() { |
| 31 | JSONObject param = new JSONObject(); | 30 | JSONObject param = new JSONObject(); |
| 32 | param.put("userId","8798981653125"); | 31 | param.put("userId", "8798981653125"); |
| 33 | GatewayResponse authCodeByUserId = apiController.getAuthCodeByUserId(param); | 32 | GatewayResponse authCodeByUserId = apiController.getAuthCodeByUserId(param); |
| 34 | String data = authCodeByUserId.getData(); | 33 | String data = authCodeByUserId.getData(); |
| 35 | JSONObject j = JSON.parseObject(data, JSONObject.class); | 34 | JSONObject j = JSON.parseObject(data, JSONObject.class); |
| 36 | String string = j.getJSONObject("data") | 35 | String string = j.getJSONObject("data") |
| 37 | .getString("authCode"); | 36 | .getString("authCode"); |
| 38 | JSONObject p = new JSONObject(); | 37 | JSONObject p = new JSONObject(); |
| 39 | p.put("authCode",string); | 38 | p.put("authCode", string); |
| 40 | DecodeBody<Object> userInfoByAuthCode = apiController.getUserInfoByAuthCode(p); | 39 | Object userInfoByAuthCode = apiController.getUserInfoByAuthCode(p); |
| 41 | System.out.println("----------------------------------------------------"); | 40 | System.out.println("----------------------------------------------------"); |
| 42 | System.out.println(JSON.toJSONString(userInfoByAuthCode)); | 41 | System.out.println(JSON.toJSONString(userInfoByAuthCode)); |
| 43 | 42 | ... | ... |
-
Please register or sign in to post a comment