schangxiang@126.com
2025-04-29 e71bc24daa8f00768787e18f5daba09128abfc62
HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Extensions/CMSPluginEfCoreExtensions.WmsPlace.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,74 @@
using CMS.Plugin.HIAWms.Domain;
using CMS.Plugin.HIAWms.Domain.WmsPlaces;
using CMS.Plugin.HIAWms.Domain.Shared.WmsPlaces;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;
namespace CMS.Plugin.HIAWms.EntityFrameworkCore.Extensions;
/// <summary>
/// EfCore扩展
/// </summary>
public  static partial class CMSPluginEfCoreExtensions
{
    /// <summary>
    /// Includes the details.
    /// </summary>
    /// <param name="queryable">The queryable.</param>
    /// <param name="include">if set to <c>true</c> [include].</param>
    /// <returns></returns>
    public static IQueryable<WmsPlace> IncludeDetails(this IQueryable<WmsPlace> queryable, bool include = true)
    {
        if (!include)
        {
            return queryable;
        }
        return queryable;
    }
    /// <summary>
    /// Configures the wmsplace.
    /// </summary>
    /// <param name="builder">The builder.</param>
    public static void ConfigureWmsPlace(this ModelBuilder builder)
    {
        Check.NotNull(builder, nameof(builder));
        builder.Entity<WmsPlace>(b =>
        {
            // Configure table & schema name
            b.ToTable((CMSPluginDbProperties.DbTablePrefix + "_WmsPlaces").ToLower(), CMSPluginDbProperties.DbSchema).HasComment("库位表");
            b.ConfigureByConvention();
            // Properties
            b.Property(x => x.PlaceNo).HasMaxLength(WmsPlaceConsts.MaxPlaceNoLength).IsRequired().HasComment("编号");
            b.Property(x => x.StorageTypeNo).HasComment("货位类型");
            b.Property(x => x.PlaceStatus).HasComment("货位状态");
            b.Property(x => x.AreaCode).HasMaxLength(WmsPlaceConsts.MaxAreaCodeLength).IsRequired().HasComment("所在库区");
            b.Property(x => x.Aisle).HasComment("巷道");
            b.Property(x => x.RowNo).HasComment("排");
            b.Property(x => x.ColumnNo).HasComment("列");
            b.Property(x => x.LayerNo).HasComment("层");
            b.Property(x => x.Islock).HasComment("是否锁定");
            b.Property(x => x.EmptyContainer).HasComment("是否空托");
            b.Property(x => x.RedundantField1).HasMaxLength(WmsPlaceConsts.MaxRedundantFieldLength).IsRequired(false).HasComment("冗余字段1 - é¢„留扩展用途");
            b.Property(x => x.RedundantField2).HasMaxLength(WmsPlaceConsts.MaxRedundantFieldLength).IsRequired(false).HasComment("冗余字段2 - é¢„留扩展用途");
            b.Property(x => x.RedundantField3).HasMaxLength(WmsPlaceConsts.MaxRedundantFieldLength).IsRequired(false).HasComment("冗余字段3 - é¢„留扩展用途");
            b.Property(x => x.Sort).HasComment("排序");
            b.Property(x => x.Remark).HasMaxLength(WmsPlaceConsts.MaxRemarkLength).IsRequired(false).HasComment("备注");
            b.Property(x => x.IsDisabled).IsRequired(false).HasComment("是否禁用");
            // Indexes
            b.HasIndex(u => u.PlaceNo).IsUnique(); // ç¼–号字段添加唯一索引
            b.HasIndex(u => u.AreaCode); // æ‰€åœ¨åº“区字段添加普通索引
            b.HasIndex(u => u.StorageTypeNo); // è´§ä½ç±»åž‹å­—段添加普通索引
            b.HasIndex(u => u.PlaceStatus); // è´§ä½ç±»åž‹å­—段添加普通索引
            // Apply object extension mappings
            b.ApplyObjectExtensionMappings();
        });
    }
}