refactor: 统一业务异常处理,标准化结果码和错误响应
1. 新增并完善ResultCode枚举,补充标准HTTP状态码对应的业务状态码 2. 重构BusinessException,新增基于ResultCode的构造函数和ThrowIf扩展方法 3. 替换所有硬编码的HTTP状态码为统一的ResultCode枚举 4. 优化全局异常中间件,根据业务状态码映射对应HTTP状态码并规范化JSON响应 5. 修复OssImageHelper和AutoDotCodeConsumer中的OSS文件处理逻辑 6. 新增用户答题快照实体类 7. 清理废弃的宠物模块迁移脚本
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using QYZH.InteractiveMagazine.Common.Extensions;
|
||||
using QYZH.InteractiveMagazine.Infrastructure.OSS;
|
||||
using QYZH.InteractiveMagazine.Models.Dto.Journal;
|
||||
using QYZH.InteractiveMagazine.Models.Entity;
|
||||
@ -65,7 +66,19 @@ public class AutoDotCodeConsumer(IConfiguration configuration,
|
||||
var uploadFilePath = uploadPdfDic + uploadFileName;
|
||||
|
||||
// 获取上传成功的书籍页码pdf文件
|
||||
var pdfSteam = await httpClientFactory.CreateClient().GetStreamAsync(journalPagePrintDtoMessage.JournalPdfUrl, cancellationToken);
|
||||
var journalPdfKey = journalPagePrintDtoMessage.JournalPdfUrl?.RemoveDomain();
|
||||
if (string.IsNullOrWhiteSpace(journalPdfKey))
|
||||
{
|
||||
logger.LogError("书籍上传的PDF文件地址为空,JournalId: {JournalId}", journalPagePrintDtoMessage.JournalId);
|
||||
return;
|
||||
}
|
||||
|
||||
await using var pdfSteam = ossService.GetObjectStream(journalPdfKey);
|
||||
if (pdfSteam == null)
|
||||
{
|
||||
logger.LogError("获取书籍上传的PDF文件失败,OSS Key: {OssKey}", journalPdfKey);
|
||||
return;
|
||||
}
|
||||
|
||||
await using (var fs = new FileStream(uploadFilePath, FileMode.CreateNew, FileAccess.Write))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user