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