feat: Domain Enum 및 에러 코드 상수 정의 (#10) #11

Merged
seonkyu.kim merged 1 commits from feature/#10-domain-enums into develop 2026-02-09 04:35:53 +00:00
23 changed files with 1066 additions and 15 deletions
Showing only changes of commit 8b6fd84b98 - Show all commits

View File

@ -0,0 +1,33 @@
namespace SPMS.Domain.Common;
/// <summary>
/// SPMS 에러 코드 상수
/// 코드 체계: [상태(0=성공,1=실패)][도메인(0~8)][순번]
/// </summary>
public static class ErrorCodes
{
// === 성공 ===
public const string Success = "000";
// === 공통 (0) ===
public const string BadRequest = "101";
public const string Unauthorized = "102";
public const string NotFound = "103";
public const string InternalError = "104";
public const string NoChange = "105";
public const string LimitExceeded = "106";
public const string Conflict = "107";
// === Auth (1) ===
public const string VerificationCodeError = "111";
public const string LoginFailed = "112";
public const string LoginAttemptExceeded = "113";
// === Account (2) ===
public const string PasswordValidationFailed = "121";
public const string ResetTokenError = "122";
// === Push (6) ===
public const string PushSendFailed = "161";
public const string PushStateChangeNotAllowed = "162";
}

View File

@ -1,3 +1,5 @@
using SPMS.Domain.Enums;
namespace SPMS.Domain.Entities;
public class Admin : BaseEntity
@ -7,7 +9,7 @@ public class Admin : BaseEntity
public string Password { get; set; } = string.Empty;
public string Phone { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public byte Role { get; set; }
public AdminRole Role { get; set; }
public bool EmailVerified { get; set; }
public DateTime? EmailVerifiedAt { get; set; }
public DateTime CreatedAt { get; set; }

View File

@ -1,10 +1,12 @@
using SPMS.Domain.Enums;
namespace SPMS.Domain.Entities;
public class Device : BaseEntity
{
public long ServiceId { get; set; }
public string DeviceToken { get; set; } = string.Empty;
public byte Platform { get; set; }
public Platform Platform { get; set; }
public string? AppVersion { get; set; }
public string? OsVersion { get; set; }
public string? DeviceModel { get; set; }

View File

@ -1,3 +1,5 @@
using SPMS.Domain.Enums;
namespace SPMS.Domain.Entities;
public class Payment : BaseEntity
@ -8,9 +10,9 @@ public class Payment : BaseEntity
public string Currency { get; set; } = string.Empty;
public string? PaymentMethod { get; set; }
public string? PaymentKey { get; set; }
public byte Status { get; set; }
public byte? TierBefore { get; set; }
public byte TierAfter { get; set; }
public PaymentStatus Status { get; set; }
public SubTier? TierBefore { get; set; }
public SubTier TierAfter { get; set; }
public DateTime PaidAt { get; set; }
public DateTime CreatedAt { get; set; }

View File

@ -1,3 +1,5 @@
using SPMS.Domain.Enums;
namespace SPMS.Domain.Entities;
public class PushSendLog : BaseEntity
@ -5,7 +7,7 @@ public class PushSendLog : BaseEntity
public long ServiceId { get; set; }
public long MessageId { get; set; }
public long DeviceId { get; set; }
public byte Status { get; set; }
public PushResult Status { get; set; }
public string? FailReason { get; set; }
public DateTime SentAt { get; set; }

View File

@ -1,3 +1,5 @@
using SPMS.Domain.Enums;
namespace SPMS.Domain.Entities;
public class Service : BaseEntity
@ -14,9 +16,9 @@ public class Service : BaseEntity
public string? FcmCredentials { get; set; }
public string? WebhookUrl { get; set; }
public string? Tags { get; set; }
public byte SubTier { get; set; }
public SubTier SubTier { get; set; }
public DateTime? SubStartedAt { get; set; }
public byte Status { get; set; }
public ServiceStatus Status { get; set; }
public DateTime CreatedAt { get; set; }
public long CreatedBy { get; set; }
public DateTime? UpdatedAt { get; set; }

View File

@ -1,12 +1,14 @@
using SPMS.Domain.Enums;
namespace SPMS.Domain.Entities;
public class WebhookLog : BaseEntity
{
public long ServiceId { get; set; }
public string WebhookUrl { get; set; } = string.Empty;
public string EventType { get; set; } = string.Empty;
public WebhookEvent EventType { get; set; }
public string Payload { get; set; } = string.Empty;
public byte Status { get; set; }
public WebhookStatus Status { get; set; }
public int? ResponseCode { get; set; }
public string? ResponseBody { get; set; }
public DateTime SentAt { get; set; }

View File

@ -0,0 +1,11 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 관리자 권한 (Admin.role)
/// </summary>
public enum AdminRole : byte
{
Super = 0,
Manager = 1,
User = 2
}

View File

@ -0,0 +1,11 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 디바이스 상태
/// </summary>
public enum DeviceStatus : byte
{
Active = 0,
Inactive = 1,
Blocked = 2
}

View File

@ -0,0 +1,11 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 링크 유형
/// </summary>
public enum LinkType : byte
{
App = 0,
Web = 1,
DeepLink = 2
}

View File

@ -0,0 +1,14 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 메시지 발송 상태
/// </summary>
public enum MessageStatus : byte
{
Draft = 0,
Pending = 1,
Sending = 2,
Sent = 3,
Failed = 4,
Cancelled = 5
}

View File

@ -0,0 +1,11 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 결제 상태 (Payment.status)
/// </summary>
public enum PaymentStatus : byte
{
Completed = 0,
Cancelled = 1,
Refunded = 2
}

View File

@ -0,0 +1,11 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 디바이스 플랫폼 (Device.platform)
/// </summary>
public enum Platform : byte
{
iOS = 0,
Android = 1,
Web = 2
}

View File

@ -0,0 +1,10 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 푸시 발송 결과 (PushSendLog.status)
/// </summary>
public enum PushResult : byte
{
Success = 0,
Failed = 1
}

View File

@ -0,0 +1,10 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 서비스 상태 (Service.status)
/// </summary>
public enum ServiceStatus : byte
{
Active = 0,
Suspended = 1
}

View File

@ -0,0 +1,11 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 구독 티어 (Service.sub_tier)
/// </summary>
public enum SubTier : byte
{
Free = 0,
Basic = 1,
Pro = 2
}

View File

@ -0,0 +1,12 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 발송 대상 유형
/// </summary>
public enum TargetType : byte
{
All = 0,
Filter = 1,
CsvFile = 2,
UserList = 3
}

View File

@ -0,0 +1,11 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 웹훅 이벤트 유형 (WebhookLog.event_type)
/// </summary>
public enum WebhookEvent : byte
{
PushSent = 0,
PushFailed = 1,
PushClicked = 2
}

View File

@ -0,0 +1,10 @@
namespace SPMS.Domain.Enums;
/// <summary>
/// 웹훅 발송 결과 (WebhookLog.status)
/// </summary>
public enum WebhookStatus : byte
{
Success = 0,
Failed = 1
}

View File

@ -0,0 +1,837 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SPMS.Infrastructure;
#nullable disable
namespace SPMS.Infrastructure.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20260209042244_ApplyDomainEnums")]
partial class ApplyDomainEnums
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
modelBuilder.Entity("SPMS.Domain.Entities.Admin", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<string>("AdminCode")
.IsRequired()
.HasMaxLength(8)
.HasColumnType("varchar(8)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<DateTime?>("DeletedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<bool>("EmailVerified")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false);
b.Property<DateTime?>("EmailVerifiedAt")
.HasColumnType("datetime(6)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false);
b.Property<DateTime?>("LastLoginAt")
.HasColumnType("datetime(6)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<string>("Phone")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<sbyte>("Role")
.HasColumnType("tinyint");
b.HasKey("Id");
b.HasIndex("AdminCode")
.IsUnique();
b.HasIndex("Email")
.IsUnique();
b.ToTable("Admin", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.DailyStat", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<int>("FailCnt")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasDefaultValue(0);
b.Property<int>("OpenCnt")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasDefaultValue(0);
b.Property<int>("SentCnt")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasDefaultValue(0);
b.Property<long>("ServiceId")
.HasColumnType("bigint");
b.Property<DateOnly>("StatDate")
.HasColumnType("date");
b.Property<int>("SuccessCnt")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasDefaultValue(0);
b.HasKey("Id");
b.HasIndex("ServiceId", "StatDate")
.IsUnique();
b.ToTable("DailyStat", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.Device", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime?>("AgreeUpdatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("AppVersion")
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("DeviceModel")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("DeviceToken")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("varchar(255)");
b.Property<bool>("IsActive")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);
b.Property<bool>("MarketingAgreed")
.HasColumnType("tinyint(1)");
b.Property<DateTime?>("MktAgreeUpdatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("OsVersion")
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<sbyte>("Platform")
.HasColumnType("tinyint");
b.Property<bool>("PushAgreed")
.HasColumnType("tinyint(1)");
b.Property<long>("ServiceId")
.HasColumnType("bigint");
b.Property<string>("Tags")
.HasColumnType("json");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("ServiceId", "DeviceToken");
b.ToTable("Device", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.FileEntity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<long>("CreatedBy")
.HasColumnType("bigint");
b.Property<string>("FileName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<string>("FilePath")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("varchar(500)");
b.Property<long>("FileSize")
.HasColumnType("bigint");
b.Property<string>("FileType")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("varchar(20)");
b.Property<string>("MimeType")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<long>("ServiceId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("CreatedBy");
b.HasIndex("ServiceId");
b.ToTable("File", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.Message", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<string>("Body")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("varchar(500)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<long>("CreatedBy")
.HasColumnType("bigint");
b.Property<string>("CustomData")
.HasColumnType("json");
b.Property<DateTime?>("DeletedAt")
.HasColumnType("datetime(6)");
b.Property<string>("ImageUrl")
.HasMaxLength(500)
.HasColumnType("varchar(500)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false);
b.Property<string>("LinkUrl")
.HasMaxLength(500)
.HasColumnType("varchar(500)");
b.Property<string>("MessageCode")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("varchar(10)");
b.Property<long>("ServiceId")
.HasColumnType("bigint");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.HasKey("Id");
b.HasIndex("CreatedBy");
b.HasIndex("MessageCode")
.IsUnique();
b.HasIndex("ServiceId");
b.ToTable("Message", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.Payment", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<long>("AdminId")
.HasColumnType("bigint");
b.Property<int>("Amount")
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Currency")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("varchar(10)");
b.Property<DateTime>("PaidAt")
.HasColumnType("datetime(6)");
b.Property<string>("PaymentKey")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("PaymentMethod")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<long>("ServiceId")
.HasColumnType("bigint");
b.Property<sbyte>("Status")
.HasColumnType("tinyint");
b.Property<sbyte>("TierAfter")
.HasColumnType("tinyint");
b.Property<sbyte?>("TierBefore")
.HasColumnType("tinyint");
b.HasKey("Id");
b.HasIndex("AdminId");
b.HasIndex("ServiceId");
b.ToTable("Payment", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.PushOpenLog", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<long>("DeviceId")
.HasColumnType("bigint");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<DateTime>("OpenedAt")
.HasColumnType("datetime(6)");
b.Property<long>("ServiceId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("DeviceId");
b.HasIndex("MessageId");
b.HasIndex("ServiceId", "OpenedAt");
b.ToTable("PushOpenLog", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.PushSendLog", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<long>("DeviceId")
.HasColumnType("bigint");
b.Property<string>("FailReason")
.HasMaxLength(200)
.HasColumnType("varchar(200)");
b.Property<long>("MessageId")
.HasColumnType("bigint");
b.Property<DateTime>("SentAt")
.HasColumnType("datetime(6)");
b.Property<long>("ServiceId")
.HasColumnType("bigint");
b.Property<sbyte>("Status")
.HasColumnType("tinyint");
b.HasKey("Id");
b.HasIndex("DeviceId");
b.HasIndex("MessageId");
b.HasIndex("ServiceId", "SentAt");
b.ToTable("PushSendLog", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.Service", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<string>("ApiKey")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<DateTime>("ApiKeyCreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("ApnsBundleId")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("ApnsKeyId")
.HasMaxLength(10)
.HasColumnType("varchar(10)");
b.Property<string>("ApnsPrivateKey")
.HasColumnType("text");
b.Property<string>("ApnsTeamId")
.HasMaxLength(10)
.HasColumnType("varchar(10)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<long>("CreatedBy")
.HasColumnType("bigint");
b.Property<DateTime?>("DeletedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Description")
.HasMaxLength(500)
.HasColumnType("varchar(500)");
b.Property<string>("FcmCredentials")
.HasColumnType("text");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
.HasDefaultValue(false);
b.Property<string>("ServiceCode")
.IsRequired()
.HasMaxLength(8)
.HasColumnType("varchar(8)");
b.Property<string>("ServiceName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<sbyte>("Status")
.HasColumnType("tinyint");
b.Property<DateTime?>("SubStartedAt")
.HasColumnType("datetime(6)");
b.Property<sbyte>("SubTier")
.HasColumnType("tinyint");
b.Property<string>("Tags")
.HasColumnType("json");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("WebhookUrl")
.HasMaxLength(500)
.HasColumnType("varchar(500)");
b.HasKey("Id");
b.HasIndex("CreatedBy");
b.HasIndex("ServiceCode")
.IsUnique();
b.ToTable("Service", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.ServiceIp", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<string>("IpAddress")
.IsRequired()
.HasMaxLength(45)
.HasColumnType("varchar(45)");
b.Property<long>("ServiceId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("ServiceId");
b.ToTable("ServiceIp", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.SystemLog", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<string>("Action")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<long?>("AdminId")
.HasColumnType("bigint");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("Details")
.HasColumnType("json");
b.Property<string>("IpAddress")
.HasMaxLength(45)
.HasColumnType("varchar(45)");
b.Property<long?>("ServiceId")
.HasColumnType("bigint");
b.Property<long?>("TargetId")
.HasColumnType("bigint");
b.Property<string>("TargetType")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("Id");
b.HasIndex("AdminId");
b.HasIndex("CreatedAt");
b.HasIndex("ServiceId");
b.ToTable("SystemLog", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.WebhookLog", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<sbyte>("EventType")
.HasColumnType("tinyint");
b.Property<string>("Payload")
.IsRequired()
.HasColumnType("json");
b.Property<string>("ResponseBody")
.HasColumnType("text");
b.Property<int?>("ResponseCode")
.HasColumnType("int");
b.Property<DateTime>("SentAt")
.HasColumnType("datetime(6)");
b.Property<long>("ServiceId")
.HasColumnType("bigint");
b.Property<sbyte>("Status")
.HasColumnType("tinyint");
b.Property<string>("WebhookUrl")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("varchar(500)");
b.HasKey("Id");
b.HasIndex("ServiceId", "SentAt");
b.ToTable("WebhookLog", (string)null);
});
modelBuilder.Entity("SPMS.Domain.Entities.DailyStat", b =>
{
b.HasOne("SPMS.Domain.Entities.Service", "Service")
.WithMany()
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Service");
});
modelBuilder.Entity("SPMS.Domain.Entities.Device", b =>
{
b.HasOne("SPMS.Domain.Entities.Service", "Service")
.WithMany("Devices")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Service");
});
modelBuilder.Entity("SPMS.Domain.Entities.FileEntity", b =>
{
b.HasOne("SPMS.Domain.Entities.Admin", "CreatedByAdmin")
.WithMany()
.HasForeignKey("CreatedBy")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("SPMS.Domain.Entities.Service", "Service")
.WithMany()
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("CreatedByAdmin");
b.Navigation("Service");
});
modelBuilder.Entity("SPMS.Domain.Entities.Message", b =>
{
b.HasOne("SPMS.Domain.Entities.Admin", "CreatedByAdmin")
.WithMany()
.HasForeignKey("CreatedBy")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("SPMS.Domain.Entities.Service", "Service")
.WithMany("Messages")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("CreatedByAdmin");
b.Navigation("Service");
});
modelBuilder.Entity("SPMS.Domain.Entities.Payment", b =>
{
b.HasOne("SPMS.Domain.Entities.Admin", "Admin")
.WithMany()
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("SPMS.Domain.Entities.Service", "Service")
.WithMany()
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Admin");
b.Navigation("Service");
});
modelBuilder.Entity("SPMS.Domain.Entities.PushOpenLog", b =>
{
b.HasOne("SPMS.Domain.Entities.Device", "Device")
.WithMany()
.HasForeignKey("DeviceId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("SPMS.Domain.Entities.Message", "Message")
.WithMany()
.HasForeignKey("MessageId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("SPMS.Domain.Entities.Service", "Service")
.WithMany()
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Device");
b.Navigation("Message");
b.Navigation("Service");
});
modelBuilder.Entity("SPMS.Domain.Entities.PushSendLog", b =>
{
b.HasOne("SPMS.Domain.Entities.Device", "Device")
.WithMany()
.HasForeignKey("DeviceId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("SPMS.Domain.Entities.Message", "Message")
.WithMany()
.HasForeignKey("MessageId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("SPMS.Domain.Entities.Service", "Service")
.WithMany()
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Device");
b.Navigation("Message");
b.Navigation("Service");
});
modelBuilder.Entity("SPMS.Domain.Entities.Service", b =>
{
b.HasOne("SPMS.Domain.Entities.Admin", "CreatedByAdmin")
.WithMany()
.HasForeignKey("CreatedBy")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("CreatedByAdmin");
});
modelBuilder.Entity("SPMS.Domain.Entities.ServiceIp", b =>
{
b.HasOne("SPMS.Domain.Entities.Service", "Service")
.WithMany("ServiceIps")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Service");
});
modelBuilder.Entity("SPMS.Domain.Entities.SystemLog", b =>
{
b.HasOne("SPMS.Domain.Entities.Admin", "Admin")
.WithMany()
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("SPMS.Domain.Entities.Service", "Service")
.WithMany()
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Admin");
b.Navigation("Service");
});
modelBuilder.Entity("SPMS.Domain.Entities.WebhookLog", b =>
{
b.HasOne("SPMS.Domain.Entities.Service", "Service")
.WithMany()
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Service");
});
modelBuilder.Entity("SPMS.Domain.Entities.Service", b =>
{
b.Navigation("Devices");
b.Navigation("Messages");
b.Navigation("ServiceIps");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SPMS.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class ApplyDomainEnums : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<sbyte>(
name: "EventType",
table: "WebhookLog",
type: "tinyint",
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50)
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "EventType",
table: "WebhookLog",
type: "varchar(50)",
maxLength: 50,
nullable: false,
oldClrType: typeof(sbyte),
oldType: "tinyint")
.Annotation("MySql:CharSet", "utf8mb4");
}
}
}

View File

@ -603,10 +603,8 @@ namespace SPMS.Infrastructure.Migrations
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<long>("Id"));
b.Property<string>("EventType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<sbyte>("EventType")
.HasColumnType("tinyint");
b.Property<string>("Payload")
.IsRequired()

View File

@ -15,7 +15,7 @@ public class WebhookLogConfiguration : IEntityTypeConfiguration<WebhookLog>
builder.Property(e => e.ServiceId).IsRequired();
builder.Property(e => e.WebhookUrl).HasMaxLength(500).IsRequired();
builder.Property(e => e.EventType).HasMaxLength(50).IsRequired();
builder.Property(e => e.EventType).HasColumnType("tinyint").IsRequired();
builder.Property(e => e.Payload).HasColumnType("json").IsRequired();
builder.Property(e => e.Status).HasColumnType("tinyint").IsRequired();
builder.Property(e => e.ResponseCode);