feat: Add new WebClientBase Blazor application and MktZaloService API, and update WhatsAppService and MktXService infrastructure.
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WebClientBase.Shared;
|
||||
using WebClientBase.Shared.DTOs;
|
||||
|
||||
namespace WebClientBase.Server.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// EN: Authentication API controller.
|
||||
/// VI: Auth API controller.
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class AuthController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// EN: Register a new user.
|
||||
/// VI: Đăng ký user mới.
|
||||
/// </summary>
|
||||
/// <param name="request">Registration data with validation</param>
|
||||
[HttpPost("register")]
|
||||
[ProducesResponseType(typeof(ApiResponse<UserProfileDto>), StatusCodes.Status201Created)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
public ActionResult<ApiResponse<UserProfileDto>> Register([FromBody] RegisterDto request)
|
||||
{
|
||||
// EN: [ApiController] validates before this code runs
|
||||
// VI: [ApiController] validate trước khi code này chạy
|
||||
|
||||
// EN: Demo - create user profile
|
||||
// VI: Demo - tạo user profile
|
||||
var profile = new UserProfileDto
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Email = request.Email,
|
||||
DisplayName = request.DisplayName,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
return CreatedAtAction(nameof(GetProfile), new { id = profile.Id }, ApiResponse<UserProfileDto>.Ok(profile));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EN: Login with email and password.
|
||||
/// VI: Đăng nhập với email và mật khẩu.
|
||||
/// </summary>
|
||||
[HttpPost("login")]
|
||||
[ProducesResponseType(typeof(ApiResponse<UserProfileDto>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status401Unauthorized)]
|
||||
public ActionResult<ApiResponse<UserProfileDto>> Login([FromBody] LoginDto request)
|
||||
{
|
||||
// EN: Demo - always succeed with mock profile
|
||||
// VI: Demo - luôn thành công với profile giả
|
||||
var profile = new UserProfileDto
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Email = request.Email,
|
||||
DisplayName = "Demo User",
|
||||
CreatedAt = DateTime.UtcNow.AddDays(-30)
|
||||
};
|
||||
|
||||
return Ok(ApiResponse<UserProfileDto>.Ok(profile));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// EN: Get user profile by ID.
|
||||
/// VI: Lấy user profile theo ID.
|
||||
/// </summary>
|
||||
[HttpGet("profile/{id:guid}")]
|
||||
[ProducesResponseType(typeof(ApiResponse<UserProfileDto>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status404NotFound)]
|
||||
public ActionResult<ApiResponse<UserProfileDto>> GetProfile(Guid id)
|
||||
{
|
||||
// EN: Demo - return mock profile
|
||||
// VI: Demo - trả về profile giả
|
||||
var profile = new UserProfileDto
|
||||
{
|
||||
Id = id,
|
||||
Email = "demo@example.com",
|
||||
DisplayName = "Demo User",
|
||||
AvatarUrl = "https://example.com/avatar.jpg",
|
||||
CreatedAt = DateTime.UtcNow.AddDays(-30)
|
||||
};
|
||||
|
||||
return Ok(ApiResponse<UserProfileDto>.Ok(profile));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user