修改
continuous-integration/drone/push Build is passing Details

Test_IRC_Net8
he 2025-11-06 11:09:16 +08:00
parent d29c150081
commit b68deafa82
10 changed files with 21265 additions and 71 deletions

View File

@ -991,7 +991,7 @@
<param name="_userInfo"></param> <param name="_userInfo"></param>
<param name="_localizer"></param> <param name="_localizer"></param>
</member> </member>
<member name="M:IRaCIS.Core.Application.Service.EmailLogService.#ctor(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailLog},IRaCIS.Core.Application.Helper.IOSSService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailRecipientLog},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.SystemEmailSendConfig},AutoMapper.IMapper,IRaCIS.Core.Domain.Share.IUserInfo,Microsoft.Extensions.Localization.IStringLocalizer)"> <member name="M:IRaCIS.Core.Application.Service.EmailLogService.#ctor(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailLog},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Trial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailAttachmentLog},IRaCIS.Core.Application.Helper.IOSSService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailRecipientLog},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.SystemEmailSendConfig},AutoMapper.IMapper,IRaCIS.Core.Domain.Share.IUserInfo,Microsoft.Extensions.Localization.IStringLocalizer)">
<summary> <summary>
邮件日志 邮件日志
</summary> </summary>
@ -15522,6 +15522,16 @@
<member name="T:IRaCIS.Core.Application.ViewModel.CommonDocumentAddOrEdit"> <member name="T:IRaCIS.Core.Application.ViewModel.CommonDocumentAddOrEdit">
<summary> CommonDocumentAddOrEdit 列表查询参数模型</summary> <summary> CommonDocumentAddOrEdit 列表查询参数模型</summary>
</member> </member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmaliAttachmentInfo.AttachmentName">
<summary>
附件名称
</summary>
</member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmaliAttachmentInfo.AttachmentPath">
<summary>
附件路径
</summary>
</member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailRecipientLogView.EmailLogId"> <member name="P:IRaCIS.Core.Application.ViewModel.EmailRecipientLogView.EmailLogId">
<summary> <summary>
邮件Id 邮件Id
@ -15562,11 +15572,6 @@
邮件主题 邮件主题
</summary> </summary>
</member> </member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailLogAddOrEdit.Attachments">
<summary>
附件
</summary>
</member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailLogAddOrEdit.EmailDate"> <member name="P:IRaCIS.Core.Application.ViewModel.EmailLogAddOrEdit.EmailDate">
<summary> <summary>
日期 日期

View File

@ -19,9 +19,23 @@ public class EmailLogView : EmailLogAddOrEdit
public List<EmailRecipientLogView> RecipientList { get; set; } public List<EmailRecipientLogView> RecipientList { get; set; }
public List<EmaliAttachmentInfo> AttachmentList { get; set; }
} }
public class EmaliAttachmentInfo
{
/// <summary>
/// 附件名称
/// </summary>
public string AttachmentName { get; set; }
/// <summary>
/// 附件路径
/// </summary>
public string AttachmentPath { get; set; }
}
public class EmailRecipientLogView public class EmailRecipientLogView
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
@ -72,11 +86,6 @@ public class EmailLogAddOrEdit
/// </summary> /// </summary>
public string EmailSubject { get; set; } = string.Empty; public string EmailSubject { get; set; } = string.Empty;
/// <summary>
/// 附件
/// </summary>
public List<EmaliAttachmentInfo> Attachments { get; set; }
/// <summary> /// <summary>
/// 日期 /// 日期
/// </summary> /// </summary>

View File

@ -35,6 +35,7 @@ namespace IRaCIS.Core.Application.Service;
[ApiExplorerSettings(GroupName = "Common")] [ApiExplorerSettings(GroupName = "Common")]
public class EmailLogService(IRepository<EmailLog> _emailLogRepository, public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
IRepository<Trial> _trialRepository, IRepository<Trial> _trialRepository,
IRepository<EmailAttachmentLog> _emailAttachmentLogRepository,
IOSSService oSSService, IOSSService oSSService,
IRepository<EmailRecipientLog> _emailRecipientLogRepository, IRepository<EmailRecipientLog> _emailRecipientLogRepository,
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig, IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
@ -102,7 +103,7 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
emailInfo.Content = message.HtmlBody ?? string.Empty; emailInfo.Content = message.HtmlBody ?? string.Empty;
if (emailInfo.Attachments.Count == 0) if (emailInfo.AttachmentList.Count == 0)
{ {
List< EmaliAttachmentInfo > attachmentInfos = new List<EmaliAttachmentInfo>(); List< EmaliAttachmentInfo > attachmentInfos = new List<EmaliAttachmentInfo>();
foreach (var att in message.Attachments) foreach (var att in message.Attachments)
@ -118,7 +119,7 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
await part.Content.DecodeToAsync(decodeStream); await part.Content.DecodeToAsync(decodeStream);
decodeStream.Position = 0; decodeStream.Position = 0;
// 3. 调你自己的 OSS 方法
emaliAttachmentInfo.AttachmentPath = await oSSService.UploadToOSSAsync( emaliAttachmentInfo.AttachmentPath = await oSSService.UploadToOSSAsync(
fileStream: decodeStream, fileStream: decodeStream,
oosFolderPath: $"EmailAttachment/{emailInfo.Id}", // OSS 虚拟目录 oosFolderPath: $"EmailAttachment/{emailInfo.Id}", // OSS 虚拟目录
@ -130,14 +131,17 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
} }
var emailLog = await _emailLogRepository.FirstOrDefaultAsync(x => x.Id == emailInfo.Id.Value); List<EmailAttachmentLog> emailAttachmentLog = attachmentInfos.Select(x => new EmailAttachmentLog()
if (emailLog != null)
{ {
emailLog.Attachments = attachmentInfos; EmailLogId = emailInfo.Id.Value,
await _emailLogRepository.SaveChangesAsync() ; AttachmentName = x.AttachmentName,
} AttachmentPath = x.AttachmentPath,
}).ToList();
emailInfo.Attachments = attachmentInfos; await _emailAttachmentLogRepository.AddRangeAsync(emailAttachmentLog);
await _emailAttachmentLogRepository.SaveChangesAsync();
emailInfo.AttachmentList = attachmentInfos;
} }
@ -267,7 +271,6 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
EmailSubject = message.Subject ?? string.Empty, EmailSubject = message.Subject ?? string.Empty,
EmailDate = message.Date.UtcDateTime, EmailDate = message.Date.UtcDateTime,
EmailStateEnum = EmailState.Success, EmailStateEnum = EmailState.Success,
Attachments = new List<EmaliAttachmentInfo>() { },
}; };
var fromMailbox = message.From.Mailboxes.FirstOrDefault(); var fromMailbox = message.From.Mailboxes.FirstOrDefault();

View File

@ -11,12 +11,16 @@ namespace IRaCIS.Core.Application.Service
public CommonConfig() public CommonConfig()
{ {
// 在此处拷贝automapper 映射 // 在此处拷贝automapper 映射
CreateMap<EmailAttachmentLog, EmaliAttachmentInfo>();
CreateMap<EmailRecipientLog, EmailRecipientLogView>(); CreateMap<EmailRecipientLog, EmailRecipientLogView>();
CreateMap<EmailLog, EmailLogView>() CreateMap<EmailLog, EmailLogView>()
.ForMember(t => t.RecipientList, u => u.MapFrom(c => c.EmailRecipientLogList)); .ForMember(t => t.RecipientList, u => u.MapFrom(c => c.EmailRecipientLogList))
.ForMember(t => t.AttachmentList, u => u.MapFrom(c => c.AttachmentList));
CreateMap<EmailLog, GetEmailInfoOutDto>() CreateMap<EmailLog, GetEmailInfoOutDto>()
.ForMember(t => t.RecipientList, u => u.MapFrom(c => c.EmailRecipientLogList)); .ForMember(t => t.RecipientList, u => u.MapFrom(c => c.EmailRecipientLogList))
.ForMember(t => t.AttachmentList, u => u.MapFrom(c => c.AttachmentList));
CreateMap<EmailLog, EmailLogAddOrEdit>().ReverseMap(); CreateMap<EmailLog, EmailLogAddOrEdit>().ReverseMap();
CreateMap<FrontAuditConfig, FrontAuditConfigAddOrEdit>().ReverseMap(); CreateMap<FrontAuditConfig, FrontAuditConfigAddOrEdit>().ReverseMap();

View File

@ -0,0 +1,30 @@
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.Domain.Models;
[Comment("邮件附件日志")]
[Table("EmailAttachmentLog")]
public class EmailAttachmentLog : BaseFullAuditEntity
{
[JsonIgnore]
[ForeignKey("EmailLogId")]
public EmailLog EmailLog { get; set; }
/// <summary>
/// 邮件Id
/// </summary>
public Guid EmailLogId { get; set; }
/// <summary>
/// 附件名称
/// </summary>
public string AttachmentName { get; set; }
/// <summary>
/// 附件路径
/// </summary>
public string AttachmentPath { get; set; }
}

View File

@ -6,9 +6,18 @@ namespace IRaCIS.Core.Domain.Models;
[Table("EmailLog")] [Table("EmailLog")]
public class EmailLog : BaseFullAuditEntity public class EmailLog : BaseFullAuditEntity
{ {
/// <summary>
/// 收件人
/// </summary>
[JsonIgnore]
public List<EmailRecipientLog> EmailRecipientLogList { get; set; } = new List<EmailRecipientLog>(); public List<EmailRecipientLog> EmailRecipientLogList { get; set; } = new List<EmailRecipientLog>();
/// <summary>
/// 附件
/// </summary>
[JsonIgnore]
public List<EmailAttachmentLog> AttachmentList { get; set; } = new List<EmailAttachmentLog>();
/// <summary> /// <summary>
/// 邮件Id /// 邮件Id
/// </summary> /// </summary>
@ -24,11 +33,6 @@ public class EmailLog : BaseFullAuditEntity
/// </summary> /// </summary>
public string EmailSubject { get; set; } = string.Empty; public string EmailSubject { get; set; } = string.Empty;
/// <summary>
/// 附件
/// </summary>
public List<EmaliAttachmentInfo> Attachments { get; set; }
/// <summary> /// <summary>
/// 日期 /// 日期
/// </summary> /// </summary>
@ -64,10 +68,5 @@ public class EmailLog : BaseFullAuditEntity
public class EmaliAttachmentInfo
{
public string AttachmentName { get; set; }
public string AttachmentPath { get; set; }
}

View File

@ -95,15 +95,6 @@ public class IRaCISDBContext : DbContext
}); });
}); });
modelBuilder.Entity<EmailLog>(entity =>
{
entity.OwnsMany(x => x.Attachments, ownedNavigationBuilder =>
{
ownedNavigationBuilder.ToJson();
});
});
#region pgsql codefirst 配置 暂时屏蔽 #region pgsql codefirst 配置 暂时屏蔽
//if (base.Database.IsNpgsql()) //if (base.Database.IsNpgsql())
//{ //{

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,73 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IRaCIS.Core.Infra.EFCore.Migrations
{
/// <inheritdoc />
public partial class EmailAttachmentLog : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Attachments",
table: "EmailLog");
migrationBuilder.CreateTable(
name: "EmailAttachmentLog",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
EmailLogId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
AttachmentName = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
AttachmentPath = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
CreateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EmailAttachmentLog", x => x.Id);
table.ForeignKey(
name: "FK_EmailAttachmentLog_EmailLog_EmailLogId",
column: x => x.EmailLogId,
principalTable: "EmailLog",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_EmailAttachmentLog_User_CreateUserId",
column: x => x.CreateUserId,
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "邮件附件日志");
migrationBuilder.CreateIndex(
name: "IX_EmailAttachmentLog_CreateUserId",
table: "EmailAttachmentLog",
column: "CreateUserId");
migrationBuilder.CreateIndex(
name: "IX_EmailAttachmentLog_EmailLogId",
table: "EmailAttachmentLog",
column: "EmailLogId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "EmailAttachmentLog");
migrationBuilder.AddColumn<string>(
name: "Attachments",
table: "EmailLog",
type: "nvarchar(max)",
nullable: true);
}
}
}

View File

@ -2300,6 +2300,48 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
}); });
}); });
modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailAttachmentLog", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<string>("AttachmentName")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b.Property<string>("AttachmentPath")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b.Property<DateTime>("CreateTime")
.HasColumnType("datetime2");
b.Property<Guid>("CreateUserId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("EmailLogId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("UpdateTime")
.HasColumnType("datetime2");
b.Property<Guid>("UpdateUserId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("CreateUserId");
b.HasIndex("EmailLogId");
b.ToTable("EmailAttachmentLog", t =>
{
t.HasComment("邮件附件日志");
});
});
modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailLog", b => modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailLog", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -16503,7 +16545,7 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
b.Navigation("CreateUserRole"); b.Navigation("CreateUserRole");
}); });
modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailLog", b => modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailAttachmentLog", b =>
{ {
b.HasOne("IRaCIS.Core.Domain.Models.UserRole", "CreateUserRole") b.HasOne("IRaCIS.Core.Domain.Models.UserRole", "CreateUserRole")
.WithMany() .WithMany()
@ -16511,36 +16553,24 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.OwnsMany("IRaCIS.Core.Domain.Models.EmaliAttachmentInfo", "Attachments", b1 => b.HasOne("IRaCIS.Core.Domain.Models.EmailLog", "EmailLog")
{ .WithMany("AttachmentList")
b1.Property<Guid>("EmailLogId") .HasForeignKey("EmailLogId")
.HasColumnType("uniqueidentifier"); .OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b1.Property<int>("Id") b.Navigation("CreateUserRole");
.ValueGeneratedOnAdd()
.HasColumnType("int");
b1.Property<string>("AttachmentName") b.Navigation("EmailLog");
.IsRequired() });
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.Property<string>("AttachmentPath") modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailLog", b =>
.IsRequired() {
.HasMaxLength(400) b.HasOne("IRaCIS.Core.Domain.Models.UserRole", "CreateUserRole")
.HasColumnType("nvarchar(400)"); .WithMany()
.HasForeignKey("CreateUserId")
b1.HasKey("EmailLogId", "Id"); .OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b1.ToTable("EmailLog");
b1.ToJson("Attachments");
b1.WithOwner()
.HasForeignKey("EmailLogId");
});
b.Navigation("Attachments");
b.Navigation("CreateUserRole"); b.Navigation("CreateUserRole");
}); });
@ -20602,6 +20632,8 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailLog", b => modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailLog", b =>
{ {
b.Navigation("AttachmentList");
b.Navigation("EmailRecipientLogList"); b.Navigation("EmailRecipientLogList");
}); });