2022-02-15 11:52:43 +00:00
|
|
|
|
namespace ASC.Core.Common.EF;
|
|
|
|
|
|
|
|
|
|
public class DbQuota : BaseEntity, IMapFrom<TenantQuota>
|
2019-12-02 09:12:16 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
public int Tenant { get; set; }
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public string Description { get; set; }
|
|
|
|
|
public long MaxFileSize { get; set; }
|
|
|
|
|
public long MaxTotalSize { get; set; }
|
|
|
|
|
public int ActiveUsers { get; set; }
|
|
|
|
|
public string Features { get; set; }
|
|
|
|
|
public decimal Price { get; set; }
|
|
|
|
|
public string AvangateId { get; set; }
|
|
|
|
|
public bool Visible { get; set; }
|
|
|
|
|
|
|
|
|
|
public override object[] GetKeys()
|
2019-12-02 09:12:16 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
return new object[] { Tenant };
|
|
|
|
|
}
|
2022-02-15 10:30:05 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
public void Mapping(Profile profile)
|
|
|
|
|
{
|
|
|
|
|
profile.CreateMap<TenantQuota, DbQuota>()
|
|
|
|
|
.ForMember(dest => dest.MaxFileSize, opt => opt.MapFrom(src => ByteConverter.GetInMBytes(src.MaxFileSize)))
|
|
|
|
|
.ForMember(dest => dest.MaxTotalSize, opt => opt.MapFrom(src => ByteConverter.GetInMBytes(src.MaxTotalSize)));
|
2019-12-02 09:12:16 +00:00
|
|
|
|
}
|
2022-02-15 11:52:43 +00:00
|
|
|
|
}
|
|
|
|
|
public static class DbQuotaExtension
|
|
|
|
|
{
|
|
|
|
|
public static ModelBuilderWrapper AddDbQuota(this ModelBuilderWrapper modelBuilder)
|
2020-08-21 02:34:37 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
modelBuilder
|
|
|
|
|
.Add(MySqlAddDbQuota, Provider.MySql)
|
|
|
|
|
.Add(PgSqlAddDbQuota, Provider.PostgreSql)
|
|
|
|
|
.HasData(
|
|
|
|
|
new DbQuota
|
|
|
|
|
{
|
|
|
|
|
Tenant = -1,
|
|
|
|
|
Name = "default",
|
|
|
|
|
Description = null,
|
|
|
|
|
MaxFileSize = 102400,
|
|
|
|
|
MaxTotalSize = 10995116277760,
|
|
|
|
|
ActiveUsers = 10000,
|
|
|
|
|
Features = "domain,audit,controlpanel,healthcheck,ldap,sso,whitelabel,branding,ssbranding,update,support,portals:10000,discencryption,privacyroom,restore",
|
|
|
|
|
Price = decimal.Parse("0,00"),
|
|
|
|
|
AvangateId = "0",
|
|
|
|
|
Visible = false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return modelBuilder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MySqlAddDbQuota(this ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<DbQuota>(entity =>
|
2020-08-21 02:34:37 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.HasKey(e => e.Tenant)
|
|
|
|
|
.HasName("PRIMARY");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.ToTable("tenants_quota");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Tenant).HasColumnName("tenant");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.ActiveUsers).HasColumnName("active_users");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.AvangateId)
|
|
|
|
|
.HasColumnName("avangate_id")
|
|
|
|
|
.HasColumnType("varchar(128)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.UseCollation("utf8_general_ci");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Description)
|
|
|
|
|
.HasColumnName("description")
|
|
|
|
|
.HasColumnType("varchar(128)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.UseCollation("utf8_general_ci");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Features)
|
|
|
|
|
.HasColumnName("features")
|
|
|
|
|
.HasColumnType("text")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.UseCollation("utf8_general_ci");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.MaxFileSize).HasColumnName("max_file_size");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.MaxTotalSize).HasColumnName("max_total_size");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Name)
|
|
|
|
|
.HasColumnName("name")
|
|
|
|
|
.HasColumnType("varchar(128)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.UseCollation("utf8_general_ci");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Price)
|
|
|
|
|
.HasColumnName("price")
|
|
|
|
|
.HasColumnType("decimal(10,2)");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Visible).HasColumnName("visible");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
public static void PgSqlAddDbQuota(this ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<DbQuota>(entity =>
|
2020-08-21 02:34:37 +00:00
|
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.HasKey(e => e.Tenant)
|
|
|
|
|
.HasName("tenants_quota_pkey");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.ToTable("tenants_quota", "onlyoffice");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Tenant)
|
|
|
|
|
.HasColumnName("tenant")
|
|
|
|
|
.ValueGeneratedNever();
|
2020-09-29 17:09:39 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.ActiveUsers).HasColumnName("active_users");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.AvangateId)
|
|
|
|
|
.HasColumnName("avangate_id")
|
|
|
|
|
.HasMaxLength(128)
|
|
|
|
|
.HasDefaultValueSql("NULL");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Description)
|
|
|
|
|
.HasColumnName("description")
|
|
|
|
|
.HasColumnType("character varying");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Features).HasColumnName("features");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.MaxFileSize)
|
|
|
|
|
.HasColumnName("max_file_size")
|
|
|
|
|
.HasDefaultValueSql("'0'");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.MaxTotalSize)
|
|
|
|
|
.HasColumnName("max_total_size")
|
|
|
|
|
.HasDefaultValueSql("'0'");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Name)
|
|
|
|
|
.HasColumnName("name")
|
|
|
|
|
.HasColumnType("character varying");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Price)
|
|
|
|
|
.HasColumnName("price")
|
|
|
|
|
.HasColumnType("numeric(10,2)")
|
|
|
|
|
.HasDefaultValueSql("0.00");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
|
entity.Property(e => e.Visible).HasColumnName("visible");
|
|
|
|
|
});
|
2020-08-21 02:34:37 +00:00
|
|
|
|
}
|
2019-12-02 09:12:16 +00:00
|
|
|
|
}
|