修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
d29c150081
commit
b68deafa82
|
|
@ -991,7 +991,7 @@
|
|||
<param name="_userInfo"></param>
|
||||
<param name="_localizer"></param>
|
||||
</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>
|
||||
|
|
@ -15522,6 +15522,16 @@
|
|||
<member name="T:IRaCIS.Core.Application.ViewModel.CommonDocumentAddOrEdit">
|
||||
<summary> CommonDocumentAddOrEdit 列表查询参数模型</summary>
|
||||
</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">
|
||||
<summary>
|
||||
邮件Id
|
||||
|
|
@ -15562,11 +15572,6 @@
|
|||
邮件主题
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:IRaCIS.Core.Application.ViewModel.EmailLogAddOrEdit.Attachments">
|
||||
<summary>
|
||||
附件
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:IRaCIS.Core.Application.ViewModel.EmailLogAddOrEdit.EmailDate">
|
||||
<summary>
|
||||
日期
|
||||
|
|
|
|||
|
|
@ -19,9 +19,23 @@ public class EmailLogView : EmailLogAddOrEdit
|
|||
|
||||
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 Guid Id { get; set; }
|
||||
|
|
@ -72,11 +86,6 @@ public class EmailLogAddOrEdit
|
|||
/// </summary>
|
||||
public string EmailSubject { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 附件
|
||||
/// </summary>
|
||||
public List<EmaliAttachmentInfo> Attachments { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日期
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ namespace IRaCIS.Core.Application.Service;
|
|||
[ApiExplorerSettings(GroupName = "Common")]
|
||||
public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
|
||||
IRepository<Trial> _trialRepository,
|
||||
IRepository<EmailAttachmentLog> _emailAttachmentLogRepository,
|
||||
IOSSService oSSService,
|
||||
IRepository<EmailRecipientLog> _emailRecipientLogRepository,
|
||||
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
|
||||
|
|
@ -102,7 +103,7 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
|
|||
emailInfo.Content = message.HtmlBody ?? string.Empty;
|
||||
|
||||
|
||||
if (emailInfo.Attachments.Count == 0)
|
||||
if (emailInfo.AttachmentList.Count == 0)
|
||||
{
|
||||
List< EmaliAttachmentInfo > attachmentInfos = new List<EmaliAttachmentInfo>();
|
||||
foreach (var att in message.Attachments)
|
||||
|
|
@ -118,7 +119,7 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
|
|||
await part.Content.DecodeToAsync(decodeStream);
|
||||
decodeStream.Position = 0;
|
||||
|
||||
// 3. 调你自己的 OSS 方法
|
||||
|
||||
emaliAttachmentInfo.AttachmentPath = await oSSService.UploadToOSSAsync(
|
||||
fileStream: decodeStream,
|
||||
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);
|
||||
if (emailLog != null)
|
||||
List<EmailAttachmentLog> emailAttachmentLog = attachmentInfos.Select(x => new EmailAttachmentLog()
|
||||
{
|
||||
emailLog.Attachments = attachmentInfos;
|
||||
await _emailLogRepository.SaveChangesAsync() ;
|
||||
}
|
||||
EmailLogId = emailInfo.Id.Value,
|
||||
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,
|
||||
EmailDate = message.Date.UtcDateTime,
|
||||
EmailStateEnum = EmailState.Success,
|
||||
Attachments = new List<EmaliAttachmentInfo>() { },
|
||||
};
|
||||
|
||||
var fromMailbox = message.From.Mailboxes.FirstOrDefault();
|
||||
|
|
|
|||
|
|
@ -11,12 +11,16 @@ namespace IRaCIS.Core.Application.Service
|
|||
public CommonConfig()
|
||||
{
|
||||
// 在此处拷贝automapper 映射
|
||||
|
||||
CreateMap<EmailAttachmentLog, EmaliAttachmentInfo>();
|
||||
CreateMap<EmailRecipientLog, EmailRecipientLogView>();
|
||||
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>()
|
||||
.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<FrontAuditConfig, FrontAuditConfigAddOrEdit>().ReverseMap();
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -6,9 +6,18 @@ namespace IRaCIS.Core.Domain.Models;
|
|||
[Table("EmailLog")]
|
||||
public class EmailLog : BaseFullAuditEntity
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 收件人
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<EmailRecipientLog> EmailRecipientLogList { get; set; } = new List<EmailRecipientLog>();
|
||||
|
||||
/// <summary>
|
||||
/// 附件
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<EmailAttachmentLog> AttachmentList { get; set; } = new List<EmailAttachmentLog>();
|
||||
|
||||
/// <summary>
|
||||
/// 邮件Id
|
||||
/// </summary>
|
||||
|
|
@ -24,11 +33,6 @@ public class EmailLog : BaseFullAuditEntity
|
|||
/// </summary>
|
||||
public string EmailSubject { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 附件
|
||||
/// </summary>
|
||||
public List<EmaliAttachmentInfo> Attachments { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日期
|
||||
/// </summary>
|
||||
|
|
@ -64,10 +68,5 @@ public class EmailLog : BaseFullAuditEntity
|
|||
|
||||
|
||||
|
||||
public class EmaliAttachmentInfo
|
||||
{
|
||||
public string AttachmentName { get; set; }
|
||||
|
||||
public string AttachmentPath { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,15 +95,6 @@ public class IRaCISDBContext : DbContext
|
|||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity<EmailLog>(entity =>
|
||||
{
|
||||
entity.OwnsMany(x => x.Attachments, ownedNavigationBuilder =>
|
||||
{
|
||||
ownedNavigationBuilder.ToJson();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
#region pgsql codefirst 配置 暂时屏蔽
|
||||
//if (base.Database.IsNpgsql())
|
||||
//{
|
||||
|
|
|
|||
21048
IRaCIS.Core.Infra.EFCore/Migrations/20251106030434_EmailAttachmentLog.Designer.cs
generated
Normal file
21048
IRaCIS.Core.Infra.EFCore/Migrations/20251106030434_EmailAttachmentLog.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
@ -16503,7 +16545,7 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
|
|||
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")
|
||||
.WithMany()
|
||||
|
|
@ -16511,36 +16553,24 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
|
|||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.OwnsMany("IRaCIS.Core.Domain.Models.EmaliAttachmentInfo", "Attachments", b1 =>
|
||||
{
|
||||
b1.Property<Guid>("EmailLogId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
b.HasOne("IRaCIS.Core.Domain.Models.EmailLog", "EmailLog")
|
||||
.WithMany("AttachmentList")
|
||||
.HasForeignKey("EmailLogId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b1.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
b.Navigation("CreateUserRole");
|
||||
|
||||
b1.Property<string>("AttachmentName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(400)
|
||||
.HasColumnType("nvarchar(400)");
|
||||
|
||||
b1.Property<string>("AttachmentPath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(400)
|
||||
.HasColumnType("nvarchar(400)");
|
||||
|
||||
b1.HasKey("EmailLogId", "Id");
|
||||
|
||||
b1.ToTable("EmailLog");
|
||||
|
||||
b1.ToJson("Attachments");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("EmailLogId");
|
||||
b.Navigation("EmailLog");
|
||||
});
|
||||
|
||||
b.Navigation("Attachments");
|
||||
modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailLog", b =>
|
||||
{
|
||||
b.HasOne("IRaCIS.Core.Domain.Models.UserRole", "CreateUserRole")
|
||||
.WithMany()
|
||||
.HasForeignKey("CreateUserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CreateUserRole");
|
||||
});
|
||||
|
|
@ -20602,6 +20632,8 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
|
|||
|
||||
modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailLog", b =>
|
||||
{
|
||||
b.Navigation("AttachmentList");
|
||||
|
||||
b.Navigation("EmailRecipientLogList");
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue