feat: 补全 AuthController 缺失的 @Operation 和 @Parameter 注解
为 8 个缺少 OpenAPI 注解的方法补全中文描述: getCurrentUserInfo, logout, refreshToken, validateToken, getUsernameFromToken, checkAccount, checkEmail, checkPhone Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -74,6 +74,7 @@ public class AuthController {
|
|||||||
* 获取当前用户信息
|
* 获取当前用户信息
|
||||||
*/
|
*/
|
||||||
@GetMapping("/userInfo")
|
@GetMapping("/userInfo")
|
||||||
|
@Operation(summary = "获取当前用户信息", description = "根据当前登录用户的Token获取用户详细信息")
|
||||||
public Result<UserInfoResponse> getCurrentUserInfo(HttpServletRequest request) {
|
public Result<UserInfoResponse> getCurrentUserInfo(HttpServletRequest request) {
|
||||||
UserInfoResponse userInfo = tokenService.getUserInfoByToken(request);
|
UserInfoResponse userInfo = tokenService.getUserInfoByToken(request);
|
||||||
return Result.success(userInfo);
|
return Result.success(userInfo);
|
||||||
@@ -105,6 +106,7 @@ public class AuthController {
|
|||||||
* 用户登出
|
* 用户登出
|
||||||
*/
|
*/
|
||||||
@PostMapping("/logout")
|
@PostMapping("/logout")
|
||||||
|
@Operation(summary = "用户登出", description = "退出登录,清除服务端Token")
|
||||||
public Result<Void> logout(HttpServletRequest request) {
|
public Result<Void> logout(HttpServletRequest request) {
|
||||||
authService.logoutByToken(request);
|
authService.logoutByToken(request);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
@@ -114,6 +116,7 @@ public class AuthController {
|
|||||||
* 刷新访问令牌
|
* 刷新访问令牌
|
||||||
*/
|
*/
|
||||||
@PostMapping("/refreshToken")
|
@PostMapping("/refreshToken")
|
||||||
|
@Operation(summary = "刷新访问令牌", description = "使用刷新令牌获取新的访问令牌和刷新令牌")
|
||||||
public Result<AuthResponse> refreshToken(@Valid @RequestBody RefreshTokenRequest request) {
|
public Result<AuthResponse> refreshToken(@Valid @RequestBody RefreshTokenRequest request) {
|
||||||
AuthResponse response = authService.refreshToken(request.getRefreshToken());
|
AuthResponse response = authService.refreshToken(request.getRefreshToken());
|
||||||
return Result.success("令牌刷新成功", response);
|
return Result.success("令牌刷新成功", response);
|
||||||
@@ -123,6 +126,7 @@ public class AuthController {
|
|||||||
* 验证访问令牌
|
* 验证访问令牌
|
||||||
*/
|
*/
|
||||||
@GetMapping("/validateToken")
|
@GetMapping("/validateToken")
|
||||||
|
@Operation(summary = "验证访问令牌", description = "验证当前Token是否有效")
|
||||||
public Result<Boolean> validateToken(HttpServletRequest request) {
|
public Result<Boolean> validateToken(HttpServletRequest request) {
|
||||||
boolean isValid = authService.validateToken(request);
|
boolean isValid = authService.validateToken(request);
|
||||||
return Result.success(isValid);
|
return Result.success(isValid);
|
||||||
@@ -132,6 +136,7 @@ public class AuthController {
|
|||||||
* 获取用户名(通过令牌)
|
* 获取用户名(通过令牌)
|
||||||
*/
|
*/
|
||||||
@GetMapping("/username")
|
@GetMapping("/username")
|
||||||
|
@Operation(summary = "获取用户名", description = "根据Token获取当前登录用户的用户名")
|
||||||
public Result<String> getUsernameFromToken(HttpServletRequest request) {
|
public Result<String> getUsernameFromToken(HttpServletRequest request) {
|
||||||
String username = tokenService.getUsernameByToken(request);
|
String username = tokenService.getUsernameByToken(request);
|
||||||
return Result.success(username);
|
return Result.success(username);
|
||||||
@@ -141,7 +146,10 @@ public class AuthController {
|
|||||||
* 检查账号是否存在
|
* 检查账号是否存在
|
||||||
*/
|
*/
|
||||||
@GetMapping("/checkAccount")
|
@GetMapping("/checkAccount")
|
||||||
public Result<Boolean> checkAccount(@RequestParam String account) {
|
@Operation(summary = "检查账号是否存在", description = "检查指定账号是否已被注册")
|
||||||
|
public Result<Boolean> checkAccount(
|
||||||
|
@Parameter(description = "账号(手机号/邮箱/用户名)", required = true)
|
||||||
|
@RequestParam String account) {
|
||||||
boolean exists = authService.existsByAccount(account);
|
boolean exists = authService.existsByAccount(account);
|
||||||
return Result.success(exists);
|
return Result.success(exists);
|
||||||
}
|
}
|
||||||
@@ -150,7 +158,10 @@ public class AuthController {
|
|||||||
* 检查邮箱是否存在
|
* 检查邮箱是否存在
|
||||||
*/
|
*/
|
||||||
@GetMapping("/checkEmail")
|
@GetMapping("/checkEmail")
|
||||||
public Result<Boolean> checkEmail(@RequestParam String email) {
|
@Operation(summary = "检查邮箱是否存在", description = "检查指定邮箱是否已被注册")
|
||||||
|
public Result<Boolean> checkEmail(
|
||||||
|
@Parameter(description = "邮箱地址", required = true)
|
||||||
|
@RequestParam String email) {
|
||||||
boolean exists = authService.existsByEmail(email);
|
boolean exists = authService.existsByEmail(email);
|
||||||
return Result.success(exists);
|
return Result.success(exists);
|
||||||
}
|
}
|
||||||
@@ -159,7 +170,10 @@ public class AuthController {
|
|||||||
* 检查手机号是否存在
|
* 检查手机号是否存在
|
||||||
*/
|
*/
|
||||||
@GetMapping("/checkPhone")
|
@GetMapping("/checkPhone")
|
||||||
public Result<Boolean> checkPhone(@RequestParam String phone) {
|
@Operation(summary = "检查手机号是否存在", description = "检查指定手机号是否已被注册")
|
||||||
|
public Result<Boolean> checkPhone(
|
||||||
|
@Parameter(description = "手机号码", required = true)
|
||||||
|
@RequestParam String phone) {
|
||||||
boolean exists = authService.existsByPhone(phone);
|
boolean exists = authService.existsByPhone(phone);
|
||||||
return Result.success(exists);
|
return Result.success(exists);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user