using iWare.Wms.Core;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Furion.Extras.iWare.Wms.Entity
{
///
/// 低代码模块管理
///
[Table("sys_low_code_module")]
[Comment("低代码模块管理")]
public class SysLowCode : DEntityBase
{
///
/// 作者姓名
///
[Comment("作者姓名")]
[MaxLength(20)]
public string AuthorName { get; set; }
///
/// 生成方式
///
[Comment("生成方式")]
[MaxLength(20)]
public string GenerateType { get; set; }
///
/// 数据库名
///
[Comment("数据库名")]
[MaxLength(100)]
public string DatabaseName { get; set; }
///
/// 命名空间
///
[Comment("命名空间")]
[MaxLength(100)]
public string NameSpace { get; set; }
///
/// 程序集
///
[NotMapped]
public string ProName
{
get { return NameSpace.TrimEnd(new char[] { '.', 'A', 'p', 'p', 'l', 'i', 'c', 'a', 't', 'i', 'o', 'n' }); }
}
///
/// 关联表信息
///
[NotMapped]
public dynamic Tables
{
get
{
if (Databases == null || !Databases.Any()) return null;
else return Databases.Select(x => new { x.TableName, x.ClassName, x.TableDesc }).Distinct().ToList();
}
}
///
/// 业务名
///
[Comment("业务名")]
[MaxLength(100)]
public string BusName { get; set; }
///
/// 菜单应用分类(应用编码)
///
[Comment("菜单应用分类")]
[MaxLength(50)]
public string MenuApplication { get; set; }
///
/// 菜单编码
///
[Comment("菜单编码")]
public long MenuPid { get; set; }
///
/// 动态表单类型
///
[Comment("动态表单类型")]
[Column(TypeName = "int")]
public FormDesignType FormDesignType { get; set; } = FormDesignType.VueFormDesign;
///
/// 动态表单
///
[Comment("动态表单")]
[Column(TypeName = "text")]
public string FormDesign { get; set; }
public ICollection Databases { get; set; }
///
/// 配置多对多关系
///
///
///
///
public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasMany(p => p.Databases)
.WithOne(p => p.SysLowCode)
.HasForeignKey(p => p.SysLowCodeId)
.HasPrincipalKey(p => p.Id);
}
}
}