This commit is contained in:
2025-10-16 16:21:22 +08:00
parent dd398c1c32
commit 311d6dab8f
222 changed files with 188 additions and 21595 deletions

View File

@@ -47,6 +47,39 @@ namespace FutureMailAPI.Controllers
result);
}
// 兼容前端请求格式的创建邮件接口
[HttpPost("create")]
public async Task<IActionResult> CreateMailCompat([FromBody] SentMailCreateCompatDto createDto)
{
if (!ModelState.IsValid)
{
return BadRequest(ApiResponse<SentMailResponseDto>.ErrorResult("输入数据无效"));
}
// 从JWT令牌中获取当前用户ID
var currentUserId = GetCurrentUserId();
if (currentUserId <= 0)
{
return Unauthorized(ApiResponse<SentMailResponseDto>.ErrorResult("未授权访问"));
}
// 转换为内部DTO
var internalDto = createDto.ToInternalDto();
var result = await _mailService.CreateMailAsync(currentUserId, internalDto);
if (!result.Success)
{
return BadRequest(result);
}
return CreatedAtAction(
nameof(GetMail),
new { mailId = result.Data!.Id },
result);
}
[HttpGet("{mailId}")]
public async Task<IActionResult> GetMail(int mailId)
{