using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Domain.Entities.Donations.ValueObject; using Domain.Entities.Members; namespace Domain.Entities.Donations; public class DonationGoalConfig { [ForeignKey(nameof(ChannelID))] public virtual Channel? Channel { get; private set; } [ForeignKey(nameof(MemberID))] public virtual Member? Member { get; private set; } [Key] public int ID { get; private set; } public int ChannelID { get; private set; } public int MemberID { get; private set; } public string Title { get; private set; } = "후원 목표"; public GoalWidgetStyle Style { get; private set; } = GoalWidgetStyle.Simple; public int StartAmount { get; private set; } = DonationConstants.Goal.DefaultStartAmount; public int TargetAmount { get; private set; } = DonationConstants.Goal.DefaultTargetAmount; public DateTime? StartAt { get; private set; } public DateTime? EndAt { get; private set; } public bool IsShowPercent { get; private set; } = true; public string BarColor { get; private set; } = DonationConstants.Goal.DefaultBarColor; public string BarBackgroundColor { get; private set; } = DonationConstants.Goal.DefaultBarBackgroundColor; public int BarHeightPx { get; private set; } = DonationConstants.Goal.DefaultBarHeight; public int TitleFontSizePx { get; private set; } = DonationConstants.Goal.DefaultFontSize; public string TitleFontColor { get; private set; } = DonationConstants.Goal.DefaultTitleFontColor; public int AmountFontSizePx { get; private set; } = DonationConstants.Goal.DefaultFontSize; public string AmountFontColor { get; private set; } = DonationConstants.Goal.DefaultAmountFontColor; public string? TitleFontFamily { get; private set; } public string? AmountFontFamily { get; private set; } public bool IsActive { get; private set; } public DateTime? UpdatedAt { get; private set; } public DateTime CreatedAt { get; private set; } = DateTime.UtcNow; private DonationGoalConfig() { } public static DonationGoalConfig Create(int channelID, int memberID, string title, int targetAmount) { return new DonationGoalConfig { ChannelID = channelID, MemberID = memberID, Title = title, TargetAmount = targetAmount }; } public void Update( string title, GoalWidgetStyle style, int startAmount, int targetAmount, DateTime? startAt, DateTime? endAt, bool isShowPercent, string barColor, string barBackgroundColor, int barHeightPx, int titleFontSizePx, string titleFontColor, int amountFontSizePx, string amountFontColor, string? titleFontFamily, string? amountFontFamily, bool isActive ) { Title = title; Style = style; StartAmount = startAmount; TargetAmount = targetAmount; StartAt = startAt; EndAt = endAt; IsShowPercent = isShowPercent; BarColor = barColor; BarBackgroundColor = barBackgroundColor; BarHeightPx = barHeightPx; TitleFontSizePx = titleFontSizePx; TitleFontColor = titleFontColor; AmountFontSizePx = amountFontSizePx; AmountFontColor = amountFontColor; TitleFontFamily = titleFontFamily; AmountFontFamily = amountFontFamily; IsActive = isActive; UpdatedAt = DateTime.UtcNow; } }