DocSpace-client/common/ASC.Core.Common/EF/Model/Tenant/DbQuota.cs

144 lines
5.4 KiB
C#
Raw Normal View History

2021-02-25 09:00:53 +00:00
using ASC.Core.Common.EF.Model;
2021-05-17 11:35:00 +00:00
2020-10-05 09:56:07 +00:00
using Microsoft.EntityFrameworkCore;
2019-12-02 09:12:16 +00:00
namespace ASC.Core.Common.EF
{
2019-12-17 13:01:59 +00:00
public class DbQuota : BaseEntity
2019-12-02 09:12:16 +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 decimal Price2 { get; set; }
public string AvangateId { get; set; }
public bool Visible { get; set; }
2020-02-21 12:38:04 +00:00
public override object[] GetKeys()
2019-12-17 13:01:59 +00:00
{
return new object[] { Tenant };
}
2019-12-02 09:12:16 +00:00
}
2020-08-21 02:34:37 +00:00
public static class DbQuotaExtension
{
2020-09-06 22:49:03 +00:00
public static ModelBuilderWrapper AddDbQuota(this ModelBuilderWrapper modelBuilder)
{
modelBuilder
.Add(MySqlAddDbQuota, Provider.MySql)
2020-10-08 09:07:05 +00:00
.Add(PgSqlAddDbQuota, Provider.Postgre)
2020-10-05 09:56:07 +00:00
.HasData(
2021-05-17 11:35:00 +00:00
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"), Price2 = decimal.Parse("0,00"), AvangateId = "0", Visible = false }
2020-10-05 09:56:07 +00:00
);
2020-09-06 22:49:03 +00:00
return modelBuilder;
}
2020-10-05 09:56:07 +00:00
2020-09-06 22:49:03 +00:00
public static void MySqlAddDbQuota(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
modelBuilder.Entity<DbQuota>(entity =>
{
entity.HasKey(e => e.Tenant)
.HasName("PRIMARY");
entity.ToTable("tenants_quota");
entity.Property(e => e.Tenant).HasColumnName("tenant");
entity.Property(e => e.ActiveUsers).HasColumnName("active_users");
entity.Property(e => e.AvangateId)
.HasColumnName("avangate_id")
.HasColumnType("varchar(128)")
.HasCharSet("utf8")
2021-05-14 12:26:18 +00:00
.UseCollation("utf8_general_ci");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Description)
.HasColumnName("description")
.HasColumnType("varchar(128)")
.HasCharSet("utf8")
2021-05-14 12:26:18 +00:00
.UseCollation("utf8_general_ci");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Features)
.HasColumnName("features")
.HasColumnType("text")
.HasCharSet("utf8")
2021-05-14 12:26:18 +00:00
.UseCollation("utf8_general_ci");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.MaxFileSize).HasColumnName("max_file_size");
entity.Property(e => e.MaxTotalSize).HasColumnName("max_total_size");
entity.Property(e => e.Name)
.HasColumnName("name")
.HasColumnType("varchar(128)")
.HasCharSet("utf8")
2021-05-14 12:26:18 +00:00
.UseCollation("utf8_general_ci");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Price)
.HasColumnName("price")
.HasColumnType("decimal(10,2)");
entity.Property(e => e.Price2)
.HasColumnName("price2")
.HasColumnType("decimal(10,2)");
entity.Property(e => e.Visible).HasColumnName("visible");
});
}
2020-09-06 22:49:03 +00:00
public static void PgSqlAddDbQuota(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
modelBuilder.Entity<DbQuota>(entity =>
{
2020-09-29 17:09:39 +00:00
entity.HasKey(e => e.Tenant)
.HasName("tenants_quota_pkey");
2020-08-21 02:34:37 +00:00
entity.ToTable("tenants_quota", "onlyoffice");
2020-09-29 17:09:39 +00:00
entity.Property(e => e.Tenant)
.HasColumnName("tenant")
.ValueGeneratedNever();
2020-08-21 02:34:37 +00:00
entity.Property(e => e.ActiveUsers).HasColumnName("active_users");
entity.Property(e => e.AvangateId)
.HasColumnName("avangate_id")
.HasMaxLength(128)
2020-09-29 17:09:39 +00:00
.HasDefaultValueSql("NULL");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Description)
.HasColumnName("description")
.HasColumnType("character varying");
entity.Property(e => e.Features).HasColumnName("features");
entity.Property(e => e.MaxFileSize)
.HasColumnName("max_file_size")
2020-09-29 17:09:39 +00:00
.HasDefaultValueSql("'0'");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.MaxTotalSize)
.HasColumnName("max_total_size")
2020-09-29 17:09:39 +00:00
.HasDefaultValueSql("'0'");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Name)
.HasColumnName("name")
.HasColumnType("character varying");
entity.Property(e => e.Price)
.HasColumnName("price")
.HasColumnType("numeric(10,2)")
.HasDefaultValueSql("0.00");
entity.Property(e => e.Price2)
.HasColumnName("price2")
.HasColumnType("numeric(10,2)")
.HasDefaultValueSql("0.00");
entity.Property(e => e.Visible).HasColumnName("visible");
});
}
}
2019-12-02 09:12:16 +00:00
}