修复
This commit is contained in:
		@@ -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)
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user