DockingApiApplicationTests.java 1.51 KB
package com.topdraw.dockingapi;

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;

import javax.annotation.Resource;

@SpringBootTest
class DockingApiApplicationTests {

    @Resource
    private UserService userService;
    @Resource
    private ApiController apiController;

    @Test
    void contextLoads() {
        JSONObject param = new JSONObject();
        param.put("phoneNum","15636524584");
        System.out.println(userService.checkIsRegisterByPhoneNum(param));
    }

    @Test
    void testApi() {
        JSONObject param = new JSONObject();
        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);
        System.out.println("----------------------------------------------------");
        System.out.println(JSON.toJSONString(userInfoByAuthCode));

    }

}