Browse Source

Close #25: Reduce inventory after payment

pull/49/head
gdlcf88 6 years ago
parent
commit
5ab4fd07ea
  1. 13
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderPaidEto.cs
  2. 4
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderProductInventoryReductionEventHandler.cs
  3. 12
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderIsInWrongStageException.cs
  4. 15
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderPaymentCompletedEventHandler.cs
  5. 29
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderProductInventoryReductionEventHandler.cs
  6. 18
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductInventoryReductionAfterOrderPaidResultEto.cs
  7. 10
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IOrderPaidEventHandler.cs
  8. 106
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/OrderCreatedEventHandler.cs
  9. 110
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/OrderPaidEventHandler.cs
  10. 15
      modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ReduceInventoryModel.cs
  11. 3533
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200610111529_UpgradedToAbp2_9_0.Designer.cs
  12. 127
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200610111529_UpgradedToAbp2_9_0.cs
  13. 168
      samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/EShopSampleMigrationsDbContextModelSnapshot.cs

13
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain.Shared/EasyAbp/EShop/Orders/Orders/OrderPaidEto.cs

@ -0,0 +1,13 @@
using System;
namespace EasyAbp.EShop.Orders.Orders
{
public class OrderPaidEto
{
public OrderEto Order { get; set; }
public Guid PaymentId { get; set; }
public Guid PaymentItemId { get; set; }
}
}

4
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/IOrderProductInventoryReductionEventHandler.cs

@ -3,7 +3,9 @@ using Volo.Abp.EventBus.Distributed;
namespace EasyAbp.EShop.Orders.Orders
{
public interface IOrderProductInventoryReductionEventHandler : IDistributedEventHandler<ProductInventoryReductionAfterOrderPlacedResultEto>
public interface IOrderProductInventoryReductionEventHandler :
IDistributedEventHandler<ProductInventoryReductionAfterOrderPlacedResultEto>,
IDistributedEventHandler<ProductInventoryReductionAfterOrderPaidResultEto>
{
}

12
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderIsInWrongStageException.cs

@ -0,0 +1,12 @@
using System;
using Volo.Abp;
namespace EasyAbp.EShop.Orders.Orders
{
public class OrderIsInWrongStageException : BusinessException
{
public OrderIsInWrongStageException(Guid orderId) : base(message: $"The order {orderId} is in the wrong stage.")
{
}
}
}

15
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderPaymentCompletedEventHandler.cs

@ -4,7 +4,9 @@ using EasyAbp.EShop.Payments;
using EasyAbp.PaymentService.Payments;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Timing;
using Volo.Abp.Uow;
@ -14,18 +16,24 @@ namespace EasyAbp.EShop.Orders.Orders
{
private readonly IClock _clock;
private readonly ICurrentTenant _currentTenant;
private readonly IObjectMapper _objectMapper;
private readonly IOrderPaymentChecker _orderPaymentChecker;
private readonly IDistributedEventBus _distributedEventBus;
private readonly IOrderRepository _orderRepository;
public OrderPaymentCompletedEventHandler(
IClock clock,
ICurrentTenant currentTenant,
IObjectMapper objectMapper,
IOrderPaymentChecker orderPaymentChecker,
IDistributedEventBus distributedEventBus,
IOrderRepository orderRepository)
{
_clock = clock;
_currentTenant = currentTenant;
_objectMapper = objectMapper;
_orderPaymentChecker = orderPaymentChecker;
_distributedEventBus = distributedEventBus;
_orderRepository = orderRepository;
}
@ -53,6 +61,13 @@ namespace EasyAbp.EShop.Orders.Orders
order.SetOrderStatus(OrderStatus.Processing);
await _orderRepository.UpdateAsync(order, true);
await _distributedEventBus.PublishAsync(new OrderPaidEto
{
Order = _objectMapper.Map<Order, OrderEto>(order),
PaymentId = eventData.Entity.Id,
PaymentItemId = item.Id
});
}
}
}

29
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderProductInventoryReductionEventHandler.cs

@ -30,9 +30,9 @@ namespace EasyAbp.EShop.Orders.Orders
{
var order = await _orderRepository.GetAsync(eventData.OrderId);
if (order.OrderStatus != OrderStatus.Pending || order.ReducedInventoryAfterPlacingTime.HasValue)
if (order.ReducedInventoryAfterPlacingTime.HasValue)
{
return;
throw new OrderIsInWrongStageException(order.Id);
}
if (!eventData.IsSuccess)
@ -46,5 +46,30 @@ namespace EasyAbp.EShop.Orders.Orders
await _orderRepository.UpdateAsync(order, true);
}
}
[UnitOfWork(true)]
public virtual async Task HandleEventAsync(ProductInventoryReductionAfterOrderPaidResultEto eventData)
{
using (_currentTenant.Change(eventData.TenantId))
{
var order = await _orderRepository.GetAsync(eventData.OrderId);
if (order.ReducedInventoryAfterPaymentTime.HasValue)
{
throw new OrderIsInWrongStageException(order.Id);
}
if (!eventData.IsSuccess)
{
// Todo: Refund.
// Todo: Cancel order.
return;
}
order.SetReducedInventoryAfterPaymentTime(_clock.Now);
await _orderRepository.UpdateAsync(order, true);
}
}
}
}

18
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain.Shared/EasyAbp/EShop/Products/Products/ProductInventoryReductionAfterOrderPaidResultEto.cs

@ -0,0 +1,18 @@
using System;
namespace EasyAbp.EShop.Products.Products
{
[Serializable]
public class ProductInventoryReductionAfterOrderPaidResultEto
{
public Guid? TenantId { get; set; }
public Guid OrderId { get; set; }
public Guid PaymentId { get; set; }
public Guid PaymentItemId { get; set; }
public bool IsSuccess { get; set; }
}
}

10
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IOrderPaidEventHandler.cs

@ -0,0 +1,10 @@
using EasyAbp.EShop.Orders.Orders;
using Volo.Abp.EventBus.Distributed;
namespace EasyAbp.EShop.Products.Products
{
public interface IOrderPaidEventHandler : IDistributedEventHandler<OrderPaidEto>
{
}
}

106
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/OrderCreatedEventHandler.cs

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EasyAbp.EShop.Orders.Orders;
@ -33,61 +32,78 @@ namespace EasyAbp.EShop.Products.Products
_productManager = productManager;
}
[UnitOfWork(true)]
public virtual async Task HandleEventAsync(EntityCreatedEto<OrderEto> eventData)
{
using (_currentTenant.Change(eventData.Entity.TenantId))
{
var models = new List<ReduceInventoryModel>();
foreach (var orderLine in eventData.Entity.OrderLines)
{
var product = await _productRepository.FindAsync(orderLine.ProductId);
using var changeTenant = _currentTenant.Change(eventData.Entity.TenantId);
var productSku = product?.ProductSkus.FirstOrDefault(sku => sku.Id == orderLine.ProductSkuId);
using var uow = _unitOfWorkManager.Begin(isTransactional: true);
if (productSku == null || product.InventoryStrategy != InventoryStrategy.ReduceAfterPlacing)
{
continue;
}
var models = new List<ReduceInventoryModel>();
foreach (var orderLine in eventData.Entity.OrderLines)
{
// Todo: Should use ProductHistory.
var product = await _productRepository.FindAsync(orderLine.ProductId);
if (!await _productManager.IsInventorySufficientAsync(product, productSku, eventData.Entity.StoreId,
orderLine.Quantity))
{
await _distributedEventBus.PublishAsync(new ProductInventoryReductionAfterOrderPlacedResultEto
{TenantId = eventData.Entity.TenantId, OrderId = eventData.Entity.Id, IsSuccess = false});
return;
}
var productSku = product?.ProductSkus.FirstOrDefault(sku => sku.Id == orderLine.ProductSkuId);
models.Add(new ReduceInventoryModel
{
Product = product,
ProductSku = productSku,
StoreId = eventData.Entity.StoreId,
Quantity = orderLine.Quantity
});
if (productSku == null)
{
await PublishResultEventAsync(eventData, false);
return;
}
if (product.InventoryStrategy != InventoryStrategy.ReduceAfterPlacing)
{
continue;
}
foreach (var model in models)
if (!await _productManager.IsInventorySufficientAsync(product, productSku, eventData.Entity.StoreId,
orderLine.Quantity))
{
await _productManager.TryReduceInventoryAsync(model.Product, model.ProductSku, model.StoreId,
model.Quantity);
await PublishResultEventAsync(eventData, false);
return;
}
await _distributedEventBus.PublishAsync(new ProductInventoryReductionAfterOrderPlacedResultEto
{TenantId = eventData.Entity.TenantId, OrderId = eventData.Entity.Id, IsSuccess = true});
models.Add(new ReduceInventoryModel
{
Product = product,
ProductSku = productSku,
StoreId = eventData.Entity.StoreId,
Quantity = orderLine.Quantity
});
}
}
}
internal class ReduceInventoryModel
{
public Product Product { get; set; }
public ProductSku ProductSku { get; set; }
public Guid StoreId { get; set; }
foreach (var model in models)
{
if (await _productManager.TryReduceInventoryAsync(model.Product, model.ProductSku, model.StoreId,
model.Quantity))
{
continue;
}
await uow.RollbackAsync();
await PublishResultEventAsync(eventData, false);
return;
}
await uow.CompleteAsync();
await PublishResultEventAsync(eventData, true);
}
public int Quantity { get; set; }
protected virtual async Task PublishResultEventAsync(EntityCreatedEto<OrderEto> orderCreatedEto, bool isSuccess)
{
await _distributedEventBus.PublishAsync(new ProductInventoryReductionAfterOrderPlacedResultEto
{
TenantId = orderCreatedEto.Entity.TenantId,
OrderId = orderCreatedEto.Entity.Id,
IsSuccess = isSuccess
});
}
}
}

110
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/OrderPaidEventHandler.cs

@ -0,0 +1,110 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EasyAbp.EShop.Orders.Orders;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
namespace EasyAbp.EShop.Products.Products
{
public class OrderPaidEventHandler : IOrderPaidEventHandler, ITransientDependency
{
private readonly ICurrentTenant _currentTenant;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IDistributedEventBus _distributedEventBus;
private readonly IProductRepository _productRepository;
private readonly IProductManager _productManager;
public OrderPaidEventHandler(
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
IDistributedEventBus distributedEventBus,
IProductRepository productRepository,
IProductManager productManager)
{
_currentTenant = currentTenant;
_unitOfWorkManager = unitOfWorkManager;
_distributedEventBus = distributedEventBus;
_productRepository = productRepository;
_productManager = productManager;
}
public virtual async Task HandleEventAsync(OrderPaidEto eventData)
{
using var changeTenant = _currentTenant.Change(eventData.Order.TenantId);
using var uow = _unitOfWorkManager.Begin(isTransactional: true);
var models = new List<ReduceInventoryModel>();
foreach (var orderLine in eventData.Order.OrderLines)
{
// Todo: Should use ProductHistory.
var product = await _productRepository.FindAsync(orderLine.ProductId);
var productSku = product?.ProductSkus.FirstOrDefault(sku => sku.Id == orderLine.ProductSkuId);
if (productSku == null)
{
await PublishResultEventAsync(eventData, false);
return;
}
if (product.InventoryStrategy != InventoryStrategy.ReduceAfterPayment)
{
continue;
}
if (!await _productManager.IsInventorySufficientAsync(product, productSku, eventData.Order.StoreId,
orderLine.Quantity))
{
await PublishResultEventAsync(eventData, false);
return;
}
models.Add(new ReduceInventoryModel
{
Product = product,
ProductSku = productSku,
StoreId = eventData.Order.StoreId,
Quantity = orderLine.Quantity
});
}
foreach (var model in models)
{
if (await _productManager.TryReduceInventoryAsync(model.Product, model.ProductSku, model.StoreId,
model.Quantity))
{
continue;
}
await uow.RollbackAsync();
await PublishResultEventAsync(eventData, false);
return;
}
await uow.CompleteAsync();
await PublishResultEventAsync(eventData, true);
}
protected virtual async Task PublishResultEventAsync(OrderPaidEto orderPaidEto, bool isSuccess)
{
await _distributedEventBus.PublishAsync(new ProductInventoryReductionAfterOrderPaidResultEto
{
TenantId = orderPaidEto.Order.TenantId,
OrderId = orderPaidEto.Order.Id,
PaymentId = orderPaidEto.PaymentId,
PaymentItemId = orderPaidEto.PaymentItemId,
IsSuccess = isSuccess
});
}
}
}

15
modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ReduceInventoryModel.cs

@ -0,0 +1,15 @@
using System;
namespace EasyAbp.EShop.Products.Products
{
public class ReduceInventoryModel
{
public Product Product { get; set; }
public ProductSku ProductSku { get; set; }
public Guid StoreId { get; set; }
public int Quantity { get; set; }
}
}

3533
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200610111529_UpgradedToAbp2_9_0.Designer.cs

File diff suppressed because it is too large

127
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/20200610111529_UpgradedToAbp2_9_0.cs

@ -0,0 +1,127 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace EShopSample.Migrations
{
public partial class UpgradedToAbp2_9_0 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AbpOrganizationUnits",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
ExtraProperties = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
LastModificationTime = table.Column<DateTime>(nullable: true),
LastModifierId = table.Column<Guid>(nullable: true),
IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(nullable: true),
DeletionTime = table.Column<DateTime>(nullable: true),
TenantId = table.Column<Guid>(nullable: true),
ParentId = table.Column<Guid>(nullable: true),
Code = table.Column<string>(maxLength: 95, nullable: false),
DisplayName = table.Column<string>(maxLength: 128, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id);
table.ForeignKey(
name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId",
column: x => x.ParentId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "AbpOrganizationUnitRoles",
columns: table => new
{
RoleId = table.Column<Guid>(nullable: false),
OrganizationUnitId = table.Column<Guid>(nullable: false),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
TenantId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId });
table.ForeignKey(
name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId",
column: x => x.OrganizationUnitId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId",
column: x => x.RoleId,
principalTable: "AbpRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpUserOrganizationUnits",
columns: table => new
{
UserId = table.Column<Guid>(nullable: false),
OrganizationUnitId = table.Column<Guid>(nullable: false),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
TenantId = table.Column<Guid>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId });
table.ForeignKey(
name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId",
column: x => x.OrganizationUnitId,
principalTable: "AbpOrganizationUnits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId",
column: x => x.UserId,
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId",
table: "AbpOrganizationUnitRoles",
columns: new[] { "RoleId", "OrganizationUnitId" });
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnits_Code",
table: "AbpOrganizationUnits",
column: "Code");
migrationBuilder.CreateIndex(
name: "IX_AbpOrganizationUnits_ParentId",
table: "AbpOrganizationUnits",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId",
table: "AbpUserOrganizationUnits",
columns: new[] { "UserId", "OrganizationUnitId" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AbpOrganizationUnitRoles");
migrationBuilder.DropTable(
name: "AbpUserOrganizationUnits");
migrationBuilder.DropTable(
name: "AbpOrganizationUnits");
}
}
}

168
samples/EShopSample/aspnet-core/src/EShopSample.EntityFrameworkCore.DbMigrations/Migrations/EShopSampleMigrationsDbContextModelSnapshot.cs

@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.EntityFrameworkCore;
namespace EShopSample.Migrations
{
@ -15,7 +16,8 @@ namespace EShopSample.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.2")
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("ProductVersion", "3.1.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
@ -2235,6 +2237,33 @@ namespace EShopSample.Migrations
b.ToTable("AbpUserLogins");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b =>
{
b.Property<Guid>("OrganizationUnitId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("UserId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("TenantId")
.HasColumnName("TenantId")
.HasColumnType("uniqueidentifier");
b.HasKey("OrganizationUnitId", "UserId");
b.HasIndex("UserId", "OrganizationUnitId");
b.ToTable("AbpUserOrganizationUnits");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b =>
{
b.Property<Guid>("UserId")
@ -2279,6 +2308,106 @@ namespace EShopSample.Migrations
b.ToTable("AbpUserTokens");
});
modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("Code")
.IsRequired()
.HasColumnName("Code")
.HasColumnType("nvarchar(95)")
.HasMaxLength(95);
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("DeleterId")
.HasColumnName("DeleterId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("DeletionTime")
.HasColumnName("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("DisplayName")
.IsRequired()
.HasColumnName("DisplayName")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnName("IsDeleted")
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("ParentId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("TenantId")
.HasColumnName("TenantId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("Code");
b.HasIndex("ParentId");
b.ToTable("AbpOrganizationUnits");
});
modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b =>
{
b.Property<Guid>("OrganizationUnitId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("RoleId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime")
.HasColumnType("datetime2");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("TenantId")
.HasColumnName("TenantId")
.HasColumnType("uniqueidentifier");
b.HasKey("OrganizationUnitId", "RoleId");
b.HasIndex("RoleId", "OrganizationUnitId");
b.ToTable("AbpOrganizationUnitRoles");
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResource", b =>
{
b.Property<Guid>("Id")
@ -3201,6 +3330,21 @@ namespace EShopSample.Migrations
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserOrganizationUnit", b =>
{
b.HasOne("Volo.Abp.Identity.OrganizationUnit", null)
.WithMany()
.HasForeignKey("OrganizationUnitId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Volo.Abp.Identity.IdentityUser", null)
.WithMany("OrganizationUnits")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityRole", null)
@ -3225,6 +3369,28 @@ namespace EShopSample.Migrations
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnit", b =>
{
b.HasOne("Volo.Abp.Identity.OrganizationUnit", null)
.WithMany()
.HasForeignKey("ParentId");
});
modelBuilder.Entity("Volo.Abp.Identity.OrganizationUnitRole", b =>
{
b.HasOne("Volo.Abp.Identity.OrganizationUnit", null)
.WithMany("Roles")
.HasForeignKey("OrganizationUnitId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Volo.Abp.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Volo.Abp.IdentityServer.ApiResources.ApiResourceClaim", b =>
{
b.HasOne("Volo.Abp.IdentityServer.ApiResources.ApiResource", null)

Loading…
Cancel
Save