v0.1.4 登录测试完成
parent
a59daa1894
commit
8b7c53671f
2
pom.xml
2
pom.xml
|
|
@ -73,6 +73,7 @@
|
|||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
<version>1.18.36</version>
|
||||
</dependency>
|
||||
|
||||
<!--JWT token依赖 -->
|
||||
|
|
@ -95,6 +96,7 @@
|
|||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.36</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.bruce.sams.controller;
|
|||
import com.bruce.sams.domain.entity.LoginRequest;
|
||||
import com.bruce.sams.service.AuthService;
|
||||
import com.bruce.sams.utils.AjaxResult;
|
||||
import com.bruce.sams.Constant.HttpStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -25,8 +24,10 @@ public class AuthController {
|
|||
*/
|
||||
@PostMapping("/login")
|
||||
public AjaxResult login(@RequestBody LoginRequest loginRequest) {
|
||||
System.out.println(loginRequest);
|
||||
// 认证成功,返回 JWT 令牌
|
||||
String token = authService.authenticate(loginRequest);
|
||||
System.out.println(AjaxResult.success("登录成功", token).toString());
|
||||
return AjaxResult.success("登录成功", token);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ public class GlobalExceptionHandler {
|
|||
*/
|
||||
@ExceptionHandler(CustomException.class)
|
||||
public AjaxResult handleCustomException(CustomException e) {
|
||||
System.out.println(AjaxResult.error(e.getCode(), e.getMessage()));
|
||||
return AjaxResult.error(e.getCode(), e.getMessage());
|
||||
}
|
||||
|
||||
|
|
@ -24,6 +25,7 @@ public class GlobalExceptionHandler {
|
|||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public AjaxResult handleException(Exception e) {
|
||||
System.out.println(AjaxResult.error(500, "服务器内部错误:" + e.getMessage()));
|
||||
return AjaxResult.error(500, "服务器内部错误:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue