sunkaixuan
2 years ago
8 changed files with 517 additions and 0 deletions
@ -0,0 +1,106 @@ |
|||
|
|||
using SqlSugar; |
|||
using System; |
|||
/// <summary>
|
|||
/// 框架实体基类Id
|
|||
/// </summary>
|
|||
public abstract class EntityBaseId |
|||
{ |
|||
/// <summary>
|
|||
/// 雪花Id
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "Id", IsPrimaryKey = true, IsIdentity = false)] |
|||
public virtual long Id { get; set; } |
|||
} |
|||
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 框架实体基类
|
|||
/// </summary>
|
|||
public abstract class EntityBase : EntityBaseId |
|||
{ |
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "创建时间")] |
|||
public virtual DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 更新时间
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "更新时间")] |
|||
public virtual DateTime? UpdateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建者Id
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "创建者Id")] |
|||
public virtual long? CreateUserId { get; set; } = 1; |
|||
|
|||
/// <summary>
|
|||
/// 修改者Id
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "修改者Id")] |
|||
public virtual long? UpdateUserId { get; set; } = 1; |
|||
|
|||
/// <summary>
|
|||
/// 软删除
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "软删除")] |
|||
public virtual bool IsDelete { get; set; } = false; |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 业务实体基类
|
|||
/// </summary>
|
|||
public abstract class BaseModel : EntityBase |
|||
{ |
|||
|
|||
[SugarColumn(ColumnDescription = "Id", IsPrimaryKey = true, IsIdentity = true)] |
|||
public override long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "创建时间")] |
|||
public override DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 更新时间
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "更新时间")] |
|||
public override DateTime? UpdateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建者Id
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "创建者Id")] |
|||
public override long? CreateUserId { get; set; } = 1; |
|||
|
|||
/// <summary>
|
|||
/// 修改者Id
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "修改者Id")] |
|||
public override long? UpdateUserId { get; set; } = 1; |
|||
|
|||
/// <summary>
|
|||
/// 软删除
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "软删除")] |
|||
public override bool IsDelete { get; set; } = false; |
|||
|
|||
/// <summary>
|
|||
/// 排序
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "排序")] |
|||
public virtual long? Order { get; set; } = 1; |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,37 @@ |
|||
using SqlSugar; |
|||
|
|||
/// <summary>
|
|||
/// 模型实用字段
|
|||
/// </summary>
|
|||
[SugarTable("WebX_Dev_Field", "功能模型字段")] |
|||
public class SysField:BaseModel |
|||
{ |
|||
/// <summary>
|
|||
/// 功能模型Id
|
|||
/// </summary>
|
|||
public long ModelId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 数据库名称
|
|||
/// </summary>
|
|||
public string FieldName { get; set; } |
|||
/// <summary>
|
|||
/// 字段类型长度
|
|||
/// </summary>
|
|||
public int TypeLength { get; set; } |
|||
/// <summary>
|
|||
/// 类型名称
|
|||
/// </summary>
|
|||
public string FieldTypeName { get; set; } |
|||
/// <summary>
|
|||
/// 字段名称
|
|||
/// </summary>
|
|||
public string FieldAlias { get; set; } = "a"; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,85 @@ |
|||
|
|||
|
|||
using SqlSugar; |
|||
|
|||
/// <summary>
|
|||
/// 模型实用字段
|
|||
/// </summary>
|
|||
[SugarTable("WebX_Dev_Form_Field", "表单字段")] |
|||
public class SysFormField : BaseModel |
|||
{ |
|||
/// <summary>
|
|||
/// 模型表单
|
|||
/// </summary>
|
|||
public long FormId { get; set; } |
|||
/// <summary>
|
|||
/// 基础字段
|
|||
/// </summary>
|
|||
public long FieldId { get; set; } |
|||
/// <summary>
|
|||
/// 功能模型Id
|
|||
/// </summary>
|
|||
public long ModelId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 数据库名称
|
|||
/// </summary>
|
|||
public string FieldName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 字段类型长度
|
|||
/// </summary>
|
|||
public int TypeLength { get; set; } |
|||
/// <summary>
|
|||
/// 类型名称
|
|||
/// </summary>
|
|||
public string FieldTypeName { get; set; } |
|||
/// <summary>
|
|||
/// 字段名称
|
|||
/// </summary>
|
|||
public string FieldAlias { get; set; } |
|||
/// <summary>
|
|||
/// 字段类型
|
|||
/// </summary>
|
|||
public int FieldType { get; set; } |
|||
/// <summary>
|
|||
/// 是否允许为空
|
|||
/// </summary>
|
|||
public bool IsAllowNull { get; set; } |
|||
/// <summary>
|
|||
/// 是否唯一
|
|||
/// </summary>
|
|||
public bool IsOnly { get; set; } |
|||
/// <summary>
|
|||
/// 是否只读
|
|||
/// </summary>
|
|||
public bool IsReadOnly { get; set; } |
|||
/// <summary>
|
|||
/// 默认值
|
|||
/// </summary>
|
|||
public string DefaultValue { get; set; } |
|||
/// <summary>
|
|||
/// 最大长度
|
|||
/// </summary>
|
|||
public int MaxLength { get; set; } |
|||
/// <summary>
|
|||
/// 是否显示在列表
|
|||
/// </summary>
|
|||
public bool IsListShow { get; set; } |
|||
/// <summary>
|
|||
/// 是否加入搜索
|
|||
/// </summary>
|
|||
public bool IsSearchShow { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 功能字段
|
|||
/// </summary>
|
|||
[Navigate(NavigateType.OneToOne, nameof(FieldId))] |
|||
public SysField SysField { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 文件
|
|||
/// </summary>
|
|||
[Navigate(NavigateType.OneToOne, nameof(Id), nameof(SysFormUpload.Form_Field_Id))] |
|||
public SysFormUpload FormUpload { get; set; } |
|||
} |
@ -0,0 +1,205 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Collections.Generic; |
|||
using SqlSugar; |
|||
|
|||
namespace Admin.NET.Application |
|||
{ |
|||
/// <summary>
|
|||
/// 表单字段输入参数
|
|||
/// </summary>
|
|||
public class SysFormFieldInput |
|||
{ |
|||
/// <summary>
|
|||
/// 模型表单
|
|||
/// </summary>
|
|||
public virtual long FormId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 基础字段
|
|||
/// </summary>
|
|||
public virtual long FieldId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 功能模型
|
|||
/// </summary>
|
|||
public virtual long ModelId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 数据库名称
|
|||
/// </summary>
|
|||
public virtual string FieldName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 字段类型长度
|
|||
/// </summary>
|
|||
public virtual int TypeLength { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 类型名称
|
|||
/// </summary>
|
|||
public virtual string FieldTypeName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 字段名称
|
|||
/// </summary>
|
|||
public virtual string FieldAlias { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 字段类型
|
|||
/// </summary>
|
|||
public virtual int FieldType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否允许为空
|
|||
/// </summary>
|
|||
public virtual bool IsAllowNull { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否唯一
|
|||
/// </summary>
|
|||
public virtual bool IsOnly { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否只读
|
|||
/// </summary>
|
|||
public virtual bool IsReadOnly { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 默认值
|
|||
/// </summary>
|
|||
public virtual string DefaultValue { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 最大长度
|
|||
/// </summary>
|
|||
public virtual int MaxLength { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否显示在列表
|
|||
/// </summary>
|
|||
public virtual bool IsListShow { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否加入搜索
|
|||
/// </summary>
|
|||
public virtual bool IsSearchShow { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 提示文字
|
|||
/// </summary>
|
|||
public virtual string TipText { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 验证错误提示文字
|
|||
/// </summary>
|
|||
public virtual string ValidateText { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 验证类型
|
|||
/// </summary>
|
|||
public virtual string ValidateType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 验证正则
|
|||
/// </summary>
|
|||
public virtual string ValidateExpression { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 排序
|
|||
/// </summary>
|
|||
public virtual long Order { get; set; } |
|||
|
|||
} |
|||
|
|||
public class AddSysFormFieldInput : SysFormFieldInput |
|||
{ |
|||
/// <summary>
|
|||
/// 模型表单
|
|||
/// </summary>
|
|||
[Required(ErrorMessage = "模型表单不能为空")] |
|||
public override long FormId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 功能模型
|
|||
/// </summary>
|
|||
[Required(ErrorMessage = "功能模型不能为空")] |
|||
public override long ModelId { get; set; } |
|||
/// <summary>
|
|||
/// 上传模式
|
|||
/// </summary>
|
|||
public int UploadMode { get; set; } |
|||
/// <summary>
|
|||
/// 是否水印
|
|||
/// </summary>
|
|||
public bool IsWaterMark { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 文件扩展名
|
|||
/// </summary>
|
|||
public string FileExts { get; set; } = "jpg|png|gif|bmp"; |
|||
/// <summary>
|
|||
/// 1省/2市/3区
|
|||
/// </summary>
|
|||
public int ShowLevel { get; set; } = 1; |
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "创建时间")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 更新时间
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "更新时间")] |
|||
public DateTime? UpdateTime { get; set; } |
|||
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 创建者Id
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "创建者Id")] |
|||
public long? CreateUserId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 修改者Id
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "修改者Id")] |
|||
public long? UpdateUserId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 软删除
|
|||
/// </summary>
|
|||
[SugarColumn(ColumnDescription = "软删除")] |
|||
public bool IsDelete { get; set; } = false; |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
public class DeleteSysFormFieldInput |
|||
{ |
|||
/// <summary>
|
|||
/// Id
|
|||
/// </summary>
|
|||
[Required(ErrorMessage = "Id不能为空")] |
|||
public long Id { get; set; } |
|||
|
|||
} |
|||
|
|||
public class UpdateSysFormFieldInput : SysFormFieldInput |
|||
{ |
|||
/// <summary>
|
|||
/// Id
|
|||
/// </summary>
|
|||
[Required(ErrorMessage = "Id不能为空")] |
|||
public long Id { get; set; } |
|||
|
|||
} |
|||
|
|||
public class QueryeSysFormFieldInput : DeleteSysFormFieldInput |
|||
{ |
|||
|
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
|
|||
using SqlSugar; |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 文件字段
|
|||
/// </summary>
|
|||
[SugarTable("WebX_Dev_Form_Upload", "文件字段")] |
|||
public class SysFormUpload : BaseModel |
|||
{ |
|||
public long FormId { get; set; } |
|||
public long Form_Field_Id { get; set; } |
|||
public long UploadMode { get; set; } |
|||
public bool IsWaterMark { get; set; } |
|||
public string FileExts { get; set; } = ""; |
|||
} |
@ -0,0 +1,61 @@ |
|||
using Admin.NET.Application; |
|||
using SqlSugar; |
|||
using System; |
|||
using System.Data; |
|||
public class UnitInsertNavOneToOne |
|||
{ |
|||
public static void Init() |
|||
{ |
|||
var db = new SqlSugarScope(new SqlSugar.ConnectionConfig() |
|||
{ |
|||
ConnectionString = "server=.;uid=sa;pwd=sasa;database=Question", |
|||
DbType = SqlSugar.DbType.SqlServer, |
|||
IsAutoCloseConnection = true |
|||
}); |
|||
db.DbMaintenance.CreateDatabase(); |
|||
//建表
|
|||
if (!db.DbMaintenance.IsAnyTable("SysField", false) && |
|||
!db.DbMaintenance.IsAnyTable("SysFormField", false) && |
|||
!db.DbMaintenance.IsAnyTable("SysFormUpload", false)) |
|||
{ |
|||
db.CodeFirst.InitTables<SysField>(); |
|||
db.CodeFirst.InitTables<SysFormField>(); |
|||
db.CodeFirst.InitTables<SysFormUpload>(); |
|||
} |
|||
|
|||
|
|||
//用例代码
|
|||
|
|||
SysFormField addSysFormFieldInput = new SysFormField() |
|||
{ |
|||
FieldId = 0, |
|||
Order = 0, |
|||
DefaultValue = "", |
|||
FieldName = "", |
|||
|
|||
FieldTypeName = "", |
|||
FieldAlias = "", |
|||
|
|||
UpdateUserId=1, |
|||
CreateUserId=1, |
|||
IsDelete=false, |
|||
FormUpload=new SysFormUpload() { CreateUserId=1, CreateTime =DateTime.Now,UpdateTime=DateTime.Now}, |
|||
SysField=new SysField() { Order=1, CreateUserId=2, FieldTypeName ="a", FieldName="a", UpdateTime=DateTime.Now, CreateTime=DateTime.Now}, |
|||
CreateTime=DateTime.Now, |
|||
UpdateTime=DateTime.Now |
|||
|
|||
}; |
|||
|
|||
var entity = addSysFormFieldInput; |
|||
|
|||
db.InsertNav(entity) |
|||
.Include(x => x.SysField) |
|||
.Include(x => x.FormUpload) |
|||
.ExecuteCommand(); |
|||
|
|||
Console.WriteLine("用例跑完"); |
|||
Console.ReadKey(); |
|||
} |
|||
|
|||
|
|||
} |
Loading…
Reference in new issue