Initial_commit_SecMPS_v2
This commit is contained in:
192
api_sqlsugar/VolPro.Core/UserManager/TableColumnContext.cs
Normal file
192
api_sqlsugar/VolPro.Core/UserManager/TableColumnContext.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using VolPro.Core.DBManager;
|
||||
using VolPro.Core.DbSqlSugar;
|
||||
using VolPro.Entity.DomainModels;
|
||||
namespace VolPro.Core.UserManager
|
||||
{
|
||||
|
||||
public static class TableColumnContext
|
||||
{
|
||||
private static object _colObject = new object();
|
||||
private static List<TableColumnField> _columnData = null;
|
||||
|
||||
public static List<TableColumnField> Data
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_columnData != null) return _columnData;
|
||||
|
||||
lock (_colObject)
|
||||
{
|
||||
if (_columnData == null)
|
||||
{
|
||||
_columnData = DbManger.SysDbContext.Queryable<Sys_TableColumn>()
|
||||
.OrderByDescending(x => x.OrderNo).Select(s => new TableColumnField
|
||||
{
|
||||
ColumnCnName = s.ColumnCnName,
|
||||
ColumnName = s.ColumnName,
|
||||
ColumnType = s.ColumnType,
|
||||
IsDisplay = s.IsDisplay ?? 1,
|
||||
IsKey = s.IsKey,
|
||||
TableName = s.TableName,
|
||||
ReferenceField = s.ReferenceField ?? 0,
|
||||
IsNull = s.IsNull ?? 1,
|
||||
Maxlength = s.Maxlength,
|
||||
OrderNo = s.OrderNo
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
return _columnData;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static object _tableObject = new object();
|
||||
private static List<TableInfo> _tableData = null;
|
||||
public static void Reload()
|
||||
{
|
||||
_columnData = null;
|
||||
_tableData = null;
|
||||
}
|
||||
|
||||
public static List<TableInfo> TableInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tableData != null)
|
||||
{
|
||||
return _tableData;
|
||||
}
|
||||
lock (_tableObject)
|
||||
{
|
||||
if (_tableData == null)
|
||||
{
|
||||
_tableData = DbManger.SysDbContext.Queryable<Sys_TableInfo>().Select(s => new TableInfo()
|
||||
{
|
||||
ActionLog = s.ActionLog,
|
||||
ColumnCNName = s.ColumnCNName,
|
||||
TableTrueName = s.TableTrueName,
|
||||
SortName = s.SortName,
|
||||
TableName = s.TableName,
|
||||
DetailCnName = s.DetailCnName,
|
||||
DetailName = s.DetailName,
|
||||
Table_Id = s.Table_Id,
|
||||
DbSql = s.DbSql,
|
||||
DBServer = s.DBServer,
|
||||
MainKeyField = null
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
return _tableData;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取表隐藏的字段
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetTableHideFields(string table)
|
||||
{
|
||||
return Data.Where(x => x.TableName == table && x.IsDisplay == 0).Select(s => s.ColumnName).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TableColumnField
|
||||
{
|
||||
public int? IsKey { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// <summary>
|
||||
[Display(Name = "")]
|
||||
[Editable(true)]
|
||||
public string ColumnName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// <summary>
|
||||
[Display(Name = "")]
|
||||
[Editable(true)]
|
||||
public string ColumnCnName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// <summary>
|
||||
[Display(Name = "")]
|
||||
[Editable(true)]
|
||||
public string ColumnType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// <summary>
|
||||
[Display(Name = "")]
|
||||
[Editable(true)]
|
||||
public string TableName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// <summary>
|
||||
[Display(Name = "")]
|
||||
[Column(TypeName = "int")]
|
||||
[Editable(true)]
|
||||
public int? IsDisplay { get; set; }
|
||||
/// <summary>
|
||||
/// 关联的表字段
|
||||
/// </summary>
|
||||
public int? ReferenceField { get; set; }
|
||||
|
||||
public int? IsNull { get; set; }
|
||||
public int? Maxlength { get; set; }
|
||||
public int? OrderNo { get; set; }
|
||||
}
|
||||
|
||||
public class TableInfo
|
||||
{
|
||||
[Column(TypeName = "int")]
|
||||
public int Table_Id { get; set; }
|
||||
|
||||
[Editable(true)]
|
||||
public string TableName { get; set; }
|
||||
[Editable(true)]
|
||||
public string TableTrueName { get; set; }
|
||||
[Editable(true)]
|
||||
public string ColumnCNName { get; set; }
|
||||
|
||||
public string SortName { get; set; }
|
||||
/// <summary>
|
||||
/// 与主表关联的字段
|
||||
/// </summary>
|
||||
[Editable(true)]
|
||||
public string ForeignField { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 显示所有查询条件
|
||||
/// </summary>
|
||||
[Editable(true)]
|
||||
public int? FixedSearch { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 启用日志审计
|
||||
/// </summary>
|
||||
[Editable(true)]
|
||||
public int? ActionLog { get; set; }
|
||||
|
||||
public string DetailCnName { get; set; }
|
||||
|
||||
public string DetailName { get; set; }
|
||||
public string DbSql { get; set; }
|
||||
public string DBServer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主表主键字段
|
||||
/// </summary>
|
||||
public string MainKeyField { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user