DocSpace-client/common/ASC.Core.Common/EF/Model/User/DbGroup.cs

132 lines
4.6 KiB
C#
Raw Normal View History

2020-09-02 15:23:39 +00:00
using System;
2020-09-06 22:49:03 +00:00
using ASC.Core.Common.EF.Model;
2020-09-02 15:23:39 +00:00
using Microsoft.EntityFrameworkCore;
2019-11-25 09:49:12 +00:00
namespace ASC.Core.Common.EF
{
2019-12-17 13:01:59 +00:00
public class DbGroup : BaseEntity
2019-11-25 09:49:12 +00:00
{
public int Tenant { get; set; }
public Guid Id { get; set; }
public string Name { get; set; }
2019-12-19 14:06:18 +00:00
public Guid? CategoryId { get; set; }
public Guid? ParentId { get; set; }
2019-11-25 09:49:12 +00:00
public string Sid { get; set; }
public bool Removed { get; set; }
public DateTime LastModified { get; set; }
2019-12-17 13:01:59 +00:00
2020-02-21 12:38:04 +00:00
public override object[] GetKeys()
2019-12-17 13:01:59 +00:00
{
return new object[] { Id };
}
2019-11-25 09:49:12 +00:00
}
2020-08-21 02:34:37 +00:00
public static class DbGroupExtension
{
2020-09-06 22:49:03 +00:00
public static ModelBuilderWrapper AddDbGroup(this ModelBuilderWrapper modelBuilder)
2020-09-02 15:23:39 +00:00
{
2020-09-06 22:49:03 +00:00
modelBuilder
.Add(MySqlAddDbGroup, Provider.MySql)
2020-10-08 09:07:05 +00:00
.Add(PgSqlAddDbGroup, Provider.Postgre);
2020-09-02 15:23:39 +00:00
return modelBuilder;
}
private static void MySqlAddDbGroup(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
modelBuilder.Entity<DbGroup>(entity =>
{
entity.ToTable("core_group");
entity.HasIndex(e => e.LastModified)
.HasName("last_modified");
entity.HasIndex(e => new { e.Tenant, e.ParentId })
.HasName("parentid");
entity.Property(e => e.Id)
.HasColumnName("id")
.HasColumnType("varchar(38)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.CategoryId)
.HasColumnName("categoryid")
.HasColumnType("varchar(38)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.LastModified)
.HasColumnName("last_modified")
.HasColumnType("timestamp")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
entity.Property(e => e.Name)
.IsRequired()
.HasColumnName("name")
.HasColumnType("varchar(128)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.ParentId)
.HasColumnName("parentid")
.HasColumnType("varchar(38)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.Removed).HasColumnName("removed");
entity.Property(e => e.Sid)
.HasColumnName("sid")
.HasColumnType("varchar(512)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.Tenant).HasColumnName("tenant");
});
}
2020-09-02 15:23:39 +00:00
private static void PgSqlAddDbGroup(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
modelBuilder.Entity<DbGroup>(entity =>
{
2020-10-06 07:06:18 +00:00
entity.ToTable("core_group");
2020-08-21 02:34:37 +00:00
entity.HasIndex(e => e.LastModified)
.HasName("last_modified");
entity.HasIndex(e => new { e.Tenant, e.ParentId })
.HasName("parentid");
entity.Property(e => e.Id)
.HasColumnName("id")
.HasMaxLength(38);
entity.Property(e => e.CategoryId)
.HasColumnName("categoryid")
.HasMaxLength(38)
2020-09-06 22:49:03 +00:00
.HasDefaultValueSql("NULL");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.LastModified)
.HasColumnName("last_modified")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
entity.Property(e => e.Name)
.IsRequired()
.HasColumnName("name")
.HasMaxLength(128);
entity.Property(e => e.ParentId)
.HasColumnName("parentid")
.HasMaxLength(38)
2020-09-06 22:49:03 +00:00
.HasDefaultValueSql("NULL");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Removed).HasColumnName("removed");
entity.Property(e => e.Sid)
.HasColumnName("sid")
.HasMaxLength(512)
2020-09-29 17:09:39 +00:00
.HasDefaultValueSql("NULL");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Tenant).HasColumnName("tenant");
});
}
}
2019-11-25 09:49:12 +00:00
}