package com.rongyichuang.auth; import com.rongyichuang.auth.dto.LoginRequest; import com.rongyichuang.auth.dto.LoginResponse; import com.rongyichuang.auth.service.AuthService; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest public class DirectLoginTest { @Autowired private AuthService authService; @Test public void testDirectLogin() { try { System.out.println("=== 开始直接测试AuthService登录方法 ==="); LoginRequest request = new LoginRequest(); request.setPhone("13800000001"); request.setPassword("123456"); System.out.println("登录请求: phone=" + request.getPhone() + ", password=" + request.getPassword()); LoginResponse response = authService.login(request); System.out.println("登录成功!"); 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("登录失败: " + e.getMessage()); e.printStackTrace(); } } }