DocSpace-buildtools/common/ASC.Core.Common/EF/Model/DbipLocation.cs

207 lines
7.1 KiB
C#
Raw Normal View History

2020-11-17 10:00:01 +00:00
using System.ComponentModel.DataAnnotations.Schema;
2020-10-12 16:23:15 +00:00
2020-11-17 10:00:01 +00:00
using Microsoft.EntityFrameworkCore;
2019-12-13 13:05:24 +00:00
namespace ASC.Core.Common.EF.Model
{
[Table("dbip_location")]
public class DbipLocation
{
public int Id { get; set; }
[Column("addr_type")]
public string AddrType { get; set; }
[Column("ip_start")]
public string IPStart { get; set; }
[Column("ip_end")]
public string IPEnd { get; set; }
public string Country { get; set; }
public string StateProv { get; set; }
public string District { get; set; }
public string City { get; set; }
public string ZipCode { get; set; }
public long Latitude { get; set; }
public long Longitude { get; set; }
[Column("geoname_id")]
public int GeonameId { get; set; }
[Column("timezone_offset")]
public double TimezoneOffset { get; set; }
[Column("timezone_name")]
public string TimezoneName { get; set; }
public int Processed { get; set; }
}
2020-08-21 02:34:37 +00:00
public static class DbipLocationExtension
{
2020-09-06 22:49:03 +00:00
public static ModelBuilderWrapper AddDbipLocation(this ModelBuilderWrapper modelBuilder)
{
2020-10-12 19:39:23 +00:00
modelBuilder
2020-09-06 22:49:03 +00:00
.Add(MySqlAddDbipLocation, Provider.MySql)
2020-10-08 09:07:05 +00:00
.Add(PgSqlAddDbipLocation, Provider.Postgre);
2020-09-06 22:49:03 +00:00
return modelBuilder;
}
public static void MySqlAddDbipLocation(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
2020-10-12 19:39:23 +00:00
modelBuilder.Entity<DbipLocation>(entity =>
2020-08-21 02:34:37 +00:00
{
2020-10-12 19:39:23 +00:00
entity.ToTable("dbip_location");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.HasIndex(e => e.IPStart)
2020-08-21 02:34:37 +00:00
.HasName("ip_start");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.Id).HasColumnName("id");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.AddrType)
2020-08-21 02:34:37 +00:00
.IsRequired()
.HasColumnName("addr_type")
.HasColumnType("enum('ipv4','ipv6')")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.City)
2020-08-21 02:34:37 +00:00
.IsRequired()
.HasColumnName("city")
.HasColumnType("varchar(255)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.Country)
2020-08-21 02:34:37 +00:00
.IsRequired()
.HasColumnName("country")
.HasColumnType("varchar(2)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.District)
2020-08-21 02:34:37 +00:00
.HasColumnName("district")
.HasColumnType("varchar(255)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.GeonameId).HasColumnName("geoname_id");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.IPEnd)
2020-08-21 02:34:37 +00:00
.IsRequired()
.HasColumnName("ip_end")
.HasColumnType("varchar(39)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.IPStart)
2020-08-21 02:34:37 +00:00
.IsRequired()
.HasColumnName("ip_start")
.HasColumnType("varchar(39)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.Latitude).HasColumnName("latitude");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.Longitude).HasColumnName("longitude");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.Processed)
2020-08-21 02:34:37 +00:00
.HasColumnName("processed")
.HasDefaultValueSql("'1'");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.StateProv)
2020-08-21 02:34:37 +00:00
.IsRequired()
.HasColumnName("stateprov")
.HasColumnType("varchar(255)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.TimezoneName)
2020-08-21 02:34:37 +00:00
.HasColumnName("timezone_name")
.HasColumnType("varchar(255)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.TimezoneOffset).HasColumnName("timezone_offset");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.ZipCode)
2020-08-21 02:34:37 +00:00
.HasColumnName("zipcode")
.HasColumnType("varchar(255)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
});
}
2020-09-06 22:49:03 +00:00
public static void PgSqlAddDbipLocation(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
2020-10-12 19:39:23 +00:00
modelBuilder.HasPostgresEnum("onlyoffice", "enum_dbip_location", new[] { "ipv4", "ipv6" });
modelBuilder.Entity<DbipLocation>(entity =>
2020-08-21 02:34:37 +00:00
{
2020-10-12 19:39:23 +00:00
entity.ToTable("dbip_location", "onlyoffice");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.HasIndex(e => e.IPStart)
2020-08-21 02:34:37 +00:00
.HasName("ip_start");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.Id).HasColumnName("id");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.City)
2020-08-21 02:34:37 +00:00
.IsRequired()
.HasColumnName("city")
.HasMaxLength(255);
2020-10-12 19:39:23 +00:00
entity.Property(e => e.Country)
2020-08-21 02:34:37 +00:00
.IsRequired()
.HasColumnName("country")
.HasMaxLength(2);
2020-10-12 19:39:23 +00:00
entity.Property(e => e.District)
2020-08-21 02:34:37 +00:00
.HasColumnName("district")
.HasMaxLength(255)
2020-09-29 17:09:39 +00:00
.HasDefaultValueSql("NULL");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.GeonameId).HasColumnName("geoname_id");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.IPEnd)
2020-08-21 02:34:37 +00:00
.IsRequired()
.HasColumnName("ip_end")
.HasMaxLength(39);
2020-10-12 19:39:23 +00:00
entity.Property(e => e.IPStart)
2020-08-21 02:34:37 +00:00
.IsRequired()
.HasColumnName("ip_start")
.HasMaxLength(39);
2020-10-12 19:39:23 +00:00
entity.Property(e => e.Latitude).HasColumnName("latitude");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.Longitude).HasColumnName("longitude");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.Processed)
2020-08-21 02:34:37 +00:00
.HasColumnName("processed")
.HasDefaultValueSql("1");
2020-10-12 19:39:23 +00:00
entity.Property(e => e.StateProv)
2020-08-21 02:34:37 +00:00
.IsRequired()
.HasColumnName("stateprov")
.HasMaxLength(255);
2020-10-12 19:39:23 +00:00
entity.Property(e => e.TimezoneName)
2020-08-21 02:34:37 +00:00
.HasColumnName("timezone_name")
.HasMaxLength(255)
2020-09-29 17:09:39 +00:00
.HasDefaultValueSql("NULL");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.TimezoneOffset).HasColumnName("timezone_offset");
2020-08-21 02:34:37 +00:00
2020-10-12 19:39:23 +00:00
entity.Property(e => e.ZipCode)
2020-08-21 02:34:37 +00:00
.HasColumnName("zipcode")
.HasMaxLength(255)
2020-09-29 17:09:39 +00:00
.HasDefaultValueSql("NULL");
2020-08-21 02:34:37 +00:00
});
}
}
2019-12-13 13:05:24 +00:00
}