forked from ddrilling/AsbCloudServer
reviw db model and migration
This commit is contained in:
parent
301f1c8013
commit
e4412d3b2a
@ -13,7 +13,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace AsbCloudDb.Migrations
|
namespace AsbCloudDb.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(AsbCloudDbContext))]
|
[DbContext(typeof(AsbCloudDbContext))]
|
||||||
[Migration("20230328185054_add_table_WITS_GTR_and_manual_hypertable")]
|
[Migration("20230331060526_add_table_WITS_GTR_and_manual_hypertable")]
|
||||||
partial class add_table_WITS_GTR_and_manual_hypertable
|
partial class add_table_WITS_GTR_and_manual_hypertable
|
||||||
{
|
{
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -821,9 +821,9 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnName("date");
|
.HasColumnName("date");
|
||||||
|
|
||||||
b.Property<float?>("Value")
|
b.Property<float>("Value")
|
||||||
.HasColumnType("real")
|
.HasColumnType("real")
|
||||||
.HasColumnName("value");
|
.HasColumnName("Value");
|
||||||
|
|
||||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||||
|
|
||||||
@ -850,8 +850,8 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnName("date");
|
.HasColumnName("date");
|
||||||
|
|
||||||
b.Property<long?>("Value")
|
b.Property<int>("Value")
|
||||||
.HasColumnType("bigint")
|
.HasColumnType("integer")
|
||||||
.HasColumnName("Value");
|
.HasColumnName("Value");
|
||||||
|
|
||||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||||
@ -880,9 +880,8 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasColumnName("date");
|
.HasColumnName("date");
|
||||||
|
|
||||||
b.Property<string>("Value")
|
b.Property<string>("Value")
|
||||||
.HasMaxLength(64)
|
.HasColumnType("text")
|
||||||
.HasColumnType("character varying(64)")
|
.HasColumnName("Value");
|
||||||
.HasColumnName("value");
|
|
||||||
|
|
||||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||||
|
|
@ -17,7 +17,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
id_record = table.Column<int>(type: "integer", nullable: false),
|
id_record = table.Column<int>(type: "integer", nullable: false),
|
||||||
id_item = table.Column<int>(type: "integer", nullable: false),
|
id_item = table.Column<int>(type: "integer", nullable: false),
|
||||||
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
value = table.Column<float>(type: "real", nullable: true)
|
Value = table.Column<float>(type: "real", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@ -39,7 +39,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
id_record = table.Column<int>(type: "integer", nullable: false),
|
id_record = table.Column<int>(type: "integer", nullable: false),
|
||||||
id_item = table.Column<int>(type: "integer", nullable: false),
|
id_item = table.Column<int>(type: "integer", nullable: false),
|
||||||
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
Value = table.Column<long>(type: "bigint", nullable: true)
|
Value = table.Column<int>(type: "integer", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@ -61,7 +61,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
id_record = table.Column<int>(type: "integer", nullable: false),
|
id_record = table.Column<int>(type: "integer", nullable: false),
|
||||||
id_item = table.Column<int>(type: "integer", nullable: false),
|
id_item = table.Column<int>(type: "integer", nullable: false),
|
||||||
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
value = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true)
|
Value = table.Column<string>(type: "text", nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@ -74,11 +74,6 @@ namespace AsbCloudDb.Migrations
|
|||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
},
|
},
|
||||||
comment: "таблица данных ГТИ с типом значения string");
|
comment: "таблица данных ГТИ с типом значения string");
|
||||||
|
|
||||||
migrationBuilder.Sql
|
|
||||||
("SELECT create_hypertable('t_wits_string','time','id_telemetry',chunk_time_interval => INTERVAL '5 day'); " +
|
|
||||||
"SELECT create_hypertable('t_wits_float','time','id_telemetry',chunk_time_interval => INTERVAL '5 day'); " +
|
|
||||||
"SELECT create_hypertable('t_wits_int','time','id_telemetry',chunk_time_interval => INTERVAL '5 day'); ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
@ -819,9 +819,9 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnName("date");
|
.HasColumnName("date");
|
||||||
|
|
||||||
b.Property<float?>("Value")
|
b.Property<float>("Value")
|
||||||
.HasColumnType("real")
|
.HasColumnType("real")
|
||||||
.HasColumnName("value");
|
.HasColumnName("Value");
|
||||||
|
|
||||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||||
|
|
||||||
@ -848,8 +848,8 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnName("date");
|
.HasColumnName("date");
|
||||||
|
|
||||||
b.Property<long?>("Value")
|
b.Property<int>("Value")
|
||||||
.HasColumnType("bigint")
|
.HasColumnType("integer")
|
||||||
.HasColumnName("Value");
|
.HasColumnName("Value");
|
||||||
|
|
||||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||||
@ -878,9 +878,8 @@ namespace AsbCloudDb.Migrations
|
|||||||
.HasColumnName("date");
|
.HasColumnName("date");
|
||||||
|
|
||||||
b.Property<string>("Value")
|
b.Property<string>("Value")
|
||||||
.HasMaxLength(64)
|
.HasColumnType("text")
|
||||||
.HasColumnType("character varying(64)")
|
.HasColumnName("Value");
|
||||||
.HasColumnName("value");
|
|
||||||
|
|
||||||
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
b.HasKey("IdTelemetry", "IdRecord", "IdItem");
|
||||||
|
|
||||||
|
@ -344,22 +344,22 @@ namespace AsbCloudDb.Model
|
|||||||
{
|
{
|
||||||
entity.HasKey(
|
entity.HasKey(
|
||||||
nameof(ITelemetryData.IdTelemetry),
|
nameof(ITelemetryData.IdTelemetry),
|
||||||
nameof(IWitsBase.IdRecord),
|
nameof(WitsItemBase<float>.IdRecord),
|
||||||
nameof(IWitsBase.IdItem));
|
nameof(WitsItemBase<float>.IdItem));
|
||||||
});
|
});
|
||||||
modelBuilder.Entity<WitsInt>(entity =>
|
modelBuilder.Entity<WitsInt>(entity =>
|
||||||
{
|
{
|
||||||
entity.HasKey(
|
entity.HasKey(
|
||||||
nameof(ITelemetryData.IdTelemetry),
|
nameof(ITelemetryData.IdTelemetry),
|
||||||
nameof(IWitsBase.IdRecord),
|
nameof(WitsItemBase<int>.IdRecord),
|
||||||
nameof(IWitsBase.IdItem));
|
nameof(WitsItemBase<int>.IdItem));
|
||||||
});
|
});
|
||||||
modelBuilder.Entity<WitsStr>(entity =>
|
modelBuilder.Entity<WitsStr>(entity =>
|
||||||
{
|
{
|
||||||
entity.HasKey(
|
entity.HasKey(
|
||||||
nameof(ITelemetryData.IdTelemetry),
|
nameof(ITelemetryData.IdTelemetry),
|
||||||
nameof(IWitsBase.IdRecord),
|
nameof(WitsItemBase<string>.IdRecord),
|
||||||
nameof(IWitsBase.IdItem));
|
nameof(WitsItemBase<string>.IdItem));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
namespace AsbCloudDb.Model.GTR
|
|
||||||
{
|
|
||||||
public interface IWitsBase:ITelemetryData
|
|
||||||
{
|
|
||||||
public int IdRecord { get; set; }
|
|
||||||
public int IdItem { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
namespace AsbCloudDb.Model.GTR
|
namespace AsbCloudDb.Model.GTR
|
||||||
{
|
{
|
||||||
[Table("t_wits_float"), Comment("таблица данных ГТИ с типом значения float")]
|
[Table("t_wits_float"), Comment("таблица данных ГТИ с типом значения float")]
|
||||||
public class WitsFloat : IWitsBase
|
public class WitsFloat : WitsItemBase<float> { }
|
||||||
{
|
|
||||||
[Column("id_telemetry")]
|
|
||||||
public int IdTelemetry { get; set; }
|
|
||||||
|
|
||||||
[Column("id_record")]
|
|
||||||
public int IdRecord { get; set; }
|
|
||||||
|
|
||||||
[Column("id_item")]
|
|
||||||
public int IdItem { get; set; }
|
|
||||||
|
|
||||||
[Column("date", TypeName = "timestamp with time zone")]
|
|
||||||
public DateTimeOffset DateTime { get; set; }
|
|
||||||
|
|
||||||
[Column("value")]
|
|
||||||
public float? Value { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey(nameof(IdTelemetry))]
|
|
||||||
public virtual Telemetry? Telemetry { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace AsbCloudDb.Model.GTR
|
namespace AsbCloudDb.Model.GTR
|
||||||
{
|
{
|
||||||
[Table("t_wits_int"), Comment("таблица данных ГТИ с типом значения int16 int32")]
|
[Table("t_wits_int"), Comment("таблица данных ГТИ с типом значения int16 int32")]
|
||||||
public class WitsInt : IWitsBase
|
public class WitsInt : WitsItemBase<int>, ITelemetryData { }
|
||||||
{
|
|
||||||
[Column("id_telemetry")]
|
|
||||||
public int IdTelemetry { get; set; }
|
|
||||||
|
|
||||||
[Column("id_record")]
|
|
||||||
public int IdRecord { get; set; }
|
|
||||||
|
|
||||||
[Column("id_item")]
|
|
||||||
public int IdItem { get; set; }
|
|
||||||
|
|
||||||
[Column("date", TypeName = "timestamp with time zone")]
|
|
||||||
public DateTimeOffset DateTime { get; set; }
|
|
||||||
|
|
||||||
[Column("Value", TypeName = "bigint")]
|
|
||||||
public int? Value { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey(nameof(IdTelemetry))]
|
|
||||||
public virtual Telemetry? Telemetry { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
30
AsbCloudDb/Model/GTR/WitsItemBase.cs
Normal file
30
AsbCloudDb/Model/GTR/WitsItemBase.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Model.GTR
|
||||||
|
{
|
||||||
|
public class WitsItemBase<T> : ITelemetryData
|
||||||
|
{
|
||||||
|
[Column("id_telemetry")]
|
||||||
|
public int IdTelemetry { get; set; }
|
||||||
|
|
||||||
|
[Column("id_record")]
|
||||||
|
public int IdRecord { get; set; }
|
||||||
|
|
||||||
|
[Column("id_item")]
|
||||||
|
public int IdItem { get; set; }
|
||||||
|
|
||||||
|
[Column("date", TypeName = "timestamp with time zone")]
|
||||||
|
public DateTimeOffset DateTime { get; set; }
|
||||||
|
|
||||||
|
[Column("Value")]
|
||||||
|
public T? Value { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(IdTelemetry))]
|
||||||
|
public virtual Telemetry? Telemetry { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WitsItemString : WitsItemBase<string> { }
|
||||||
|
public class WitsItemFloat : WitsItemBase<float> { }
|
||||||
|
public class WitsItemInt : WitsItemBase<int> { }
|
||||||
|
}
|
@ -1,30 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace AsbCloudDb.Model.GTR
|
namespace AsbCloudDb.Model.GTR
|
||||||
{
|
{
|
||||||
[Table("t_wits_string"), Comment("таблица данных ГТИ с типом значения string")]
|
[Table("t_wits_string"), Comment("таблица данных ГТИ с типом значения string")]
|
||||||
public class WitsStr: IWitsBase
|
public class WitsStr: WitsItemBase<string> { }
|
||||||
{
|
|
||||||
[Column("id_telemetry")]
|
|
||||||
public int IdTelemetry { get; set; }
|
|
||||||
|
|
||||||
[Column("id_record")]
|
|
||||||
public int IdRecord { get; set; }
|
|
||||||
|
|
||||||
[Column("id_item")]
|
|
||||||
public int IdItem { get; set; }
|
|
||||||
|
|
||||||
[Column("date", TypeName = "timestamp with time zone")]
|
|
||||||
public DateTimeOffset DateTime { get; set; }
|
|
||||||
|
|
||||||
[Column("value")]
|
|
||||||
[StringLength(64)]
|
|
||||||
public string? Value { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey(nameof(IdTelemetry))]
|
|
||||||
public virtual Telemetry? Telemetry { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
11
AsbCloudWebApi/Controllers/GTR/GtrWitsController.cs
Normal file
11
AsbCloudWebApi/Controllers/GTR/GtrWitsController.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace AsbCloudWebApi.Controllers.GTR
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class GtrWitsController : ControllerBase
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user