feat: add points rule entity configurations
This commit is contained in:
parent
7eee913c3c
commit
4830c9b2ae
@ -0,0 +1,42 @@
|
|||||||
|
using Fengling.Member.Domain.Aggregates.PointsRuleModel;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
namespace Fengling.Member.Infrastructure.EntityConfigurations;
|
||||||
|
|
||||||
|
public class PointsRuleConditionEntityConfiguration : IEntityTypeConfiguration<PointsRuleCondition>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<PointsRuleCondition> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("PointsRuleConditions");
|
||||||
|
|
||||||
|
builder.HasKey(x => x.Id);
|
||||||
|
|
||||||
|
builder.Property(x => x.Id)
|
||||||
|
.UseGuidVersion7ValueGenerator()
|
||||||
|
.HasComment("条件标识");
|
||||||
|
|
||||||
|
builder.Property(x => x.RuleId)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("关联规则标识");
|
||||||
|
|
||||||
|
builder.Property(x => x.DimensionType)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("维度类型");
|
||||||
|
|
||||||
|
builder.Property(x => x.DimensionValue)
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("维度值");
|
||||||
|
|
||||||
|
builder.Property(x => x.Operator)
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasComment("操作符");
|
||||||
|
|
||||||
|
builder.Property(x => x.CreatedAt)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("创建时间");
|
||||||
|
|
||||||
|
builder.HasIndex(x => new { x.RuleId, x.DimensionType });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
using Fengling.Member.Domain.Aggregates.PointsRuleModel;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
|
namespace Fengling.Member.Infrastructure.EntityConfigurations;
|
||||||
|
|
||||||
|
public class PointsRuleEntityConfiguration : IEntityTypeConfiguration<PointsRule>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<PointsRule> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("PointsRules");
|
||||||
|
|
||||||
|
builder.HasKey(x => x.Id);
|
||||||
|
|
||||||
|
builder.Property(x => x.Id)
|
||||||
|
.UseGuidVersion7ValueGenerator()
|
||||||
|
.HasComment("规则标识");
|
||||||
|
|
||||||
|
builder.Property(x => x.Name)
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("规则名称");
|
||||||
|
|
||||||
|
builder.Property(x => x.Code)
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("规则编码");
|
||||||
|
|
||||||
|
builder.Property(x => x.RuleType)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("规则类型");
|
||||||
|
|
||||||
|
builder.Property(x => x.BasePoints)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("基础积分");
|
||||||
|
|
||||||
|
builder.Property(x => x.WeightFactor)
|
||||||
|
.HasPrecision(18, 4)
|
||||||
|
.HasComment("权重因子");
|
||||||
|
|
||||||
|
builder.Property(x => x.ValidityDays)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("有效期天数");
|
||||||
|
|
||||||
|
builder.Property(x => x.Priority)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("优先级");
|
||||||
|
|
||||||
|
builder.Property(x => x.CalculationMode)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("计算模式");
|
||||||
|
|
||||||
|
builder.Property(x => x.IsActive)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("是否启用");
|
||||||
|
|
||||||
|
builder.Property(x => x.EffectiveFrom)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("生效开始时间");
|
||||||
|
|
||||||
|
builder.Property(x => x.EffectiveTo)
|
||||||
|
.HasComment("生效结束时间");
|
||||||
|
|
||||||
|
builder.Property(x => x.CreatedAt)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("创建时间");
|
||||||
|
|
||||||
|
builder.Property(x => x.UpdatedAt)
|
||||||
|
.IsRequired()
|
||||||
|
.HasComment("更新时间");
|
||||||
|
|
||||||
|
builder.HasMany(x => x.Conditions)
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey(x => x.RuleId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
builder.HasIndex(x => x.Code).IsUnique();
|
||||||
|
builder.HasIndex(x => x.IsActive);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user