update swagger implementation

This commit is contained in:
voltsrage
2026-06-26 04:22:47 +08:00
parent 869006e5e7
commit 9777a335c5
8 changed files with 126 additions and 36 deletions
@@ -19,6 +19,7 @@ public class AuthController : ControllerBase
/// Authenticates a user and returns a JWT with role claims.
/// </summary>
[HttpPost("login")]
[AllowAnonymous]
[ProducesResponseType(typeof(ApiResponse<LoginResponse>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status422UnprocessableEntity)]
public async Task<IActionResult> Login([FromBody] LoginRequest req)
@@ -32,16 +33,13 @@ public class AuthController : ControllerBase
/// </summary>
[HttpGet("me")]
[Authorize]
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiResponse<UserProfileResponse>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status401Unauthorized)]
public async Task<IActionResult> Me()
{
var userId = Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!);
var user = await _auth.GetCurrentUserAsync(userId);
return Ok(ApiResponse<object>.Ok(new
{
user.Id, user.Username, user.FullName,
role = user.Role.ToDbString()
}));
return Ok(ApiResponse<UserProfileResponse>.Ok(new UserProfileResponse(
user.Id, user.Username, user.FullName, user.Role.ToDbString())));
}
}