lrj
3 天以前 7ba080d35812e6db7bd5aa8f88161c02653eb6c1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.rongyichuang.auth;
 
import com.rongyichuang.auth.api.AuthGraphqlApi;
import com.rongyichuang.auth.dto.LoginRequest;
import com.rongyichuang.auth.dto.LoginResponse;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
 
@SpringBootTest
public class GraphQLLoginTest {
 
    @Autowired
    private AuthGraphqlApi authGraphqlApi;
 
    @Test
    public void testGraphQLLogin() {
        try {
            System.out.println("=== 开始测试GraphQL API层登录方法 ===");
            
            LoginRequest request = new LoginRequest();
            request.setPhone("13800000001");
            request.setPassword("123456");
            
            System.out.println("登录请求: phone=" + request.getPhone() + ", password=" + request.getPassword());
            
            LoginResponse response = authGraphqlApi.webLogin(request);
            
            System.out.println("GraphQL登录成功!");
            System.out.println("Token: " + response.getToken());
            System.out.println("用户ID: " + response.getUserInfo().getUserId());
            System.out.println("用户名: " + response.getUserInfo().getName());
            System.out.println("用户类型: " + response.getUserInfo().getUserType());
            
        } catch (Exception e) {
            System.err.println("GraphQL登录失败: " + e.getMessage());
            e.printStackTrace();
        }
    }
}