2020-08-21 02:34:37 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2019-12-05 08:51:28 +00:00
|
|
|
|
|
|
|
|
|
namespace ASC.Core.Common.EF.Model
|
|
|
|
|
{
|
|
|
|
|
[Table("login_events")]
|
|
|
|
|
public class LoginEvents : MessageEvent
|
|
|
|
|
{
|
|
|
|
|
public string Login { get; set; }
|
|
|
|
|
}
|
2020-08-21 02:34:37 +00:00
|
|
|
|
public static class LoginEventsExtension
|
|
|
|
|
{
|
2020-09-06 22:49:03 +00:00
|
|
|
|
public static ModelBuilderWrapper AddLoginEvents(this ModelBuilderWrapper modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder
|
|
|
|
|
.Add(MySqlAddLoginEvents, Provider.MySql)
|
2020-10-08 09:07:05 +00:00
|
|
|
|
.Add(PgSqlAddLoginEvents, Provider.Postgre);
|
2020-09-06 22:49:03 +00:00
|
|
|
|
return modelBuilder;
|
|
|
|
|
}
|
|
|
|
|
public static void MySqlAddLoginEvents(this ModelBuilder modelBuilder)
|
2020-08-21 02:34:37 +00:00
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<LoginEvents>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.ToTable("login_events");
|
|
|
|
|
|
|
|
|
|
entity.HasIndex(e => e.Date)
|
|
|
|
|
.HasName("date");
|
|
|
|
|
|
|
|
|
|
entity.HasIndex(e => new { e.TenantId, e.UserId })
|
|
|
|
|
.HasName("tenant_id");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Action).HasColumnName("action");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Browser)
|
|
|
|
|
.HasColumnName("browser")
|
|
|
|
|
.HasColumnType("varchar(200)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.HasCollation("utf8_general_ci");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Date)
|
|
|
|
|
.HasColumnName("date")
|
|
|
|
|
.HasColumnType("datetime");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Description)
|
|
|
|
|
.HasColumnName("description")
|
|
|
|
|
.HasColumnType("varchar(500)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.HasCollation("utf8_general_ci");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Ip)
|
|
|
|
|
.HasColumnName("ip")
|
|
|
|
|
.HasColumnType("varchar(50)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.HasCollation("utf8_general_ci");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Login)
|
|
|
|
|
.HasColumnName("login")
|
|
|
|
|
.HasColumnType("varchar(200)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.HasCollation("utf8_general_ci");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Page)
|
|
|
|
|
.HasColumnName("page")
|
|
|
|
|
.HasColumnType("varchar(300)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.HasCollation("utf8_general_ci");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Platform)
|
|
|
|
|
.HasColumnName("platform")
|
|
|
|
|
.HasColumnType("varchar(200)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.HasCollation("utf8_general_ci");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.TenantId).HasColumnName("tenant_id");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.UserId)
|
|
|
|
|
.IsRequired()
|
|
|
|
|
.HasColumnName("user_id")
|
|
|
|
|
.HasColumnType("char(38)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.HasCollation("utf8_general_ci");
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-09-06 22:49:03 +00:00
|
|
|
|
public static void PgSqlAddLoginEvents(this ModelBuilder modelBuilder)
|
2020-08-21 02:34:37 +00:00
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<LoginEvents>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.ToTable("login_events", "onlyoffice");
|
|
|
|
|
|
|
|
|
|
entity.HasIndex(e => e.Date)
|
|
|
|
|
.HasName("date_login_events");
|
|
|
|
|
|
|
|
|
|
entity.HasIndex(e => new { e.UserId, e.TenantId })
|
|
|
|
|
.HasName("tenant_id_login_events");
|
|
|
|
|
|
2020-09-29 17:09:39 +00:00
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Action).HasColumnName("action");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Browser)
|
|
|
|
|
.HasColumnName("browser")
|
|
|
|
|
.HasMaxLength(200)
|
|
|
|
|
.HasDefaultValueSql("NULL::character varying");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Date).HasColumnName("date");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Description)
|
|
|
|
|
.HasColumnName("description")
|
|
|
|
|
.HasMaxLength(500)
|
2020-09-29 17:09:39 +00:00
|
|
|
|
.HasDefaultValueSql("NULL");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Ip)
|
|
|
|
|
.HasColumnName("ip")
|
|
|
|
|
.HasMaxLength(50)
|
2020-09-29 17:09:39 +00:00
|
|
|
|
.HasDefaultValueSql("NULL");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Login)
|
|
|
|
|
.HasColumnName("login")
|
|
|
|
|
.HasMaxLength(200)
|
2020-09-29 17:09:39 +00:00
|
|
|
|
.HasDefaultValueSql("NULL");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Page)
|
|
|
|
|
.HasColumnName("page")
|
|
|
|
|
.HasMaxLength(300)
|
2020-09-29 17:09:39 +00:00
|
|
|
|
.HasDefaultValueSql("NULL");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
|
|
|
|
entity.Property(e => e.Platform)
|
|
|
|
|
.HasColumnName("platform")
|
|
|
|
|
.HasMaxLength(200)
|
2020-09-29 17:09:39 +00:00
|
|
|
|
.HasDefaultValueSql("NULL");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
|
|
|
|
entity.Property(e => e.TenantId).HasColumnName("tenant_id");
|
|
|
|
|
|
|
|
|
|
entity.Property(e => e.UserId)
|
|
|
|
|
.IsRequired()
|
|
|
|
|
.HasColumnName("user_id")
|
|
|
|
|
.HasMaxLength(38)
|
|
|
|
|
.IsFixedLength();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-05 08:51:28 +00:00
|
|
|
|
}
|