提交 5f02f9d2 编写于 作者: 麦壳饼's avatar 麦壳饼

修正事件 ID等问题

上级 2600373f
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IoTSharp.Migrations
{
public partial class FixIX_TelemetryData_DeviceId_KeyName_DateTime : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_BaseEvents_Customer_CustomerId",
table: "BaseEvents");
migrationBuilder.DropForeignKey(
name: "FK_BaseEvents_Tenant_TenantId",
table: "BaseEvents");
migrationBuilder.AlterColumn<Guid>(
name: "TenantId",
table: "BaseEvents",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AlterColumn<Guid>(
name: "CustomerId",
table: "BaseEvents",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddForeignKey(
name: "FK_BaseEvents_Customer_CustomerId",
table: "BaseEvents",
column: "CustomerId",
principalTable: "Customer",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_BaseEvents_Tenant_TenantId",
table: "BaseEvents",
column: "TenantId",
principalTable: "Tenant",
principalColumn: "Id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_BaseEvents_Customer_CustomerId",
table: "BaseEvents");
migrationBuilder.DropForeignKey(
name: "FK_BaseEvents_Tenant_TenantId",
table: "BaseEvents");
migrationBuilder.AlterColumn<Guid>(
name: "TenantId",
table: "BaseEvents",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AlterColumn<Guid>(
name: "CustomerId",
table: "BaseEvents",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_BaseEvents_Customer_CustomerId",
table: "BaseEvents",
column: "CustomerId",
principalTable: "Customer",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_BaseEvents_Tenant_TenantId",
table: "BaseEvents",
column: "TenantId",
principalTable: "Tenant",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
......@@ -198,7 +198,7 @@ namespace IoTSharp.Migrations
b.Property<Guid>("Creator")
.HasColumnType("uuid");
b.Property<Guid>("CustomerId")
b.Property<Guid?>("CustomerId")
.HasColumnType("uuid");
b.Property<string>("EventDesc")
......@@ -216,7 +216,7 @@ namespace IoTSharp.Migrations
b.Property<string>("MataData")
.HasColumnType("text");
b.Property<Guid>("TenantId")
b.Property<Guid?>("TenantId")
.HasColumnType("uuid");
b.Property<int>("Type")
......@@ -1872,9 +1872,7 @@ namespace IoTSharp.Migrations
{
b.HasOne("IoTSharp.Data.Customer", "Customer")
.WithMany()
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("CustomerId");
b.HasOne("IoTSharp.Data.FlowRule", "FlowRule")
.WithMany()
......@@ -1882,9 +1880,7 @@ namespace IoTSharp.Migrations
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("TenantId");
b.Navigation("Customer");
......
......@@ -25,9 +25,7 @@ namespace IoTSharp.Data
public string BizData { get; set; }
public Tenant Tenant { get; set; }
public Guid TenantId { get; set; }
public Guid CustomerId { get; set; }
public Customer Customer { get; set; }
......
......@@ -1171,7 +1171,7 @@ namespace IoTSharp.Controllers
public async Task<ApiResult<PagedData<BaseEventDto>>> FlowEvents([FromBody] EventParam m)
{
var profile = await this.GetUserProfile();
Expression<Func<BaseEvent, bool>> condition = x => x.EventStaus > -1&&x.TenantId==profile.Tenant;
Expression<Func<BaseEvent, bool>> condition = x => x.EventStaus > -1&&x.Tenant.Id==profile.Tenant;
if (!string.IsNullOrEmpty(m.Name))
{
condition = condition.And(x => x.EventName.Contains(m.Name));
......
......@@ -8,8 +8,8 @@
},
"DataBase": "PostgreSql",
"ConnectionStrings": {
"IoTSharp": "Server=localhost;Database=IoTSharp;Username=postgres;Password=future;",
"TelemetryStorage": "Server=localhost;Database=IoTSharp;Username=postgres;Password=future;"
"IoTSharp": "Server=localhost;Database=IoTSharp100;Username=postgres;Password=future;",
"TelemetryStorage": "Server=localhost;Database=IoTSharp100;Username=postgres;Password=future;"
},
"JwtKey": "iotsharpiotsharpiotsharpiotsharpiotsharp",
"JwtExpireHours": 3,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册