升级到.net 6
This commit is contained in:
Binary file not shown.
+14
-11
@@ -1,22 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--核心设置-->
|
||||
<Setting>
|
||||
<Core>
|
||||
<!--全局调试。XTrace.Debug-->
|
||||
<Debug>true</Debug>
|
||||
<!--日志等级。只输出大于等于该级别的日志,All/Debug/Info/Warn/Error/Fatal,默认Info-->
|
||||
<LogLevel>Info</LogLevel>
|
||||
<!--文件日志目录-->
|
||||
<!--文件日志目录。默认Log子目录,web上一级Log-->
|
||||
<LogPath>Log</LogPath>
|
||||
<!--网络日志。本地子网日志广播255.255.255.255:514-->
|
||||
<NetworkLog></NetworkLog>
|
||||
<!--日志文件格式。默认{0:yyyy_MM_dd}.log-->
|
||||
<!--日志文件上限。超过上限后拆分新日志文件,默认10MB,0表示不限制大小-->
|
||||
<LogFileMaxBytes>10</LogFileMaxBytes>
|
||||
<!--日志文件备份。超过备份数后,最旧的文件将被删除,默认100,0表示不限制个数-->
|
||||
<LogFileBackups>100</LogFileBackups>
|
||||
<!--日志文件格式。默认{0:yyyy_MM_dd}.log,支持日志等级如 {1}_{0:yyyy_MM_dd}.log-->
|
||||
<LogFileFormat>{0:yyyy_MM_dd}.log</LogFileFormat>
|
||||
<!--临时目录-->
|
||||
<TempPath>XTemp</TempPath>
|
||||
<!--网络日志。本地子网日志广播udp://255.255.255.255:514,或者http://xxx:80/log-->
|
||||
<NetworkLog></NetworkLog>
|
||||
<!--数据目录。本地数据库目录,默认Data子目录,web上一级Data-->
|
||||
<DataPath>Data</DataPath>
|
||||
<!--备份目录。备份数据库时存放的目录,默认Backup子目录,web上一级Backup-->
|
||||
<BackupPath>Backup</BackupPath>
|
||||
<!--插件目录-->
|
||||
<PluginPath>Plugins</PluginPath>
|
||||
<!--插件服务器。将从该网页上根据关键字分析链接并下载插件-->
|
||||
<PluginServer>http://x.newlifex.com/</PluginServer>
|
||||
<!--插件缓存目录。默认位于系统盘的X\Cache-->
|
||||
<PluginCache>C:\X\Cache</PluginCache>
|
||||
</Setting>
|
||||
</Core>
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--XCode设置-->
|
||||
<Setting>
|
||||
<XCode>
|
||||
<!--调试-->
|
||||
<Debug>true</Debug>
|
||||
<!--输出SQL。是否输出SQL语句,默认启用-->
|
||||
@@ -9,17 +8,15 @@
|
||||
<SQLPath></SQLPath>
|
||||
<!--SQL执行时间。跟踪SQL执行时间,大于该阀值将输出日志,默认1000毫秒-->
|
||||
<TraceSQLTime>1000</TraceSQLTime>
|
||||
<!--连接映射。连接名映射#,表名映射@,把实体类中的Test2和Test3连接名映射到Test去-->
|
||||
<ConnMaps></ConnMaps>
|
||||
<!--SQL最大长度。输出日志时的SQL最大长度,超长截断,默认4096,不截断用0-->
|
||||
<SQLMaxLength>4096</SQLMaxLength>
|
||||
<!--参数化添删改查。默认关闭-->
|
||||
<UseParameter>false</UseParameter>
|
||||
<!--SQLite默认目录。没有设置连接字符串的连接默认创建SQLite连接,数据库放在该目录-->
|
||||
<SQLiteDbPath>.</SQLiteDbPath>
|
||||
<!--备份目录。备份数据库时存放的目录-->
|
||||
<BackupPath>Backup</BackupPath>
|
||||
<!--命令超时。查询执行超时时间,默认0秒不限制-->
|
||||
<CommandTimeout>0</CommandTimeout>
|
||||
<!--数据层缓存。默认0秒-->
|
||||
<!--失败重试。执行命令超时后的重试次数,默认0不重试-->
|
||||
<RetryOnFailure>0</RetryOnFailure>
|
||||
<!--数据层缓存。根据sql做缓存,默认0秒-->
|
||||
<DataCacheExpire>0</DataCacheExpire>
|
||||
<!--实体缓存过期。整表缓存实体列表,默认10秒-->
|
||||
<EntityCacheExpire>10</EntityCacheExpire>
|
||||
@@ -29,4 +26,6 @@
|
||||
<ExtendExpire>10</ExtendExpire>
|
||||
<!--反向工程。Off 关闭;ReadOnly 只读不执行;On 打开,仅新建;Full 完全,修改删除-->
|
||||
<Migration>On</Migration>
|
||||
</Setting>
|
||||
<!--表名称、字段名大小写格式。Default 根据模型生成;Upper 全大写;Lower 全小写;Underline下划线-->
|
||||
<NameFormat>Default</NameFormat>
|
||||
</XCode>
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"OSName": "Windows 11 企业版",
|
||||
"OSVersion": "6.2.9200.0",
|
||||
"Product": "System Product Name",
|
||||
"Processor": "12th Gen Intel(R) Core(TM) i7-12700K",
|
||||
"CpuID": "BFEBFBFF00090672",
|
||||
"UUID": "45AA16D8-DF2F-3221-350A-04421A983F7F",
|
||||
"Guid": "5f9c0713-29c7-4621-b35e-b35efd70a57b",
|
||||
"DiskID": "0025_38DC_11B1_45AC.",
|
||||
"Memory": 34088443904,
|
||||
"AvailableMemory": 14803206144,
|
||||
"CpuRate": 0.02833942,
|
||||
"UplinkSpeed": 0,
|
||||
"DownlinkSpeed": 0,
|
||||
"Temperature": 0,
|
||||
"Battery": 0
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<#@ template language="C#" hostSpecific="true" debug="true" #>
|
||||
<#@ assembly name="$(ProjectDir)\$(OutputPath)\NewLife.Core.dll" #>
|
||||
<#@ assembly name="$(ProjectDir)\$(OutputPath)\XCode.dll" #>
|
||||
<#@ import namespace="System.Diagnostics" #>
|
||||
<#@ import namespace="System.IO" #>
|
||||
<#@ import namespace="XCode.Code" #>
|
||||
<#@ import namespace="XCode.DataAccessLayer" #>
|
||||
<#@ output extension=".log" #>
|
||||
<#
|
||||
// 设置当前工作目录
|
||||
PathHelper.BasePath = Host.ResolvePath(".");
|
||||
|
||||
// 设置如何格式化字段名,默认去掉下划线并转驼峰命名
|
||||
//ModelResolver.Current = new ModelResolver { TrimUnderline = false, Camel = false };
|
||||
|
||||
// 加载模型文件,得到数据表
|
||||
var option = new BuilderOption();
|
||||
var tables = ClassBuilder.LoadModels(null, option, out var atts);
|
||||
EntityBuilder.FixModelFile(null, option, atts, tables);
|
||||
|
||||
// 生成实体类
|
||||
//option.BaseClass = "I{name}";
|
||||
//option.ModelNameForCopy = "I{name}";
|
||||
EntityBuilder.BuildTables(tables, option, chineseFileName: true);
|
||||
|
||||
// 生成简易模型类
|
||||
option.Output = @"Output\EntityModels\";
|
||||
option.ClassNameTemplate = "{name}Model";
|
||||
option.ModelNameForCopy = "I{name}";
|
||||
//ClassBuilder.BuildModels(tables, option);
|
||||
|
||||
// 生成简易接口
|
||||
option.BaseClass = null;
|
||||
option.ClassNameTemplate = null;
|
||||
option.Output = @"Output\EntityInterfaces\";
|
||||
//ClassBuilder.BuildInterfaces(tables, option);
|
||||
|
||||
// 精确控制生成
|
||||
/*foreach (var item in tables)
|
||||
{
|
||||
var builder = new ClassBuilder
|
||||
{
|
||||
Table = item,
|
||||
Option = option.Clone(),
|
||||
};
|
||||
builder.Execute();
|
||||
builder.Save(null, true, false);
|
||||
}*/
|
||||
#>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Setting>
|
||||
<!--全局调试。XTrace.Debug-->
|
||||
<Debug>true</Debug>
|
||||
<!--日志等级。只输出大于等于该级别的日志,All/Debug/Info/Warn/Error/Fatal,默认Info-->
|
||||
<LogLevel>Info</LogLevel>
|
||||
<!--文件日志目录。默认Log子目录,web上一级Log-->
|
||||
<LogPath>Log</LogPath>
|
||||
<!--日志文件上限。超过上限后拆分新日志文件,默认10MB,0表示不限制大小-->
|
||||
<LogFileMaxBytes>10</LogFileMaxBytes>
|
||||
<!--日志文件备份。超过备份数后,最旧的文件将被删除,默认100,0表示不限制个数-->
|
||||
<LogFileBackups>100</LogFileBackups>
|
||||
<!--日志文件格式。默认{0:yyyy_MM_dd}.log,支持日志等级如 {1}_{0:yyyy_MM_dd}.log-->
|
||||
<LogFileFormat>{0:yyyy_MM_dd}.log</LogFileFormat>
|
||||
<!--网络日志。本地子网日志广播udp://255.255.255.255:514,或者http://xxx:80/log-->
|
||||
<NetworkLog></NetworkLog>
|
||||
<!--数据目录。本地数据库目录,默认Data子目录,web上一级Data-->
|
||||
<DataPath>Data</DataPath>
|
||||
<!--备份目录。备份数据库时存放的目录,默认Backup子目录,web上一级Backup-->
|
||||
<BackupPath>Backup</BackupPath>
|
||||
<!--插件目录-->
|
||||
<PluginPath>Plugins</PluginPath>
|
||||
<!--插件服务器。将从该网页上根据关键字分析链接并下载插件-->
|
||||
<PluginServer>http://x.newlifex.com/</PluginServer>
|
||||
</Setting>
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Setting>
|
||||
<!--调试-->
|
||||
<Debug>true</Debug>
|
||||
<!--输出SQL。是否输出SQL语句,默认启用-->
|
||||
<ShowSQL>true</ShowSQL>
|
||||
<!--SQL目录。设置SQL输出的单独目录,默认为空,SQL输出到当前日志中。生产环境建议输出到站点外单独的SqlLog目录-->
|
||||
<SQLPath></SQLPath>
|
||||
<!--SQL执行时间。跟踪SQL执行时间,大于该阀值将输出日志,默认1000毫秒-->
|
||||
<TraceSQLTime>1000</TraceSQLTime>
|
||||
<!--SQL最大长度。输出日志时的SQL最大长度,超长截断,默认4096,不截断用0-->
|
||||
<SQLMaxLength>4096</SQLMaxLength>
|
||||
<!--连接映射。连接名映射#,表名映射@,把实体类中的Test2和Test3连接名映射到Test去-->
|
||||
<ConnMaps></ConnMaps>
|
||||
<!--参数化添删改查。默认关闭-->
|
||||
<UseParameter>false</UseParameter>
|
||||
<!--命令超时。查询执行超时时间,默认0秒不限制-->
|
||||
<CommandTimeout>0</CommandTimeout>
|
||||
<!--失败重试。执行命令超时后的重试次数,默认0不重试-->
|
||||
<RetryOnFailure>0</RetryOnFailure>
|
||||
<!--数据层缓存。默认0秒,达到60秒后全表查询使用文件缓存-->
|
||||
<DataCacheExpire>0</DataCacheExpire>
|
||||
<!--实体缓存过期。整表缓存实体列表,默认10秒-->
|
||||
<EntityCacheExpire>10</EntityCacheExpire>
|
||||
<!--单对象缓存过期。按主键缓存实体,默认10秒-->
|
||||
<SingleCacheExpire>10</SingleCacheExpire>
|
||||
<!--扩展属性过期。扩展属性Extends缓存,默认10秒-->
|
||||
<ExtendExpire>10</ExtendExpire>
|
||||
<!--反向工程。Off 关闭;ReadOnly 只读不执行;On 打开,仅新建;Full 完全,修改删除-->
|
||||
<Migration>On</Migration>
|
||||
<!--表名称、字段名大小写格式。Default 根据模型生成;Upper 全大写;Lower 全小写-->
|
||||
<NameFormat>Default</NameFormat>
|
||||
</Setting>
|
||||
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>地区。行政区划数据</summary>
|
||||
public partial class Area : Entity<Area>
|
||||
{
|
||||
#region 对象操作
|
||||
static Area()
|
||||
{
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(nameof(ParentID));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<UserModule>();
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Modules.Add<IPModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 处理当前已登录用户信息,可以由UserModule过滤器代劳
|
||||
/*var user = ManageProvider.User;
|
||||
if (user != null)
|
||||
{
|
||||
if (!Dirtys[nameof(UpdateUserID)]) UpdateUserID = user.ID;
|
||||
}*/
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
//if (!Dirtys[nameof(UpdateIP)]) UpdateIP = ManageProvider.UserHost;
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Session.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Area[地区]数据……");
|
||||
|
||||
// var entity = new Area();
|
||||
// entity.ID = 0;
|
||||
// entity.Name = "abc";
|
||||
// entity.FullName = "abc";
|
||||
// entity.ParentID = 0;
|
||||
// entity.Level = 0;
|
||||
// entity.Longitude = 0.0;
|
||||
// entity.Latitude = 0.0;
|
||||
// entity.Enable = true;
|
||||
// entity.UpdateUser = "abc";
|
||||
// entity.UpdateUserID = 0;
|
||||
// entity.UpdateIP = "abc";
|
||||
// entity.UpdateTime = DateTime.Now;
|
||||
// entity.Remark = "abc";
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化Area[地区]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编码查找</summary>
|
||||
/// <param name="id">编码</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static Area FindByID(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
|
||||
|
||||
// 单对象缓存
|
||||
return Meta.SingleCache[id];
|
||||
|
||||
//return Find(_.ID == id);
|
||||
}
|
||||
|
||||
/// <summary>根据父级查找</summary>
|
||||
/// <param name="parentId">父级</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Area> FindAllByParentID(Int32 parentId)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.ParentID == parentId);
|
||||
|
||||
return FindAll(_.ParentID == parentId);
|
||||
}
|
||||
|
||||
/// <summary>根据名称查找</summary>
|
||||
/// <param name="name">名称</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Area> FindAllByName(String name)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
|
||||
|
||||
return FindAll(_.Name == name);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
/// <summary>高级查询</summary>
|
||||
/// <param name="name">名称</param>
|
||||
/// <param name="parentId">父级</param>
|
||||
/// <param name="start">更新时间开始</param>
|
||||
/// <param name="end">更新时间结束</param>
|
||||
/// <param name="key">关键字</param>
|
||||
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Area> Search(String name, Int32 parentId, DateTime start, DateTime end, String key, PageParameter page)
|
||||
{
|
||||
var exp = new WhereExpression();
|
||||
|
||||
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
|
||||
if (parentId >= 0) exp &= _.ParentID == parentId;
|
||||
exp &= _.UpdateTime.Between(start, end);
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.FullName.Contains(key) | _.UpdateUser.Contains(key) | _.UpdateIP.Contains(key) | _.Remark.Contains(key);
|
||||
|
||||
return FindAll(exp, page);
|
||||
}
|
||||
|
||||
// Select Count(Id) as Id,Category From Area Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<Area> _CategoryCache = new FieldCache<Area>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>地区。行政区划数据</summary>
|
||||
[Serializable]
|
||||
[DataObject]
|
||||
[Description("地区。行政区划数据")]
|
||||
[BindIndex("IX_Area_ParentID", false, "ParentID")]
|
||||
[BindIndex("IX_Area_Name", false, "Name")]
|
||||
[BindIndex("IX_Area_UpdateTime_ID", false, "UpdateTime,ID")]
|
||||
[BindTable("Area", Description = "地区。行政区划数据", ConnName = "Membership", DbType = DatabaseType.None)]
|
||||
public partial class Area
|
||||
{
|
||||
#region 属性
|
||||
private Int32 _ID;
|
||||
/// <summary>编码。行政区划编码</summary>
|
||||
[DisplayName("编码")]
|
||||
[Description("编码。行政区划编码")]
|
||||
[DataObjectField(true, false, false, 0)]
|
||||
[BindColumn("ID", "编码。行政区划编码", "")]
|
||||
public Int32 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }
|
||||
|
||||
private String _Name;
|
||||
/// <summary>名称</summary>
|
||||
[DisplayName("名称")]
|
||||
[Description("名称")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Name", "名称", "", Master = true)]
|
||||
public String Name { get => _Name; set { if (OnPropertyChanging("Name", value)) { _Name = value; OnPropertyChanged("Name"); } } }
|
||||
|
||||
private String _FullName;
|
||||
/// <summary>全名</summary>
|
||||
[DisplayName("全名")]
|
||||
[Description("全名")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("FullName", "全名", "", Master = true)]
|
||||
public String FullName { get => _FullName; set { if (OnPropertyChanging("FullName", value)) { _FullName = value; OnPropertyChanged("FullName"); } } }
|
||||
|
||||
private Int32 _ParentID;
|
||||
/// <summary>父级</summary>
|
||||
[DisplayName("父级")]
|
||||
[Description("父级")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("ParentID", "父级", "")]
|
||||
public Int32 ParentID { get => _ParentID; set { if (OnPropertyChanging("ParentID", value)) { _ParentID = value; OnPropertyChanged("ParentID"); } } }
|
||||
|
||||
private Int32 _Level;
|
||||
/// <summary>层级</summary>
|
||||
[DisplayName("层级")]
|
||||
[Description("层级")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Level", "层级", "")]
|
||||
public Int32 Level { get => _Level; set { if (OnPropertyChanging("Level", value)) { _Level = value; OnPropertyChanged("Level"); } } }
|
||||
|
||||
private Double _Longitude;
|
||||
/// <summary>经度</summary>
|
||||
[DisplayName("经度")]
|
||||
[Description("经度")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Longitude", "经度", "")]
|
||||
public Double Longitude { get => _Longitude; set { if (OnPropertyChanging("Longitude", value)) { _Longitude = value; OnPropertyChanged("Longitude"); } } }
|
||||
|
||||
private Double _Latitude;
|
||||
/// <summary>纬度</summary>
|
||||
[DisplayName("纬度")]
|
||||
[Description("纬度")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Latitude", "纬度", "")]
|
||||
public Double Latitude { get => _Latitude; set { if (OnPropertyChanging("Latitude", value)) { _Latitude = value; OnPropertyChanged("Latitude"); } } }
|
||||
|
||||
private Boolean _Enable;
|
||||
/// <summary>启用</summary>
|
||||
[DisplayName("启用")]
|
||||
[Description("启用")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Enable", "启用", "")]
|
||||
public Boolean Enable { get => _Enable; set { if (OnPropertyChanging("Enable", value)) { _Enable = value; OnPropertyChanged("Enable"); } } }
|
||||
|
||||
private String _UpdateUser;
|
||||
/// <summary>更新者</summary>
|
||||
[DisplayName("更新者")]
|
||||
[Description("更新者")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateUser", "更新者", "")]
|
||||
public String UpdateUser { get => _UpdateUser; set { if (OnPropertyChanging("UpdateUser", value)) { _UpdateUser = value; OnPropertyChanged("UpdateUser"); } } }
|
||||
|
||||
private Int32 _UpdateUserID;
|
||||
/// <summary>更新用户</summary>
|
||||
[DisplayName("更新用户")]
|
||||
[Description("更新用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateUserID", "更新用户", "")]
|
||||
public Int32 UpdateUserID { get => _UpdateUserID; set { if (OnPropertyChanging("UpdateUserID", value)) { _UpdateUserID = value; OnPropertyChanged("UpdateUserID"); } } }
|
||||
|
||||
private String _UpdateIP;
|
||||
/// <summary>更新地址</summary>
|
||||
[DisplayName("更新地址")]
|
||||
[Description("更新地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateIP", "更新地址", "")]
|
||||
public String UpdateIP { get => _UpdateIP; set { if (OnPropertyChanging("UpdateIP", value)) { _UpdateIP = value; OnPropertyChanged("UpdateIP"); } } }
|
||||
|
||||
private DateTime _UpdateTime;
|
||||
/// <summary>更新时间</summary>
|
||||
[DisplayName("更新时间")]
|
||||
[Description("更新时间")]
|
||||
[DataObjectField(false, false, true, 0)]
|
||||
[BindColumn("UpdateTime", "更新时间", "")]
|
||||
public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }
|
||||
|
||||
private String _Remark;
|
||||
/// <summary>备注</summary>
|
||||
[DisplayName("备注")]
|
||||
[Description("备注")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("Remark", "备注", "")]
|
||||
public String Remark { get => _Remark; set { if (OnPropertyChanging("Remark", value)) { _Remark = value; OnPropertyChanged("Remark"); } } }
|
||||
#endregion
|
||||
|
||||
#region 获取/设置 字段值
|
||||
/// <summary>获取/设置 字段值</summary>
|
||||
/// <param name="name">字段名</param>
|
||||
/// <returns></returns>
|
||||
public override Object this[String name]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": return _ID;
|
||||
case "Name": return _Name;
|
||||
case "FullName": return _FullName;
|
||||
case "ParentID": return _ParentID;
|
||||
case "Level": return _Level;
|
||||
case "Longitude": return _Longitude;
|
||||
case "Latitude": return _Latitude;
|
||||
case "Enable": return _Enable;
|
||||
case "UpdateUser": return _UpdateUser;
|
||||
case "UpdateUserID": return _UpdateUserID;
|
||||
case "UpdateIP": return _UpdateIP;
|
||||
case "UpdateTime": return _UpdateTime;
|
||||
case "Remark": return _Remark;
|
||||
default: return base[name];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": _ID = value.ToInt(); break;
|
||||
case "Name": _Name = Convert.ToString(value); break;
|
||||
case "FullName": _FullName = Convert.ToString(value); break;
|
||||
case "ParentID": _ParentID = value.ToInt(); break;
|
||||
case "Level": _Level = value.ToInt(); break;
|
||||
case "Longitude": _Longitude = value.ToDouble(); break;
|
||||
case "Latitude": _Latitude = value.ToDouble(); break;
|
||||
case "Enable": _Enable = value.ToBoolean(); break;
|
||||
case "UpdateUser": _UpdateUser = Convert.ToString(value); break;
|
||||
case "UpdateUserID": _UpdateUserID = value.ToInt(); break;
|
||||
case "UpdateIP": _UpdateIP = Convert.ToString(value); break;
|
||||
case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
|
||||
case "Remark": _Remark = Convert.ToString(value); break;
|
||||
default: base[name] = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字段名
|
||||
/// <summary>取得地区字段信息的快捷方式</summary>
|
||||
public partial class _
|
||||
{
|
||||
/// <summary>编码。行政区划编码</summary>
|
||||
public static readonly Field ID = FindByName("ID");
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public static readonly Field Name = FindByName("Name");
|
||||
|
||||
/// <summary>全名</summary>
|
||||
public static readonly Field FullName = FindByName("FullName");
|
||||
|
||||
/// <summary>父级</summary>
|
||||
public static readonly Field ParentID = FindByName("ParentID");
|
||||
|
||||
/// <summary>层级</summary>
|
||||
public static readonly Field Level = FindByName("Level");
|
||||
|
||||
/// <summary>经度</summary>
|
||||
public static readonly Field Longitude = FindByName("Longitude");
|
||||
|
||||
/// <summary>纬度</summary>
|
||||
public static readonly Field Latitude = FindByName("Latitude");
|
||||
|
||||
/// <summary>启用</summary>
|
||||
public static readonly Field Enable = FindByName("Enable");
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public static readonly Field UpdateUser = FindByName("UpdateUser");
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public static readonly Field UpdateUserID = FindByName("UpdateUserID");
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public static readonly Field UpdateIP = FindByName("UpdateIP");
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public static readonly Field UpdateTime = FindByName("UpdateTime");
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public static readonly Field Remark = FindByName("Remark");
|
||||
|
||||
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||
}
|
||||
|
||||
/// <summary>取得地区字段名称的快捷方式</summary>
|
||||
public partial class __
|
||||
{
|
||||
/// <summary>编码。行政区划编码</summary>
|
||||
public const String ID = "ID";
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public const String Name = "Name";
|
||||
|
||||
/// <summary>全名</summary>
|
||||
public const String FullName = "FullName";
|
||||
|
||||
/// <summary>父级</summary>
|
||||
public const String ParentID = "ParentID";
|
||||
|
||||
/// <summary>层级</summary>
|
||||
public const String Level = "Level";
|
||||
|
||||
/// <summary>经度</summary>
|
||||
public const String Longitude = "Longitude";
|
||||
|
||||
/// <summary>纬度</summary>
|
||||
public const String Latitude = "Latitude";
|
||||
|
||||
/// <summary>启用</summary>
|
||||
public const String Enable = "Enable";
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public const String UpdateUser = "UpdateUser";
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public const String UpdateUserID = "UpdateUserID";
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public const String UpdateIP = "UpdateIP";
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public const String UpdateTime = "UpdateTime";
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public const String Remark = "Remark";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>字典参数</summary>
|
||||
public partial class Parameter : Entity<Parameter>
|
||||
{
|
||||
#region 对象操作
|
||||
static Parameter()
|
||||
{
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(nameof(UserID));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<UserModule>();
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Modules.Add<IPModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 处理当前已登录用户信息,可以由UserModule过滤器代劳
|
||||
/*var user = ManageProvider.User;
|
||||
if (user != null)
|
||||
{
|
||||
if (isNew && !Dirtys[nameof(CreateUserID)]) CreateUserID = user.ID;
|
||||
if (!Dirtys[nameof(UpdateUserID)]) UpdateUserID = user.ID;
|
||||
}*/
|
||||
//if (isNew && !Dirtys[nameof(CreateTime)]) CreateTime = DateTime.Now;
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
//if (isNew && !Dirtys[nameof(CreateIP)]) CreateIP = ManageProvider.UserHost;
|
||||
//if (!Dirtys[nameof(UpdateIP)]) UpdateIP = ManageProvider.UserHost;
|
||||
|
||||
// 检查唯一索引
|
||||
// CheckExist(isNew, nameof(UserID), nameof(Category), nameof(Name));
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Session.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Parameter[字典参数]数据……");
|
||||
|
||||
// var entity = new Parameter();
|
||||
// entity.UserID = 0;
|
||||
// entity.Category = "abc";
|
||||
// entity.Name = "abc";
|
||||
// entity.Value = "abc";
|
||||
// entity.LongValue = "abc";
|
||||
// entity.Kind = 0;
|
||||
// entity.Enable = true;
|
||||
// entity.Ex1 = 0;
|
||||
// entity.Ex2 = 0;
|
||||
// entity.Ex3 = 0.0;
|
||||
// entity.Ex4 = "abc";
|
||||
// entity.Ex5 = "abc";
|
||||
// entity.Ex6 = "abc";
|
||||
// entity.CreateUser = "abc";
|
||||
// entity.CreateUserID = 0;
|
||||
// entity.CreateIP = "abc";
|
||||
// entity.CreateTime = DateTime.Now;
|
||||
// entity.UpdateUser = "abc";
|
||||
// entity.UpdateUserID = 0;
|
||||
// entity.UpdateIP = "abc";
|
||||
// entity.UpdateTime = DateTime.Now;
|
||||
// entity.Remark = "abc";
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化Parameter[字典参数]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>用户</summary>
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public User User => Extends.Get(nameof(User), k => User.FindByID(UserID));
|
||||
|
||||
/// <summary>用户</summary>
|
||||
[Map(nameof(UserID), typeof(User), "ID")]
|
||||
public String UserName => User?.Name;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static Parameter FindByID(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
|
||||
|
||||
// 单对象缓存
|
||||
return Meta.SingleCache[id];
|
||||
|
||||
//return Find(_.ID == id);
|
||||
}
|
||||
|
||||
/// <summary>根据类别、名称查找</summary>
|
||||
/// <param name="category">类别</param>
|
||||
/// <param name="name">名称</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Parameter> FindAllByCategoryAndName(String category, String name)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Category.EqualIgnoreCase(category) && e.Name.EqualIgnoreCase(name));
|
||||
|
||||
return FindAll(_.Category == category & _.Name == name);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
/// <summary>高级查询</summary>
|
||||
/// <param name="userId">用户。按用户区分参数,用户0表示系统级</param>
|
||||
/// <param name="category">类别</param>
|
||||
/// <param name="name">名称</param>
|
||||
/// <param name="start">更新时间开始</param>
|
||||
/// <param name="end">更新时间结束</param>
|
||||
/// <param name="key">关键字</param>
|
||||
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Parameter> Search(Int32 userId, String category, String name, DateTime start, DateTime end, String key, PageParameter page)
|
||||
{
|
||||
var exp = new WhereExpression();
|
||||
|
||||
if (userId >= 0) exp &= _.UserID == userId;
|
||||
if (!category.IsNullOrEmpty()) exp &= _.Category == category;
|
||||
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
|
||||
exp &= _.UpdateTime.Between(start, end);
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Category.Contains(key) | _.Name.Contains(key) | _.Value.Contains(key) | _.LongValue.Contains(key) | _.Ex4.Contains(key) | _.Ex5.Contains(key) | _.Ex6.Contains(key) | _.CreateUser.Contains(key) | _.CreateIP.Contains(key) | _.UpdateUser.Contains(key) | _.UpdateIP.Contains(key) | _.Remark.Contains(key);
|
||||
|
||||
return FindAll(exp, page);
|
||||
}
|
||||
|
||||
// Select Count(ID) as ID,Category From Parameter Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By ID Desc limit 20
|
||||
static readonly FieldCache<Parameter> _CategoryCache = new FieldCache<Parameter>(nameof(Category))
|
||||
{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
};
|
||||
|
||||
/// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
/// <returns></returns>
|
||||
public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,428 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>字典参数</summary>
|
||||
[Serializable]
|
||||
[DataObject]
|
||||
[Description("字典参数")]
|
||||
[BindIndex("IU_Parameter_UserID_Category_Name", true, "UserID,Category,Name")]
|
||||
[BindIndex("IX_Parameter_Category_Name", false, "Category,Name")]
|
||||
[BindIndex("IX_Parameter_UpdateTime", false, "UpdateTime")]
|
||||
[BindTable("Parameter", Description = "字典参数", ConnName = "Membership", DbType = DatabaseType.None)]
|
||||
public partial class Parameter
|
||||
{
|
||||
#region 属性
|
||||
private Int32 _ID;
|
||||
/// <summary>编号</summary>
|
||||
[DisplayName("编号")]
|
||||
[Description("编号")]
|
||||
[DataObjectField(true, true, false, 0)]
|
||||
[BindColumn("ID", "编号", "")]
|
||||
public Int32 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }
|
||||
|
||||
private Int32 _UserID;
|
||||
/// <summary>用户。按用户区分参数,用户0表示系统级</summary>
|
||||
[DisplayName("用户")]
|
||||
[Description("用户。按用户区分参数,用户0表示系统级")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UserID", "用户。按用户区分参数,用户0表示系统级", "")]
|
||||
public Int32 UserID { get => _UserID; set { if (OnPropertyChanging("UserID", value)) { _UserID = value; OnPropertyChanged("UserID"); } } }
|
||||
|
||||
private String _Category;
|
||||
/// <summary>类别</summary>
|
||||
[DisplayName("类别")]
|
||||
[Description("类别")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Category", "类别", "")]
|
||||
public String Category { get => _Category; set { if (OnPropertyChanging("Category", value)) { _Category = value; OnPropertyChanged("Category"); } } }
|
||||
|
||||
private String _Name;
|
||||
/// <summary>名称</summary>
|
||||
[DisplayName("名称")]
|
||||
[Description("名称")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Name", "名称", "", Master = true)]
|
||||
public String Name { get => _Name; set { if (OnPropertyChanging("Name", value)) { _Name = value; OnPropertyChanged("Name"); } } }
|
||||
|
||||
private String _Value;
|
||||
/// <summary>数值</summary>
|
||||
[DisplayName("数值")]
|
||||
[Description("数值")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("Value", "数值", "")]
|
||||
public String Value { get => _Value; set { if (OnPropertyChanging("Value", value)) { _Value = value; OnPropertyChanged("Value"); } } }
|
||||
|
||||
private String _LongValue;
|
||||
/// <summary>长数值</summary>
|
||||
[DisplayName("长数值")]
|
||||
[Description("长数值")]
|
||||
[DataObjectField(false, false, true, 2000)]
|
||||
[BindColumn("LongValue", "长数值", "")]
|
||||
public String LongValue { get => _LongValue; set { if (OnPropertyChanging("LongValue", value)) { _LongValue = value; OnPropertyChanged("LongValue"); } } }
|
||||
|
||||
private XCode.Membership.ParameterKinds _Kind;
|
||||
/// <summary>种类。0普通,21列表,22名值</summary>
|
||||
[DisplayName("种类")]
|
||||
[Description("种类。0普通,21列表,22名值")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Kind", "种类。0普通,21列表,22名值", "")]
|
||||
public XCode.Membership.ParameterKinds Kind { get => _Kind; set { if (OnPropertyChanging("Kind", value)) { _Kind = value; OnPropertyChanged("Kind"); } } }
|
||||
|
||||
private Boolean _Enable;
|
||||
/// <summary>启用</summary>
|
||||
[DisplayName("启用")]
|
||||
[Description("启用")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Enable", "启用", "")]
|
||||
public Boolean Enable { get => _Enable; set { if (OnPropertyChanging("Enable", value)) { _Enable = value; OnPropertyChanged("Enable"); } } }
|
||||
|
||||
private Int32 _Ex1;
|
||||
/// <summary>扩展1</summary>
|
||||
[DisplayName("扩展1")]
|
||||
[Description("扩展1")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex1", "扩展1", "")]
|
||||
public Int32 Ex1 { get => _Ex1; set { if (OnPropertyChanging("Ex1", value)) { _Ex1 = value; OnPropertyChanged("Ex1"); } } }
|
||||
|
||||
private Int32 _Ex2;
|
||||
/// <summary>扩展2</summary>
|
||||
[DisplayName("扩展2")]
|
||||
[Description("扩展2")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex2", "扩展2", "")]
|
||||
public Int32 Ex2 { get => _Ex2; set { if (OnPropertyChanging("Ex2", value)) { _Ex2 = value; OnPropertyChanged("Ex2"); } } }
|
||||
|
||||
private Double _Ex3;
|
||||
/// <summary>扩展3</summary>
|
||||
[DisplayName("扩展3")]
|
||||
[Description("扩展3")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex3", "扩展3", "")]
|
||||
public Double Ex3 { get => _Ex3; set { if (OnPropertyChanging("Ex3", value)) { _Ex3 = value; OnPropertyChanged("Ex3"); } } }
|
||||
|
||||
private String _Ex4;
|
||||
/// <summary>扩展4</summary>
|
||||
[DisplayName("扩展4")]
|
||||
[Description("扩展4")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex4", "扩展4", "")]
|
||||
public String Ex4 { get => _Ex4; set { if (OnPropertyChanging("Ex4", value)) { _Ex4 = value; OnPropertyChanged("Ex4"); } } }
|
||||
|
||||
private String _Ex5;
|
||||
/// <summary>扩展5</summary>
|
||||
[DisplayName("扩展5")]
|
||||
[Description("扩展5")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex5", "扩展5", "")]
|
||||
public String Ex5 { get => _Ex5; set { if (OnPropertyChanging("Ex5", value)) { _Ex5 = value; OnPropertyChanged("Ex5"); } } }
|
||||
|
||||
private String _Ex6;
|
||||
/// <summary>扩展6</summary>
|
||||
[DisplayName("扩展6")]
|
||||
[Description("扩展6")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex6", "扩展6", "")]
|
||||
public String Ex6 { get => _Ex6; set { if (OnPropertyChanging("Ex6", value)) { _Ex6 = value; OnPropertyChanged("Ex6"); } } }
|
||||
|
||||
private String _CreateUser;
|
||||
/// <summary>创建者</summary>
|
||||
[DisplayName("创建者")]
|
||||
[Description("创建者")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("CreateUser", "创建者", "")]
|
||||
public String CreateUser { get => _CreateUser; set { if (OnPropertyChanging("CreateUser", value)) { _CreateUser = value; OnPropertyChanged("CreateUser"); } } }
|
||||
|
||||
private Int32 _CreateUserID;
|
||||
/// <summary>创建用户</summary>
|
||||
[DisplayName("创建用户")]
|
||||
[Description("创建用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateUserID", "创建用户", "")]
|
||||
public Int32 CreateUserID { get => _CreateUserID; set { if (OnPropertyChanging("CreateUserID", value)) { _CreateUserID = value; OnPropertyChanged("CreateUserID"); } } }
|
||||
|
||||
private String _CreateIP;
|
||||
/// <summary>创建地址</summary>
|
||||
[DisplayName("创建地址")]
|
||||
[Description("创建地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("CreateIP", "创建地址", "")]
|
||||
public String CreateIP { get => _CreateIP; set { if (OnPropertyChanging("CreateIP", value)) { _CreateIP = value; OnPropertyChanged("CreateIP"); } } }
|
||||
|
||||
private DateTime _CreateTime;
|
||||
/// <summary>创建时间</summary>
|
||||
[DisplayName("创建时间")]
|
||||
[Description("创建时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateTime", "创建时间", "")]
|
||||
public DateTime CreateTime { get => _CreateTime; set { if (OnPropertyChanging("CreateTime", value)) { _CreateTime = value; OnPropertyChanged("CreateTime"); } } }
|
||||
|
||||
private String _UpdateUser;
|
||||
/// <summary>更新者</summary>
|
||||
[DisplayName("更新者")]
|
||||
[Description("更新者")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateUser", "更新者", "")]
|
||||
public String UpdateUser { get => _UpdateUser; set { if (OnPropertyChanging("UpdateUser", value)) { _UpdateUser = value; OnPropertyChanged("UpdateUser"); } } }
|
||||
|
||||
private Int32 _UpdateUserID;
|
||||
/// <summary>更新用户</summary>
|
||||
[DisplayName("更新用户")]
|
||||
[Description("更新用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateUserID", "更新用户", "")]
|
||||
public Int32 UpdateUserID { get => _UpdateUserID; set { if (OnPropertyChanging("UpdateUserID", value)) { _UpdateUserID = value; OnPropertyChanged("UpdateUserID"); } } }
|
||||
|
||||
private String _UpdateIP;
|
||||
/// <summary>更新地址</summary>
|
||||
[DisplayName("更新地址")]
|
||||
[Description("更新地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateIP", "更新地址", "")]
|
||||
public String UpdateIP { get => _UpdateIP; set { if (OnPropertyChanging("UpdateIP", value)) { _UpdateIP = value; OnPropertyChanged("UpdateIP"); } } }
|
||||
|
||||
private DateTime _UpdateTime;
|
||||
/// <summary>更新时间</summary>
|
||||
[DisplayName("更新时间")]
|
||||
[Description("更新时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateTime", "更新时间", "")]
|
||||
public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }
|
||||
|
||||
private String _Remark;
|
||||
/// <summary>备注</summary>
|
||||
[DisplayName("备注")]
|
||||
[Description("备注")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("Remark", "备注", "")]
|
||||
public String Remark { get => _Remark; set { if (OnPropertyChanging("Remark", value)) { _Remark = value; OnPropertyChanged("Remark"); } } }
|
||||
#endregion
|
||||
|
||||
#region 获取/设置 字段值
|
||||
/// <summary>获取/设置 字段值</summary>
|
||||
/// <param name="name">字段名</param>
|
||||
/// <returns></returns>
|
||||
public override Object this[String name]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": return _ID;
|
||||
case "UserID": return _UserID;
|
||||
case "Category": return _Category;
|
||||
case "Name": return _Name;
|
||||
case "Value": return _Value;
|
||||
case "LongValue": return _LongValue;
|
||||
case "Kind": return _Kind;
|
||||
case "Enable": return _Enable;
|
||||
case "Ex1": return _Ex1;
|
||||
case "Ex2": return _Ex2;
|
||||
case "Ex3": return _Ex3;
|
||||
case "Ex4": return _Ex4;
|
||||
case "Ex5": return _Ex5;
|
||||
case "Ex6": return _Ex6;
|
||||
case "CreateUser": return _CreateUser;
|
||||
case "CreateUserID": return _CreateUserID;
|
||||
case "CreateIP": return _CreateIP;
|
||||
case "CreateTime": return _CreateTime;
|
||||
case "UpdateUser": return _UpdateUser;
|
||||
case "UpdateUserID": return _UpdateUserID;
|
||||
case "UpdateIP": return _UpdateIP;
|
||||
case "UpdateTime": return _UpdateTime;
|
||||
case "Remark": return _Remark;
|
||||
default: return base[name];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": _ID = value.ToInt(); break;
|
||||
case "UserID": _UserID = value.ToInt(); break;
|
||||
case "Category": _Category = Convert.ToString(value); break;
|
||||
case "Name": _Name = Convert.ToString(value); break;
|
||||
case "Value": _Value = Convert.ToString(value); break;
|
||||
case "LongValue": _LongValue = Convert.ToString(value); break;
|
||||
case "Kind": _Kind = (XCode.Membership.ParameterKinds)value.ToInt(); break;
|
||||
case "Enable": _Enable = value.ToBoolean(); break;
|
||||
case "Ex1": _Ex1 = value.ToInt(); break;
|
||||
case "Ex2": _Ex2 = value.ToInt(); break;
|
||||
case "Ex3": _Ex3 = value.ToDouble(); break;
|
||||
case "Ex4": _Ex4 = Convert.ToString(value); break;
|
||||
case "Ex5": _Ex5 = Convert.ToString(value); break;
|
||||
case "Ex6": _Ex6 = Convert.ToString(value); break;
|
||||
case "CreateUser": _CreateUser = Convert.ToString(value); break;
|
||||
case "CreateUserID": _CreateUserID = value.ToInt(); break;
|
||||
case "CreateIP": _CreateIP = Convert.ToString(value); break;
|
||||
case "CreateTime": _CreateTime = value.ToDateTime(); break;
|
||||
case "UpdateUser": _UpdateUser = Convert.ToString(value); break;
|
||||
case "UpdateUserID": _UpdateUserID = value.ToInt(); break;
|
||||
case "UpdateIP": _UpdateIP = Convert.ToString(value); break;
|
||||
case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
|
||||
case "Remark": _Remark = Convert.ToString(value); break;
|
||||
default: base[name] = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字段名
|
||||
/// <summary>取得字典参数字段信息的快捷方式</summary>
|
||||
public partial class _
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public static readonly Field ID = FindByName("ID");
|
||||
|
||||
/// <summary>用户。按用户区分参数,用户0表示系统级</summary>
|
||||
public static readonly Field UserID = FindByName("UserID");
|
||||
|
||||
/// <summary>类别</summary>
|
||||
public static readonly Field Category = FindByName("Category");
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public static readonly Field Name = FindByName("Name");
|
||||
|
||||
/// <summary>数值</summary>
|
||||
public static readonly Field Value = FindByName("Value");
|
||||
|
||||
/// <summary>长数值</summary>
|
||||
public static readonly Field LongValue = FindByName("LongValue");
|
||||
|
||||
/// <summary>种类。0普通,21列表,22名值</summary>
|
||||
public static readonly Field Kind = FindByName("Kind");
|
||||
|
||||
/// <summary>启用</summary>
|
||||
public static readonly Field Enable = FindByName("Enable");
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public static readonly Field Ex1 = FindByName("Ex1");
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public static readonly Field Ex2 = FindByName("Ex2");
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public static readonly Field Ex3 = FindByName("Ex3");
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public static readonly Field Ex4 = FindByName("Ex4");
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public static readonly Field Ex5 = FindByName("Ex5");
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public static readonly Field Ex6 = FindByName("Ex6");
|
||||
|
||||
/// <summary>创建者</summary>
|
||||
public static readonly Field CreateUser = FindByName("CreateUser");
|
||||
|
||||
/// <summary>创建用户</summary>
|
||||
public static readonly Field CreateUserID = FindByName("CreateUserID");
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public static readonly Field CreateIP = FindByName("CreateIP");
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public static readonly Field CreateTime = FindByName("CreateTime");
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public static readonly Field UpdateUser = FindByName("UpdateUser");
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public static readonly Field UpdateUserID = FindByName("UpdateUserID");
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public static readonly Field UpdateIP = FindByName("UpdateIP");
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public static readonly Field UpdateTime = FindByName("UpdateTime");
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public static readonly Field Remark = FindByName("Remark");
|
||||
|
||||
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||
}
|
||||
|
||||
/// <summary>取得字典参数字段名称的快捷方式</summary>
|
||||
public partial class __
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public const String ID = "ID";
|
||||
|
||||
/// <summary>用户。按用户区分参数,用户0表示系统级</summary>
|
||||
public const String UserID = "UserID";
|
||||
|
||||
/// <summary>类别</summary>
|
||||
public const String Category = "Category";
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public const String Name = "Name";
|
||||
|
||||
/// <summary>数值</summary>
|
||||
public const String Value = "Value";
|
||||
|
||||
/// <summary>长数值</summary>
|
||||
public const String LongValue = "LongValue";
|
||||
|
||||
/// <summary>种类。0普通,21列表,22名值</summary>
|
||||
public const String Kind = "Kind";
|
||||
|
||||
/// <summary>启用</summary>
|
||||
public const String Enable = "Enable";
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public const String Ex1 = "Ex1";
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public const String Ex2 = "Ex2";
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public const String Ex3 = "Ex3";
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public const String Ex4 = "Ex4";
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public const String Ex5 = "Ex5";
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public const String Ex6 = "Ex6";
|
||||
|
||||
/// <summary>创建者</summary>
|
||||
public const String CreateUser = "CreateUser";
|
||||
|
||||
/// <summary>创建用户</summary>
|
||||
public const String CreateUserID = "CreateUserID";
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public const String CreateIP = "CreateIP";
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public const String CreateTime = "CreateTime";
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public const String UpdateUser = "UpdateUser";
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public const String UpdateUserID = "UpdateUserID";
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public const String UpdateIP = "UpdateIP";
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public const String UpdateTime = "UpdateTime";
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public const String Remark = "Remark";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>日志</summary>
|
||||
public partial class Log : Entity<Log>
|
||||
{
|
||||
#region 对象操作
|
||||
static Log()
|
||||
{
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(nameof(LinkID));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<UserModule>();
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Modules.Add<IPModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 处理当前已登录用户信息,可以由UserModule过滤器代劳
|
||||
/*var user = ManageProvider.User;
|
||||
if (user != null)
|
||||
{
|
||||
if (isNew && !Dirtys[nameof(CreateUserID)]) CreateUserID = user.ID;
|
||||
}*/
|
||||
//if (isNew && !Dirtys[nameof(CreateTime)]) CreateTime = DateTime.Now;
|
||||
//if (isNew && !Dirtys[nameof(CreateIP)]) CreateIP = ManageProvider.UserHost;
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Session.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Log[日志]数据……");
|
||||
|
||||
// var entity = new Log();
|
||||
// entity.Category = "abc";
|
||||
// entity.Action = "abc";
|
||||
// entity.LinkID = 0;
|
||||
// entity.Success = true;
|
||||
// entity.UserName = "abc";
|
||||
// entity.Ex1 = 0;
|
||||
// entity.Ex2 = 0;
|
||||
// entity.Ex3 = 0.0;
|
||||
// entity.Ex4 = "abc";
|
||||
// entity.Ex5 = "abc";
|
||||
// entity.Ex6 = "abc";
|
||||
// entity.CreateUser = "abc";
|
||||
// entity.CreateUserID = 0;
|
||||
// entity.CreateIP = "abc";
|
||||
// entity.CreateTime = DateTime.Now;
|
||||
// entity.Remark = "abc";
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化Log[日志]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static Log FindByID(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
|
||||
|
||||
// 单对象缓存
|
||||
return Meta.SingleCache[id];
|
||||
|
||||
//return Find(_.ID == id);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
/// <summary>高级查询</summary>
|
||||
/// <param name="category">类别</param>
|
||||
/// <param name="action">操作</param>
|
||||
/// <param name="createUserId">创建用户</param>
|
||||
/// <param name="start">时间开始</param>
|
||||
/// <param name="end">时间结束</param>
|
||||
/// <param name="key">关键字</param>
|
||||
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Log> Search(String category, String action, Int32 createUserId, DateTime start, DateTime end, String key, PageParameter page)
|
||||
{
|
||||
var exp = new WhereExpression();
|
||||
|
||||
if (!category.IsNullOrEmpty()) exp &= _.Category == category;
|
||||
if (!action.IsNullOrEmpty()) exp &= _.Action == action;
|
||||
if (createUserId >= 0) exp &= _.CreateUserID == createUserId;
|
||||
exp &= _.CreateTime.Between(start, end);
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Category.Contains(key) | _.Action.Contains(key) | _.UserName.Contains(key) | _.Ex4.Contains(key) | _.Ex5.Contains(key) | _.Ex6.Contains(key) | _.CreateUser.Contains(key) | _.CreateIP.Contains(key) | _.Remark.Contains(key);
|
||||
|
||||
return FindAll(exp, page);
|
||||
}
|
||||
|
||||
// Select Count(ID) as ID,Action From Log Where CreateTime>'2020-01-24 00:00:00' Group By Action Order By ID Desc limit 20
|
||||
static readonly FieldCache<Log> _ActionCache = new FieldCache<Log>(nameof(Action))
|
||||
{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
};
|
||||
|
||||
/// <summary>获取操作列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
/// <returns></returns>
|
||||
public static IDictionary<String, String> GetActionList() => _ActionCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>日志</summary>
|
||||
[Serializable]
|
||||
[DataObject]
|
||||
[Description("日志")]
|
||||
[BindIndex("IX_Log_Action_Category_CreateTime", false, "Action,Category,CreateTime")]
|
||||
[BindIndex("IX_Log_CreateUserID_CreateTime", false, "CreateUserID,CreateTime")]
|
||||
[BindIndex("IX_Log_CreateTime", false, "CreateTime")]
|
||||
[BindTable("Log", Description = "日志", ConnName = "Log", DbType = DatabaseType.None)]
|
||||
public partial class Log
|
||||
{
|
||||
#region 属性
|
||||
private Int32 _ID;
|
||||
/// <summary>编号</summary>
|
||||
[DisplayName("编号")]
|
||||
[Description("编号")]
|
||||
[DataObjectField(true, true, false, 0)]
|
||||
[BindColumn("ID", "编号", "")]
|
||||
public Int32 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }
|
||||
|
||||
private String _Category;
|
||||
/// <summary>类别</summary>
|
||||
[DisplayName("类别")]
|
||||
[Description("类别")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Category", "类别", "")]
|
||||
public String Category { get => _Category; set { if (OnPropertyChanging("Category", value)) { _Category = value; OnPropertyChanged("Category"); } } }
|
||||
|
||||
private String _Action;
|
||||
/// <summary>操作</summary>
|
||||
[DisplayName("操作")]
|
||||
[Description("操作")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Action", "操作", "")]
|
||||
public String Action { get => _Action; set { if (OnPropertyChanging("Action", value)) { _Action = value; OnPropertyChanged("Action"); } } }
|
||||
|
||||
private Int32 _LinkID;
|
||||
/// <summary>链接</summary>
|
||||
[DisplayName("链接")]
|
||||
[Description("链接")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("LinkID", "链接", "")]
|
||||
public Int32 LinkID { get => _LinkID; set { if (OnPropertyChanging("LinkID", value)) { _LinkID = value; OnPropertyChanged("LinkID"); } } }
|
||||
|
||||
private Boolean _Success;
|
||||
/// <summary>成功</summary>
|
||||
[DisplayName("成功")]
|
||||
[Description("成功")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Success", "成功", "")]
|
||||
public Boolean Success { get => _Success; set { if (OnPropertyChanging("Success", value)) { _Success = value; OnPropertyChanged("Success"); } } }
|
||||
|
||||
private String _UserName;
|
||||
/// <summary>用户名</summary>
|
||||
[DisplayName("用户名")]
|
||||
[Description("用户名")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UserName", "用户名", "")]
|
||||
public String UserName { get => _UserName; set { if (OnPropertyChanging("UserName", value)) { _UserName = value; OnPropertyChanged("UserName"); } } }
|
||||
|
||||
private Int32 _Ex1;
|
||||
/// <summary>扩展1</summary>
|
||||
[DisplayName("扩展1")]
|
||||
[Description("扩展1")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex1", "扩展1", "")]
|
||||
public Int32 Ex1 { get => _Ex1; set { if (OnPropertyChanging("Ex1", value)) { _Ex1 = value; OnPropertyChanged("Ex1"); } } }
|
||||
|
||||
private Int32 _Ex2;
|
||||
/// <summary>扩展2</summary>
|
||||
[DisplayName("扩展2")]
|
||||
[Description("扩展2")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex2", "扩展2", "")]
|
||||
public Int32 Ex2 { get => _Ex2; set { if (OnPropertyChanging("Ex2", value)) { _Ex2 = value; OnPropertyChanged("Ex2"); } } }
|
||||
|
||||
private Double _Ex3;
|
||||
/// <summary>扩展3</summary>
|
||||
[DisplayName("扩展3")]
|
||||
[Description("扩展3")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex3", "扩展3", "")]
|
||||
public Double Ex3 { get => _Ex3; set { if (OnPropertyChanging("Ex3", value)) { _Ex3 = value; OnPropertyChanged("Ex3"); } } }
|
||||
|
||||
private String _Ex4;
|
||||
/// <summary>扩展4</summary>
|
||||
[DisplayName("扩展4")]
|
||||
[Description("扩展4")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex4", "扩展4", "")]
|
||||
public String Ex4 { get => _Ex4; set { if (OnPropertyChanging("Ex4", value)) { _Ex4 = value; OnPropertyChanged("Ex4"); } } }
|
||||
|
||||
private String _Ex5;
|
||||
/// <summary>扩展5</summary>
|
||||
[DisplayName("扩展5")]
|
||||
[Description("扩展5")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex5", "扩展5", "")]
|
||||
public String Ex5 { get => _Ex5; set { if (OnPropertyChanging("Ex5", value)) { _Ex5 = value; OnPropertyChanged("Ex5"); } } }
|
||||
|
||||
private String _Ex6;
|
||||
/// <summary>扩展6</summary>
|
||||
[DisplayName("扩展6")]
|
||||
[Description("扩展6")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex6", "扩展6", "")]
|
||||
public String Ex6 { get => _Ex6; set { if (OnPropertyChanging("Ex6", value)) { _Ex6 = value; OnPropertyChanged("Ex6"); } } }
|
||||
|
||||
private String _CreateUser;
|
||||
/// <summary>创建者</summary>
|
||||
[DisplayName("创建者")]
|
||||
[Description("创建者")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("CreateUser", "创建者", "")]
|
||||
public String CreateUser { get => _CreateUser; set { if (OnPropertyChanging("CreateUser", value)) { _CreateUser = value; OnPropertyChanged("CreateUser"); } } }
|
||||
|
||||
private Int32 _CreateUserID;
|
||||
/// <summary>创建用户</summary>
|
||||
[DisplayName("创建用户")]
|
||||
[Description("创建用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateUserID", "创建用户", "")]
|
||||
public Int32 CreateUserID { get => _CreateUserID; set { if (OnPropertyChanging("CreateUserID", value)) { _CreateUserID = value; OnPropertyChanged("CreateUserID"); } } }
|
||||
|
||||
private String _CreateIP;
|
||||
/// <summary>创建地址</summary>
|
||||
[DisplayName("创建地址")]
|
||||
[Description("创建地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("CreateIP", "创建地址", "")]
|
||||
public String CreateIP { get => _CreateIP; set { if (OnPropertyChanging("CreateIP", value)) { _CreateIP = value; OnPropertyChanged("CreateIP"); } } }
|
||||
|
||||
private DateTime _CreateTime;
|
||||
/// <summary>时间</summary>
|
||||
[DisplayName("时间")]
|
||||
[Description("时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateTime", "时间", "")]
|
||||
public DateTime CreateTime { get => _CreateTime; set { if (OnPropertyChanging("CreateTime", value)) { _CreateTime = value; OnPropertyChanged("CreateTime"); } } }
|
||||
|
||||
private String _Remark;
|
||||
/// <summary>详细信息</summary>
|
||||
[DisplayName("详细信息")]
|
||||
[Description("详细信息")]
|
||||
[DataObjectField(false, false, true, 500)]
|
||||
[BindColumn("Remark", "详细信息", "")]
|
||||
public String Remark { get => _Remark; set { if (OnPropertyChanging("Remark", value)) { _Remark = value; OnPropertyChanged("Remark"); } } }
|
||||
#endregion
|
||||
|
||||
#region 获取/设置 字段值
|
||||
/// <summary>获取/设置 字段值</summary>
|
||||
/// <param name="name">字段名</param>
|
||||
/// <returns></returns>
|
||||
public override Object this[String name]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": return _ID;
|
||||
case "Category": return _Category;
|
||||
case "Action": return _Action;
|
||||
case "LinkID": return _LinkID;
|
||||
case "Success": return _Success;
|
||||
case "UserName": return _UserName;
|
||||
case "Ex1": return _Ex1;
|
||||
case "Ex2": return _Ex2;
|
||||
case "Ex3": return _Ex3;
|
||||
case "Ex4": return _Ex4;
|
||||
case "Ex5": return _Ex5;
|
||||
case "Ex6": return _Ex6;
|
||||
case "CreateUser": return _CreateUser;
|
||||
case "CreateUserID": return _CreateUserID;
|
||||
case "CreateIP": return _CreateIP;
|
||||
case "CreateTime": return _CreateTime;
|
||||
case "Remark": return _Remark;
|
||||
default: return base[name];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": _ID = value.ToInt(); break;
|
||||
case "Category": _Category = Convert.ToString(value); break;
|
||||
case "Action": _Action = Convert.ToString(value); break;
|
||||
case "LinkID": _LinkID = value.ToInt(); break;
|
||||
case "Success": _Success = value.ToBoolean(); break;
|
||||
case "UserName": _UserName = Convert.ToString(value); break;
|
||||
case "Ex1": _Ex1 = value.ToInt(); break;
|
||||
case "Ex2": _Ex2 = value.ToInt(); break;
|
||||
case "Ex3": _Ex3 = value.ToDouble(); break;
|
||||
case "Ex4": _Ex4 = Convert.ToString(value); break;
|
||||
case "Ex5": _Ex5 = Convert.ToString(value); break;
|
||||
case "Ex6": _Ex6 = Convert.ToString(value); break;
|
||||
case "CreateUser": _CreateUser = Convert.ToString(value); break;
|
||||
case "CreateUserID": _CreateUserID = value.ToInt(); break;
|
||||
case "CreateIP": _CreateIP = Convert.ToString(value); break;
|
||||
case "CreateTime": _CreateTime = value.ToDateTime(); break;
|
||||
case "Remark": _Remark = Convert.ToString(value); break;
|
||||
default: base[name] = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字段名
|
||||
/// <summary>取得日志字段信息的快捷方式</summary>
|
||||
public partial class _
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public static readonly Field ID = FindByName("ID");
|
||||
|
||||
/// <summary>类别</summary>
|
||||
public static readonly Field Category = FindByName("Category");
|
||||
|
||||
/// <summary>操作</summary>
|
||||
public static readonly Field Action = FindByName("Action");
|
||||
|
||||
/// <summary>链接</summary>
|
||||
public static readonly Field LinkID = FindByName("LinkID");
|
||||
|
||||
/// <summary>成功</summary>
|
||||
public static readonly Field Success = FindByName("Success");
|
||||
|
||||
/// <summary>用户名</summary>
|
||||
public static readonly Field UserName = FindByName("UserName");
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public static readonly Field Ex1 = FindByName("Ex1");
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public static readonly Field Ex2 = FindByName("Ex2");
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public static readonly Field Ex3 = FindByName("Ex3");
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public static readonly Field Ex4 = FindByName("Ex4");
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public static readonly Field Ex5 = FindByName("Ex5");
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public static readonly Field Ex6 = FindByName("Ex6");
|
||||
|
||||
/// <summary>创建者</summary>
|
||||
public static readonly Field CreateUser = FindByName("CreateUser");
|
||||
|
||||
/// <summary>创建用户</summary>
|
||||
public static readonly Field CreateUserID = FindByName("CreateUserID");
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public static readonly Field CreateIP = FindByName("CreateIP");
|
||||
|
||||
/// <summary>时间</summary>
|
||||
public static readonly Field CreateTime = FindByName("CreateTime");
|
||||
|
||||
/// <summary>详细信息</summary>
|
||||
public static readonly Field Remark = FindByName("Remark");
|
||||
|
||||
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||
}
|
||||
|
||||
/// <summary>取得日志字段名称的快捷方式</summary>
|
||||
public partial class __
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public const String ID = "ID";
|
||||
|
||||
/// <summary>类别</summary>
|
||||
public const String Category = "Category";
|
||||
|
||||
/// <summary>操作</summary>
|
||||
public const String Action = "Action";
|
||||
|
||||
/// <summary>链接</summary>
|
||||
public const String LinkID = "LinkID";
|
||||
|
||||
/// <summary>成功</summary>
|
||||
public const String Success = "Success";
|
||||
|
||||
/// <summary>用户名</summary>
|
||||
public const String UserName = "UserName";
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public const String Ex1 = "Ex1";
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public const String Ex2 = "Ex2";
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public const String Ex3 = "Ex3";
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public const String Ex4 = "Ex4";
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public const String Ex5 = "Ex5";
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public const String Ex6 = "Ex6";
|
||||
|
||||
/// <summary>创建者</summary>
|
||||
public const String CreateUser = "CreateUser";
|
||||
|
||||
/// <summary>创建用户</summary>
|
||||
public const String CreateUserID = "CreateUserID";
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public const String CreateIP = "CreateIP";
|
||||
|
||||
/// <summary>时间</summary>
|
||||
public const String CreateTime = "CreateTime";
|
||||
|
||||
/// <summary>详细信息</summary>
|
||||
public const String Remark = "Remark";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>用户</summary>
|
||||
public partial class User : Entity<User>
|
||||
{
|
||||
#region 对象操作
|
||||
static User()
|
||||
{
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(nameof(Sex));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<UserModule>();
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Modules.Add<IPModule>();
|
||||
|
||||
// 单对象缓存
|
||||
var sc = Meta.SingleCache;
|
||||
sc.FindSlaveKeyMethod = k => Find(_.Name == k);
|
||||
sc.GetSlaveKeyMethod = e => e.Name;
|
||||
}
|
||||
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 这里验证参数范围,建议抛出参数异常,指定参数名,前端用户界面可以捕获参数异常并聚焦到对应的参数输入框
|
||||
if (Name.IsNullOrEmpty()) throw new ArgumentNullException(nameof(Name), "名称不能为空!");
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 处理当前已登录用户信息,可以由UserModule过滤器代劳
|
||||
/*var user = ManageProvider.User;
|
||||
if (user != null)
|
||||
{
|
||||
if (!Dirtys[nameof(UpdateUserID)]) UpdateUserID = user.ID;
|
||||
}*/
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
//if (!Dirtys[nameof(UpdateIP)]) UpdateIP = ManageProvider.UserHost;
|
||||
|
||||
// 检查唯一索引
|
||||
// CheckExist(isNew, nameof(Name));
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Session.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化User[用户]数据……");
|
||||
|
||||
// var entity = new User();
|
||||
// entity.Name = "abc";
|
||||
// entity.Password = "abc";
|
||||
// entity.DisplayName = "abc";
|
||||
// entity.Sex = 0;
|
||||
// entity.Mail = "abc";
|
||||
// entity.Mobile = "abc";
|
||||
// entity.Code = "abc";
|
||||
// entity.Avatar = "abc";
|
||||
// entity.RoleID = 0;
|
||||
// entity.RoleIDs = "abc";
|
||||
// entity.DepartmentID = 0;
|
||||
// entity.Online = true;
|
||||
// entity.Enable = true;
|
||||
// entity.Logins = 0;
|
||||
// entity.LastLogin = DateTime.Now;
|
||||
// entity.LastLoginIP = "abc";
|
||||
// entity.RegisterTime = DateTime.Now;
|
||||
// entity.RegisterIP = "abc";
|
||||
// entity.Ex1 = 0;
|
||||
// entity.Ex2 = 0;
|
||||
// entity.Ex3 = 0.0;
|
||||
// entity.Ex4 = "abc";
|
||||
// entity.Ex5 = "abc";
|
||||
// entity.Ex6 = "abc";
|
||||
// entity.UpdateUser = "abc";
|
||||
// entity.UpdateUserID = 0;
|
||||
// entity.UpdateIP = "abc";
|
||||
// entity.UpdateTime = DateTime.Now;
|
||||
// entity.Remark = "abc";
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化User[用户]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>角色</summary>
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Role Role => Extends.Get(nameof(Role), k => Role.FindByID(RoleID));
|
||||
|
||||
/// <summary>角色</summary>
|
||||
[Map(nameof(RoleID), typeof(Role), "ID")]
|
||||
public String RoleName => Role?.Name;
|
||||
|
||||
/// <summary>部门</summary>
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Department Department => Extends.Get(nameof(Department), k => Department.FindByID(DepartmentID));
|
||||
|
||||
/// <summary>部门</summary>
|
||||
[Map(nameof(DepartmentID), typeof(Department), "ID")]
|
||||
public String DepartmentName => Department?.Name;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static User FindByID(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
|
||||
|
||||
// 单对象缓存
|
||||
return Meta.SingleCache[id];
|
||||
|
||||
//return Find(_.ID == id);
|
||||
}
|
||||
|
||||
/// <summary>根据名称查找</summary>
|
||||
/// <param name="name">名称</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static User FindByName(String name)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
|
||||
|
||||
// 单对象缓存
|
||||
//return Meta.SingleCache.GetItemWithSlaveKey(name) as User;
|
||||
|
||||
return Find(_.Name == name);
|
||||
}
|
||||
|
||||
/// <summary>根据角色查找</summary>
|
||||
/// <param name="roleId">角色</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<User> FindAllByRoleID(Int32 roleId)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.RoleID == roleId);
|
||||
|
||||
return FindAll(_.RoleID == roleId);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
/// <summary>高级查询</summary>
|
||||
/// <param name="name">名称。登录用户名</param>
|
||||
/// <param name="roleId">角色。主要角色</param>
|
||||
/// <param name="start">更新时间开始</param>
|
||||
/// <param name="end">更新时间结束</param>
|
||||
/// <param name="key">关键字</param>
|
||||
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<User> Search(String name, Int32 roleId, DateTime start, DateTime end, String key, PageParameter page)
|
||||
{
|
||||
var exp = new WhereExpression();
|
||||
|
||||
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
|
||||
if (roleId >= 0) exp &= _.RoleID == roleId;
|
||||
exp &= _.UpdateTime.Between(start, end);
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.Password.Contains(key) | _.DisplayName.Contains(key) | _.Mail.Contains(key) | _.Mobile.Contains(key) | _.Code.Contains(key) | _.Avatar.Contains(key) | _.RoleIDs.Contains(key) | _.LastLoginIP.Contains(key) | _.RegisterIP.Contains(key) | _.Ex4.Contains(key) | _.Ex5.Contains(key) | _.Ex6.Contains(key) | _.UpdateUser.Contains(key) | _.UpdateIP.Contains(key) | _.Remark.Contains(key);
|
||||
|
||||
return FindAll(exp, page);
|
||||
}
|
||||
|
||||
// Select Count(ID) as ID,Category From User Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By ID Desc limit 20
|
||||
//static readonly FieldCache<User> _CategoryCache = new FieldCache<User>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,541 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>用户</summary>
|
||||
[Serializable]
|
||||
[DataObject]
|
||||
[Description("用户")]
|
||||
[BindIndex("IU_User_Name", true, "Name")]
|
||||
[BindIndex("IX_User_RoleID", false, "RoleID")]
|
||||
[BindIndex("IX_User_UpdateTime", false, "UpdateTime")]
|
||||
[BindTable("User", Description = "用户", ConnName = "Membership", DbType = DatabaseType.None)]
|
||||
public partial class User
|
||||
{
|
||||
#region 属性
|
||||
private Int32 _ID;
|
||||
/// <summary>编号</summary>
|
||||
[DisplayName("编号")]
|
||||
[Description("编号")]
|
||||
[DataObjectField(true, true, false, 0)]
|
||||
[BindColumn("ID", "编号", "")]
|
||||
public Int32 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }
|
||||
|
||||
private String _Name;
|
||||
/// <summary>名称。登录用户名</summary>
|
||||
[DisplayName("名称")]
|
||||
[Description("名称。登录用户名")]
|
||||
[DataObjectField(false, false, false, 50)]
|
||||
[BindColumn("Name", "名称。登录用户名", "", Master = true)]
|
||||
public String Name { get => _Name; set { if (OnPropertyChanging("Name", value)) { _Name = value; OnPropertyChanged("Name"); } } }
|
||||
|
||||
private String _Password;
|
||||
/// <summary>密码</summary>
|
||||
[DisplayName("密码")]
|
||||
[Description("密码")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Password", "密码", "")]
|
||||
public String Password { get => _Password; set { if (OnPropertyChanging("Password", value)) { _Password = value; OnPropertyChanged("Password"); } } }
|
||||
|
||||
private String _DisplayName;
|
||||
/// <summary>昵称</summary>
|
||||
[DisplayName("昵称")]
|
||||
[Description("昵称")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("DisplayName", "昵称", "")]
|
||||
public String DisplayName { get => _DisplayName; set { if (OnPropertyChanging("DisplayName", value)) { _DisplayName = value; OnPropertyChanged("DisplayName"); } } }
|
||||
|
||||
private SexKinds _Sex;
|
||||
/// <summary>性别。未知、男、女</summary>
|
||||
[DisplayName("性别")]
|
||||
[Description("性别。未知、男、女")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Sex", "性别。未知、男、女", "")]
|
||||
public SexKinds Sex { get => _Sex; set { if (OnPropertyChanging("Sex", value)) { _Sex = value; OnPropertyChanged("Sex"); } } }
|
||||
|
||||
private String _Mail;
|
||||
/// <summary>邮件</summary>
|
||||
[DisplayName("邮件")]
|
||||
[Description("邮件")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Mail", "邮件", "", ItemType = "mail")]
|
||||
public String Mail { get => _Mail; set { if (OnPropertyChanging("Mail", value)) { _Mail = value; OnPropertyChanged("Mail"); } } }
|
||||
|
||||
private String _Mobile;
|
||||
/// <summary>手机</summary>
|
||||
[DisplayName("手机")]
|
||||
[Description("手机")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Mobile", "手机", "", ItemType = "mobile")]
|
||||
public String Mobile { get => _Mobile; set { if (OnPropertyChanging("Mobile", value)) { _Mobile = value; OnPropertyChanged("Mobile"); } } }
|
||||
|
||||
private String _Code;
|
||||
/// <summary>代码。身份证、员工编号等</summary>
|
||||
[DisplayName("代码")]
|
||||
[Description("代码。身份证、员工编号等")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Code", "代码。身份证、员工编号等", "")]
|
||||
public String Code { get => _Code; set { if (OnPropertyChanging("Code", value)) { _Code = value; OnPropertyChanged("Code"); } } }
|
||||
|
||||
private String _Avatar;
|
||||
/// <summary>头像</summary>
|
||||
[DisplayName("头像")]
|
||||
[Description("头像")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("Avatar", "头像", "", ItemType = "image")]
|
||||
public String Avatar { get => _Avatar; set { if (OnPropertyChanging("Avatar", value)) { _Avatar = value; OnPropertyChanged("Avatar"); } } }
|
||||
|
||||
private Int32 _RoleID;
|
||||
/// <summary>角色。主要角色</summary>
|
||||
[DisplayName("角色")]
|
||||
[Description("角色。主要角色")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("RoleID", "角色。主要角色", "")]
|
||||
public Int32 RoleID { get => _RoleID; set { if (OnPropertyChanging("RoleID", value)) { _RoleID = value; OnPropertyChanged("RoleID"); } } }
|
||||
|
||||
private String _RoleIDs;
|
||||
/// <summary>角色组。次要角色集合</summary>
|
||||
[DisplayName("角色组")]
|
||||
[Description("角色组。次要角色集合")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("RoleIDs", "角色组。次要角色集合", "")]
|
||||
public String RoleIDs { get => _RoleIDs; set { if (OnPropertyChanging("RoleIDs", value)) { _RoleIDs = value; OnPropertyChanged("RoleIDs"); } } }
|
||||
|
||||
private Int32 _DepartmentID;
|
||||
/// <summary>部门。组织机构</summary>
|
||||
[DisplayName("部门")]
|
||||
[Description("部门。组织机构")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("DepartmentID", "部门。组织机构", "")]
|
||||
public Int32 DepartmentID { get => _DepartmentID; set { if (OnPropertyChanging("DepartmentID", value)) { _DepartmentID = value; OnPropertyChanged("DepartmentID"); } } }
|
||||
|
||||
private Boolean _Online;
|
||||
/// <summary>在线</summary>
|
||||
[DisplayName("在线")]
|
||||
[Description("在线")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Online", "在线", "")]
|
||||
public Boolean Online { get => _Online; set { if (OnPropertyChanging("Online", value)) { _Online = value; OnPropertyChanged("Online"); } } }
|
||||
|
||||
private Boolean _Enable;
|
||||
/// <summary>启用</summary>
|
||||
[DisplayName("启用")]
|
||||
[Description("启用")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Enable", "启用", "")]
|
||||
public Boolean Enable { get => _Enable; set { if (OnPropertyChanging("Enable", value)) { _Enable = value; OnPropertyChanged("Enable"); } } }
|
||||
|
||||
private Int32 _Logins;
|
||||
/// <summary>登录次数</summary>
|
||||
[DisplayName("登录次数")]
|
||||
[Description("登录次数")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Logins", "登录次数", "")]
|
||||
public Int32 Logins { get => _Logins; set { if (OnPropertyChanging("Logins", value)) { _Logins = value; OnPropertyChanged("Logins"); } } }
|
||||
|
||||
private DateTime _LastLogin;
|
||||
/// <summary>最后登录</summary>
|
||||
[DisplayName("最后登录")]
|
||||
[Description("最后登录")]
|
||||
[DataObjectField(false, false, true, 0)]
|
||||
[BindColumn("LastLogin", "最后登录", "")]
|
||||
public DateTime LastLogin { get => _LastLogin; set { if (OnPropertyChanging("LastLogin", value)) { _LastLogin = value; OnPropertyChanged("LastLogin"); } } }
|
||||
|
||||
private String _LastLoginIP;
|
||||
/// <summary>最后登录IP</summary>
|
||||
[DisplayName("最后登录IP")]
|
||||
[Description("最后登录IP")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("LastLoginIP", "最后登录IP", "")]
|
||||
public String LastLoginIP { get => _LastLoginIP; set { if (OnPropertyChanging("LastLoginIP", value)) { _LastLoginIP = value; OnPropertyChanged("LastLoginIP"); } } }
|
||||
|
||||
private DateTime _RegisterTime;
|
||||
/// <summary>注册时间</summary>
|
||||
[DisplayName("注册时间")]
|
||||
[Description("注册时间")]
|
||||
[DataObjectField(false, false, true, 0)]
|
||||
[BindColumn("RegisterTime", "注册时间", "")]
|
||||
public DateTime RegisterTime { get => _RegisterTime; set { if (OnPropertyChanging("RegisterTime", value)) { _RegisterTime = value; OnPropertyChanged("RegisterTime"); } } }
|
||||
|
||||
private String _RegisterIP;
|
||||
/// <summary>注册IP</summary>
|
||||
[DisplayName("注册IP")]
|
||||
[Description("注册IP")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("RegisterIP", "注册IP", "")]
|
||||
public String RegisterIP { get => _RegisterIP; set { if (OnPropertyChanging("RegisterIP", value)) { _RegisterIP = value; OnPropertyChanged("RegisterIP"); } } }
|
||||
|
||||
private Int32 _Ex1;
|
||||
/// <summary>扩展1</summary>
|
||||
[DisplayName("扩展1")]
|
||||
[Description("扩展1")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex1", "扩展1", "")]
|
||||
public Int32 Ex1 { get => _Ex1; set { if (OnPropertyChanging("Ex1", value)) { _Ex1 = value; OnPropertyChanged("Ex1"); } } }
|
||||
|
||||
private Int32 _Ex2;
|
||||
/// <summary>扩展2</summary>
|
||||
[DisplayName("扩展2")]
|
||||
[Description("扩展2")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex2", "扩展2", "")]
|
||||
public Int32 Ex2 { get => _Ex2; set { if (OnPropertyChanging("Ex2", value)) { _Ex2 = value; OnPropertyChanged("Ex2"); } } }
|
||||
|
||||
private Double _Ex3;
|
||||
/// <summary>扩展3</summary>
|
||||
[DisplayName("扩展3")]
|
||||
[Description("扩展3")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex3", "扩展3", "")]
|
||||
public Double Ex3 { get => _Ex3; set { if (OnPropertyChanging("Ex3", value)) { _Ex3 = value; OnPropertyChanged("Ex3"); } } }
|
||||
|
||||
private String _Ex4;
|
||||
/// <summary>扩展4</summary>
|
||||
[DisplayName("扩展4")]
|
||||
[Description("扩展4")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex4", "扩展4", "")]
|
||||
public String Ex4 { get => _Ex4; set { if (OnPropertyChanging("Ex4", value)) { _Ex4 = value; OnPropertyChanged("Ex4"); } } }
|
||||
|
||||
private String _Ex5;
|
||||
/// <summary>扩展5</summary>
|
||||
[DisplayName("扩展5")]
|
||||
[Description("扩展5")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex5", "扩展5", "")]
|
||||
public String Ex5 { get => _Ex5; set { if (OnPropertyChanging("Ex5", value)) { _Ex5 = value; OnPropertyChanged("Ex5"); } } }
|
||||
|
||||
private String _Ex6;
|
||||
/// <summary>扩展6</summary>
|
||||
[XmlIgnore, ScriptIgnore, IgnoreDataMember]
|
||||
[DisplayName("扩展6")]
|
||||
[Description("扩展6")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex6", "扩展6", "")]
|
||||
public String Ex6 { get => _Ex6; set { if (OnPropertyChanging("Ex6", value)) { _Ex6 = value; OnPropertyChanged("Ex6"); } } }
|
||||
|
||||
private String _UpdateUser;
|
||||
/// <summary>更新者</summary>
|
||||
[DisplayName("更新者")]
|
||||
[Description("更新者")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateUser", "更新者", "")]
|
||||
public String UpdateUser { get => _UpdateUser; set { if (OnPropertyChanging("UpdateUser", value)) { _UpdateUser = value; OnPropertyChanged("UpdateUser"); } } }
|
||||
|
||||
private Int32 _UpdateUserID;
|
||||
/// <summary>更新用户</summary>
|
||||
[DisplayName("更新用户")]
|
||||
[Description("更新用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateUserID", "更新用户", "")]
|
||||
public Int32 UpdateUserID { get => _UpdateUserID; set { if (OnPropertyChanging("UpdateUserID", value)) { _UpdateUserID = value; OnPropertyChanged("UpdateUserID"); } } }
|
||||
|
||||
private String _UpdateIP;
|
||||
/// <summary>更新地址</summary>
|
||||
[DisplayName("更新地址")]
|
||||
[Description("更新地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateIP", "更新地址", "")]
|
||||
public String UpdateIP { get => _UpdateIP; set { if (OnPropertyChanging("UpdateIP", value)) { _UpdateIP = value; OnPropertyChanged("UpdateIP"); } } }
|
||||
|
||||
private DateTime _UpdateTime;
|
||||
/// <summary>更新时间</summary>
|
||||
[DisplayName("更新时间")]
|
||||
[Description("更新时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateTime", "更新时间", "")]
|
||||
public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }
|
||||
|
||||
private String _Remark;
|
||||
/// <summary>备注</summary>
|
||||
[DisplayName("备注")]
|
||||
[Description("备注")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("Remark", "备注", "")]
|
||||
public String Remark { get => _Remark; set { if (OnPropertyChanging("Remark", value)) { _Remark = value; OnPropertyChanged("Remark"); } } }
|
||||
#endregion
|
||||
|
||||
#region 获取/设置 字段值
|
||||
/// <summary>获取/设置 字段值</summary>
|
||||
/// <param name="name">字段名</param>
|
||||
/// <returns></returns>
|
||||
public override Object this[String name]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": return _ID;
|
||||
case "Name": return _Name;
|
||||
case "Password": return _Password;
|
||||
case "DisplayName": return _DisplayName;
|
||||
case "Sex": return _Sex;
|
||||
case "Mail": return _Mail;
|
||||
case "Mobile": return _Mobile;
|
||||
case "Code": return _Code;
|
||||
case "Avatar": return _Avatar;
|
||||
case "RoleID": return _RoleID;
|
||||
case "RoleIDs": return _RoleIDs;
|
||||
case "DepartmentID": return _DepartmentID;
|
||||
case "Online": return _Online;
|
||||
case "Enable": return _Enable;
|
||||
case "Logins": return _Logins;
|
||||
case "LastLogin": return _LastLogin;
|
||||
case "LastLoginIP": return _LastLoginIP;
|
||||
case "RegisterTime": return _RegisterTime;
|
||||
case "RegisterIP": return _RegisterIP;
|
||||
case "Ex1": return _Ex1;
|
||||
case "Ex2": return _Ex2;
|
||||
case "Ex3": return _Ex3;
|
||||
case "Ex4": return _Ex4;
|
||||
case "Ex5": return _Ex5;
|
||||
case "Ex6": return _Ex6;
|
||||
case "UpdateUser": return _UpdateUser;
|
||||
case "UpdateUserID": return _UpdateUserID;
|
||||
case "UpdateIP": return _UpdateIP;
|
||||
case "UpdateTime": return _UpdateTime;
|
||||
case "Remark": return _Remark;
|
||||
default: return base[name];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": _ID = value.ToInt(); break;
|
||||
case "Name": _Name = Convert.ToString(value); break;
|
||||
case "Password": _Password = Convert.ToString(value); break;
|
||||
case "DisplayName": _DisplayName = Convert.ToString(value); break;
|
||||
case "Sex": _Sex = (SexKinds)value.ToInt(); break;
|
||||
case "Mail": _Mail = Convert.ToString(value); break;
|
||||
case "Mobile": _Mobile = Convert.ToString(value); break;
|
||||
case "Code": _Code = Convert.ToString(value); break;
|
||||
case "Avatar": _Avatar = Convert.ToString(value); break;
|
||||
case "RoleID": _RoleID = value.ToInt(); break;
|
||||
case "RoleIDs": _RoleIDs = Convert.ToString(value); break;
|
||||
case "DepartmentID": _DepartmentID = value.ToInt(); break;
|
||||
case "Online": _Online = value.ToBoolean(); break;
|
||||
case "Enable": _Enable = value.ToBoolean(); break;
|
||||
case "Logins": _Logins = value.ToInt(); break;
|
||||
case "LastLogin": _LastLogin = value.ToDateTime(); break;
|
||||
case "LastLoginIP": _LastLoginIP = Convert.ToString(value); break;
|
||||
case "RegisterTime": _RegisterTime = value.ToDateTime(); break;
|
||||
case "RegisterIP": _RegisterIP = Convert.ToString(value); break;
|
||||
case "Ex1": _Ex1 = value.ToInt(); break;
|
||||
case "Ex2": _Ex2 = value.ToInt(); break;
|
||||
case "Ex3": _Ex3 = value.ToDouble(); break;
|
||||
case "Ex4": _Ex4 = Convert.ToString(value); break;
|
||||
case "Ex5": _Ex5 = Convert.ToString(value); break;
|
||||
case "Ex6": _Ex6 = Convert.ToString(value); break;
|
||||
case "UpdateUser": _UpdateUser = Convert.ToString(value); break;
|
||||
case "UpdateUserID": _UpdateUserID = value.ToInt(); break;
|
||||
case "UpdateIP": _UpdateIP = Convert.ToString(value); break;
|
||||
case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
|
||||
case "Remark": _Remark = Convert.ToString(value); break;
|
||||
default: base[name] = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字段名
|
||||
/// <summary>取得用户字段信息的快捷方式</summary>
|
||||
public partial class _
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public static readonly Field ID = FindByName("ID");
|
||||
|
||||
/// <summary>名称。登录用户名</summary>
|
||||
public static readonly Field Name = FindByName("Name");
|
||||
|
||||
/// <summary>密码</summary>
|
||||
public static readonly Field Password = FindByName("Password");
|
||||
|
||||
/// <summary>昵称</summary>
|
||||
public static readonly Field DisplayName = FindByName("DisplayName");
|
||||
|
||||
/// <summary>性别。未知、男、女</summary>
|
||||
public static readonly Field Sex = FindByName("Sex");
|
||||
|
||||
/// <summary>邮件</summary>
|
||||
public static readonly Field Mail = FindByName("Mail");
|
||||
|
||||
/// <summary>手机</summary>
|
||||
public static readonly Field Mobile = FindByName("Mobile");
|
||||
|
||||
/// <summary>代码。身份证、员工编号等</summary>
|
||||
public static readonly Field Code = FindByName("Code");
|
||||
|
||||
/// <summary>头像</summary>
|
||||
public static readonly Field Avatar = FindByName("Avatar");
|
||||
|
||||
/// <summary>角色。主要角色</summary>
|
||||
public static readonly Field RoleID = FindByName("RoleID");
|
||||
|
||||
/// <summary>角色组。次要角色集合</summary>
|
||||
public static readonly Field RoleIDs = FindByName("RoleIDs");
|
||||
|
||||
/// <summary>部门。组织机构</summary>
|
||||
public static readonly Field DepartmentID = FindByName("DepartmentID");
|
||||
|
||||
/// <summary>在线</summary>
|
||||
public static readonly Field Online = FindByName("Online");
|
||||
|
||||
/// <summary>启用</summary>
|
||||
public static readonly Field Enable = FindByName("Enable");
|
||||
|
||||
/// <summary>登录次数</summary>
|
||||
public static readonly Field Logins = FindByName("Logins");
|
||||
|
||||
/// <summary>最后登录</summary>
|
||||
public static readonly Field LastLogin = FindByName("LastLogin");
|
||||
|
||||
/// <summary>最后登录IP</summary>
|
||||
public static readonly Field LastLoginIP = FindByName("LastLoginIP");
|
||||
|
||||
/// <summary>注册时间</summary>
|
||||
public static readonly Field RegisterTime = FindByName("RegisterTime");
|
||||
|
||||
/// <summary>注册IP</summary>
|
||||
public static readonly Field RegisterIP = FindByName("RegisterIP");
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public static readonly Field Ex1 = FindByName("Ex1");
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public static readonly Field Ex2 = FindByName("Ex2");
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public static readonly Field Ex3 = FindByName("Ex3");
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public static readonly Field Ex4 = FindByName("Ex4");
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public static readonly Field Ex5 = FindByName("Ex5");
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public static readonly Field Ex6 = FindByName("Ex6");
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public static readonly Field UpdateUser = FindByName("UpdateUser");
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public static readonly Field UpdateUserID = FindByName("UpdateUserID");
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public static readonly Field UpdateIP = FindByName("UpdateIP");
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public static readonly Field UpdateTime = FindByName("UpdateTime");
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public static readonly Field Remark = FindByName("Remark");
|
||||
|
||||
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||
}
|
||||
|
||||
/// <summary>取得用户字段名称的快捷方式</summary>
|
||||
public partial class __
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public const String ID = "ID";
|
||||
|
||||
/// <summary>名称。登录用户名</summary>
|
||||
public const String Name = "Name";
|
||||
|
||||
/// <summary>密码</summary>
|
||||
public const String Password = "Password";
|
||||
|
||||
/// <summary>昵称</summary>
|
||||
public const String DisplayName = "DisplayName";
|
||||
|
||||
/// <summary>性别。未知、男、女</summary>
|
||||
public const String Sex = "Sex";
|
||||
|
||||
/// <summary>邮件</summary>
|
||||
public const String Mail = "Mail";
|
||||
|
||||
/// <summary>手机</summary>
|
||||
public const String Mobile = "Mobile";
|
||||
|
||||
/// <summary>代码。身份证、员工编号等</summary>
|
||||
public const String Code = "Code";
|
||||
|
||||
/// <summary>头像</summary>
|
||||
public const String Avatar = "Avatar";
|
||||
|
||||
/// <summary>角色。主要角色</summary>
|
||||
public const String RoleID = "RoleID";
|
||||
|
||||
/// <summary>角色组。次要角色集合</summary>
|
||||
public const String RoleIDs = "RoleIDs";
|
||||
|
||||
/// <summary>部门。组织机构</summary>
|
||||
public const String DepartmentID = "DepartmentID";
|
||||
|
||||
/// <summary>在线</summary>
|
||||
public const String Online = "Online";
|
||||
|
||||
/// <summary>启用</summary>
|
||||
public const String Enable = "Enable";
|
||||
|
||||
/// <summary>登录次数</summary>
|
||||
public const String Logins = "Logins";
|
||||
|
||||
/// <summary>最后登录</summary>
|
||||
public const String LastLogin = "LastLogin";
|
||||
|
||||
/// <summary>最后登录IP</summary>
|
||||
public const String LastLoginIP = "LastLoginIP";
|
||||
|
||||
/// <summary>注册时间</summary>
|
||||
public const String RegisterTime = "RegisterTime";
|
||||
|
||||
/// <summary>注册IP</summary>
|
||||
public const String RegisterIP = "RegisterIP";
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public const String Ex1 = "Ex1";
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public const String Ex2 = "Ex2";
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public const String Ex3 = "Ex3";
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public const String Ex4 = "Ex4";
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public const String Ex5 = "Ex5";
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public const String Ex6 = "Ex6";
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public const String UpdateUser = "UpdateUser";
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public const String UpdateUserID = "UpdateUserID";
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public const String UpdateIP = "UpdateIP";
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public const String UpdateTime = "UpdateTime";
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public const String Remark = "Remark";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>用户在线</summary>
|
||||
public partial class UserOnline : Entity<UserOnline>
|
||||
{
|
||||
#region 对象操作
|
||||
static UserOnline()
|
||||
{
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(nameof(UserID));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Modules.Add<IPModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
//if (isNew && !Dirtys[nameof(CreateTime)]) CreateTime = DateTime.Now;
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
//if (isNew && !Dirtys[nameof(CreateIP)]) CreateIP = ManageProvider.UserHost;
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Session.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化UserOnline[用户在线]数据……");
|
||||
|
||||
// var entity = new UserOnline();
|
||||
// entity.UserID = 0;
|
||||
// entity.Name = "abc";
|
||||
// entity.SessionID = "abc";
|
||||
// entity.Times = 0;
|
||||
// entity.Page = "abc";
|
||||
// entity.Status = "abc";
|
||||
// entity.OnlineTime = 0;
|
||||
// entity.CreateIP = "abc";
|
||||
// entity.CreateTime = DateTime.Now;
|
||||
// entity.UpdateTime = DateTime.Now;
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化UserOnline[用户在线]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>用户</summary>
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public User User => Extends.Get(nameof(User), k => User.FindByID(UserID));
|
||||
|
||||
/// <summary>用户</summary>
|
||||
[Map(nameof(UserID), typeof(User), "ID")]
|
||||
public String UserName => User?.Name;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static UserOnline FindByID(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
|
||||
|
||||
// 单对象缓存
|
||||
return Meta.SingleCache[id];
|
||||
|
||||
//return Find(_.ID == id);
|
||||
}
|
||||
|
||||
/// <summary>根据用户查找</summary>
|
||||
/// <param name="userId">用户</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<UserOnline> FindAllByUserID(Int32 userId)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.UserID == userId);
|
||||
|
||||
return FindAll(_.UserID == userId);
|
||||
}
|
||||
|
||||
/// <summary>根据会话查找</summary>
|
||||
/// <param name="sessionId">会话</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<UserOnline> FindAllBySessionID(String sessionId)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.SessionID.EqualIgnoreCase(sessionId));
|
||||
|
||||
return FindAll(_.SessionID == sessionId);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
/// <summary>高级查询</summary>
|
||||
/// <param name="userId">用户</param>
|
||||
/// <param name="sessionId">会话。Web的SessionID或Server的会话编号</param>
|
||||
/// <param name="start">创建时间开始</param>
|
||||
/// <param name="end">创建时间结束</param>
|
||||
/// <param name="key">关键字</param>
|
||||
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<UserOnline> Search(Int32 userId, String sessionId, DateTime start, DateTime end, String key, PageParameter page)
|
||||
{
|
||||
var exp = new WhereExpression();
|
||||
|
||||
if (userId >= 0) exp &= _.UserID == userId;
|
||||
if (!sessionId.IsNullOrEmpty()) exp &= _.SessionID == sessionId;
|
||||
exp &= _.CreateTime.Between(start, end);
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.SessionID.Contains(key) | _.Page.Contains(key) | _.Status.Contains(key) | _.CreateIP.Contains(key);
|
||||
|
||||
return FindAll(exp, page);
|
||||
}
|
||||
|
||||
// Select Count(ID) as ID,SessionID From UserOnline Where CreateTime>'2020-01-24 00:00:00' Group By SessionID Order By ID Desc limit 20
|
||||
static readonly FieldCache<UserOnline> _SessionIDCache = new FieldCache<UserOnline>(nameof(SessionID))
|
||||
{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
};
|
||||
|
||||
/// <summary>获取会话列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
/// <returns></returns>
|
||||
public static IDictionary<String, String> GetSessionIDList() => _SessionIDCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>用户在线</summary>
|
||||
[Serializable]
|
||||
[DataObject]
|
||||
[Description("用户在线")]
|
||||
[BindIndex("IX_UserOnline_UserID", false, "UserID")]
|
||||
[BindIndex("IX_UserOnline_SessionID", false, "SessionID")]
|
||||
[BindIndex("IX_UserOnline_CreateTime", false, "CreateTime")]
|
||||
[BindTable("UserOnline", Description = "用户在线", ConnName = "Log", DbType = DatabaseType.None)]
|
||||
public partial class UserOnline
|
||||
{
|
||||
#region 属性
|
||||
private Int32 _ID;
|
||||
/// <summary>编号</summary>
|
||||
[DisplayName("编号")]
|
||||
[Description("编号")]
|
||||
[DataObjectField(true, true, false, 0)]
|
||||
[BindColumn("ID", "编号", "")]
|
||||
public Int32 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }
|
||||
|
||||
private Int32 _UserID;
|
||||
/// <summary>用户</summary>
|
||||
[DisplayName("用户")]
|
||||
[Description("用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UserID", "用户", "")]
|
||||
public Int32 UserID { get => _UserID; set { if (OnPropertyChanging("UserID", value)) { _UserID = value; OnPropertyChanged("UserID"); } } }
|
||||
|
||||
private String _Name;
|
||||
/// <summary>名称</summary>
|
||||
[DisplayName("名称")]
|
||||
[Description("名称")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Name", "名称", "", Master = true)]
|
||||
public String Name { get => _Name; set { if (OnPropertyChanging("Name", value)) { _Name = value; OnPropertyChanged("Name"); } } }
|
||||
|
||||
private String _SessionID;
|
||||
/// <summary>会话。Web的SessionID或Server的会话编号</summary>
|
||||
[DisplayName("会话")]
|
||||
[Description("会话。Web的SessionID或Server的会话编号")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("SessionID", "会话。Web的SessionID或Server的会话编号", "")]
|
||||
public String SessionID { get => _SessionID; set { if (OnPropertyChanging("SessionID", value)) { _SessionID = value; OnPropertyChanged("SessionID"); } } }
|
||||
|
||||
private Int32 _Times;
|
||||
/// <summary>次数</summary>
|
||||
[DisplayName("次数")]
|
||||
[Description("次数")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Times", "次数", "")]
|
||||
public Int32 Times { get => _Times; set { if (OnPropertyChanging("Times", value)) { _Times = value; OnPropertyChanged("Times"); } } }
|
||||
|
||||
private String _Page;
|
||||
/// <summary>页面</summary>
|
||||
[DisplayName("页面")]
|
||||
[Description("页面")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Page", "页面", "")]
|
||||
public String Page { get => _Page; set { if (OnPropertyChanging("Page", value)) { _Page = value; OnPropertyChanged("Page"); } } }
|
||||
|
||||
private String _Status;
|
||||
/// <summary>状态</summary>
|
||||
[DisplayName("状态")]
|
||||
[Description("状态")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("Status", "状态", "")]
|
||||
public String Status { get => _Status; set { if (OnPropertyChanging("Status", value)) { _Status = value; OnPropertyChanged("Status"); } } }
|
||||
|
||||
private Int32 _OnlineTime;
|
||||
/// <summary>在线时间。本次在线总时间,秒</summary>
|
||||
[DisplayName("在线时间")]
|
||||
[Description("在线时间。本次在线总时间,秒")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("OnlineTime", "在线时间。本次在线总时间,秒", "")]
|
||||
public Int32 OnlineTime { get => _OnlineTime; set { if (OnPropertyChanging("OnlineTime", value)) { _OnlineTime = value; OnPropertyChanged("OnlineTime"); } } }
|
||||
|
||||
private String _CreateIP;
|
||||
/// <summary>创建地址</summary>
|
||||
[DisplayName("创建地址")]
|
||||
[Description("创建地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("CreateIP", "创建地址", "")]
|
||||
public String CreateIP { get => _CreateIP; set { if (OnPropertyChanging("CreateIP", value)) { _CreateIP = value; OnPropertyChanged("CreateIP"); } } }
|
||||
|
||||
private DateTime _CreateTime;
|
||||
/// <summary>创建时间</summary>
|
||||
[DisplayName("创建时间")]
|
||||
[Description("创建时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateTime", "创建时间", "")]
|
||||
public DateTime CreateTime { get => _CreateTime; set { if (OnPropertyChanging("CreateTime", value)) { _CreateTime = value; OnPropertyChanged("CreateTime"); } } }
|
||||
|
||||
private DateTime _UpdateTime;
|
||||
/// <summary>修改时间</summary>
|
||||
[DisplayName("修改时间")]
|
||||
[Description("修改时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateTime", "修改时间", "")]
|
||||
public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }
|
||||
#endregion
|
||||
|
||||
#region 获取/设置 字段值
|
||||
/// <summary>获取/设置 字段值</summary>
|
||||
/// <param name="name">字段名</param>
|
||||
/// <returns></returns>
|
||||
public override Object this[String name]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": return _ID;
|
||||
case "UserID": return _UserID;
|
||||
case "Name": return _Name;
|
||||
case "SessionID": return _SessionID;
|
||||
case "Times": return _Times;
|
||||
case "Page": return _Page;
|
||||
case "Status": return _Status;
|
||||
case "OnlineTime": return _OnlineTime;
|
||||
case "CreateIP": return _CreateIP;
|
||||
case "CreateTime": return _CreateTime;
|
||||
case "UpdateTime": return _UpdateTime;
|
||||
default: return base[name];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": _ID = value.ToInt(); break;
|
||||
case "UserID": _UserID = value.ToInt(); break;
|
||||
case "Name": _Name = Convert.ToString(value); break;
|
||||
case "SessionID": _SessionID = Convert.ToString(value); break;
|
||||
case "Times": _Times = value.ToInt(); break;
|
||||
case "Page": _Page = Convert.ToString(value); break;
|
||||
case "Status": _Status = Convert.ToString(value); break;
|
||||
case "OnlineTime": _OnlineTime = value.ToInt(); break;
|
||||
case "CreateIP": _CreateIP = Convert.ToString(value); break;
|
||||
case "CreateTime": _CreateTime = value.ToDateTime(); break;
|
||||
case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
|
||||
default: base[name] = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字段名
|
||||
/// <summary>取得用户在线字段信息的快捷方式</summary>
|
||||
public partial class _
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public static readonly Field ID = FindByName("ID");
|
||||
|
||||
/// <summary>用户</summary>
|
||||
public static readonly Field UserID = FindByName("UserID");
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public static readonly Field Name = FindByName("Name");
|
||||
|
||||
/// <summary>会话。Web的SessionID或Server的会话编号</summary>
|
||||
public static readonly Field SessionID = FindByName("SessionID");
|
||||
|
||||
/// <summary>次数</summary>
|
||||
public static readonly Field Times = FindByName("Times");
|
||||
|
||||
/// <summary>页面</summary>
|
||||
public static readonly Field Page = FindByName("Page");
|
||||
|
||||
/// <summary>状态</summary>
|
||||
public static readonly Field Status = FindByName("Status");
|
||||
|
||||
/// <summary>在线时间。本次在线总时间,秒</summary>
|
||||
public static readonly Field OnlineTime = FindByName("OnlineTime");
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public static readonly Field CreateIP = FindByName("CreateIP");
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public static readonly Field CreateTime = FindByName("CreateTime");
|
||||
|
||||
/// <summary>修改时间</summary>
|
||||
public static readonly Field UpdateTime = FindByName("UpdateTime");
|
||||
|
||||
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||
}
|
||||
|
||||
/// <summary>取得用户在线字段名称的快捷方式</summary>
|
||||
public partial class __
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public const String ID = "ID";
|
||||
|
||||
/// <summary>用户</summary>
|
||||
public const String UserID = "UserID";
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public const String Name = "Name";
|
||||
|
||||
/// <summary>会话。Web的SessionID或Server的会话编号</summary>
|
||||
public const String SessionID = "SessionID";
|
||||
|
||||
/// <summary>次数</summary>
|
||||
public const String Times = "Times";
|
||||
|
||||
/// <summary>页面</summary>
|
||||
public const String Page = "Page";
|
||||
|
||||
/// <summary>状态</summary>
|
||||
public const String Status = "Status";
|
||||
|
||||
/// <summary>在线时间。本次在线总时间,秒</summary>
|
||||
public const String OnlineTime = "OnlineTime";
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public const String CreateIP = "CreateIP";
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public const String CreateTime = "CreateTime";
|
||||
|
||||
/// <summary>修改时间</summary>
|
||||
public const String UpdateTime = "UpdateTime";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>菜单</summary>
|
||||
public partial class Menu : Entity<Menu>
|
||||
{
|
||||
#region 对象操作
|
||||
static Menu()
|
||||
{
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(nameof(ParentID));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<UserModule>();
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Modules.Add<IPModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 这里验证参数范围,建议抛出参数异常,指定参数名,前端用户界面可以捕获参数异常并聚焦到对应的参数输入框
|
||||
if (Name.IsNullOrEmpty()) throw new ArgumentNullException(nameof(Name), "名称不能为空!");
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 处理当前已登录用户信息,可以由UserModule过滤器代劳
|
||||
/*var user = ManageProvider.User;
|
||||
if (user != null)
|
||||
{
|
||||
if (isNew && !Dirtys[nameof(CreateUserID)]) CreateUserID = user.ID;
|
||||
if (!Dirtys[nameof(UpdateUserID)]) UpdateUserID = user.ID;
|
||||
}*/
|
||||
//if (isNew && !Dirtys[nameof(CreateTime)]) CreateTime = DateTime.Now;
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
//if (isNew && !Dirtys[nameof(CreateIP)]) CreateIP = ManageProvider.UserHost;
|
||||
//if (!Dirtys[nameof(UpdateIP)]) UpdateIP = ManageProvider.UserHost;
|
||||
|
||||
// 检查唯一索引
|
||||
// CheckExist(isNew, nameof(ParentID), nameof(Name));
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Session.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Menu[菜单]数据……");
|
||||
|
||||
// var entity = new Menu();
|
||||
// entity.Name = "abc";
|
||||
// entity.DisplayName = "abc";
|
||||
// entity.FullName = "abc";
|
||||
// entity.ParentID = 0;
|
||||
// entity.Url = "abc";
|
||||
// entity.Sort = 0;
|
||||
// entity.Icon = "abc";
|
||||
// entity.Visible = true;
|
||||
// entity.Necessary = true;
|
||||
// entity.Permission = "abc";
|
||||
// entity.Ex1 = 0;
|
||||
// entity.Ex2 = 0;
|
||||
// entity.Ex3 = 0.0;
|
||||
// entity.Ex4 = "abc";
|
||||
// entity.Ex5 = "abc";
|
||||
// entity.Ex6 = "abc";
|
||||
// entity.CreateUser = "abc";
|
||||
// entity.CreateUserID = 0;
|
||||
// entity.CreateIP = "abc";
|
||||
// entity.CreateTime = DateTime.Now;
|
||||
// entity.UpdateUser = "abc";
|
||||
// entity.UpdateUserID = 0;
|
||||
// entity.UpdateIP = "abc";
|
||||
// entity.UpdateTime = DateTime.Now;
|
||||
// entity.Remark = "abc";
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化Menu[菜单]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static Menu FindByID(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
|
||||
|
||||
// 单对象缓存
|
||||
return Meta.SingleCache[id];
|
||||
|
||||
//return Find(_.ID == id);
|
||||
}
|
||||
|
||||
/// <summary>根据名称查找</summary>
|
||||
/// <param name="name">名称</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Menu> FindAllByName(String name)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
|
||||
|
||||
return FindAll(_.Name == name);
|
||||
}
|
||||
|
||||
/// <summary>根据父编号、名称查找</summary>
|
||||
/// <param name="parentId">父编号</param>
|
||||
/// <param name="name">名称</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static Menu FindByParentIDAndName(Int32 parentId, String name)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ParentID == parentId && e.Name.EqualIgnoreCase(name));
|
||||
|
||||
return Find(_.ParentID == parentId & _.Name == name);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
/// <summary>高级查询</summary>
|
||||
/// <param name="name">名称</param>
|
||||
/// <param name="parentId">父编号</param>
|
||||
/// <param name="start">更新时间开始</param>
|
||||
/// <param name="end">更新时间结束</param>
|
||||
/// <param name="key">关键字</param>
|
||||
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Menu> Search(String name, Int32 parentId, DateTime start, DateTime end, String key, PageParameter page)
|
||||
{
|
||||
var exp = new WhereExpression();
|
||||
|
||||
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
|
||||
if (parentId >= 0) exp &= _.ParentID == parentId;
|
||||
exp &= _.UpdateTime.Between(start, end);
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.DisplayName.Contains(key) | _.FullName.Contains(key) | _.Url.Contains(key) | _.Icon.Contains(key) | _.Permission.Contains(key) | _.Ex4.Contains(key) | _.Ex5.Contains(key) | _.Ex6.Contains(key) | _.CreateUser.Contains(key) | _.CreateIP.Contains(key) | _.UpdateUser.Contains(key) | _.UpdateIP.Contains(key) | _.Remark.Contains(key);
|
||||
|
||||
return FindAll(exp, page);
|
||||
}
|
||||
|
||||
// Select Count(ID) as ID,Category From Menu Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By ID Desc limit 20
|
||||
//static readonly FieldCache<Menu> _CategoryCache = new FieldCache<Menu>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,475 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>菜单</summary>
|
||||
[Serializable]
|
||||
[DataObject]
|
||||
[Description("菜单")]
|
||||
[BindIndex("IX_Menu_Name", false, "Name")]
|
||||
[BindIndex("IU_Menu_ParentID_Name", true, "ParentID,Name")]
|
||||
[BindTable("Menu", Description = "菜单", ConnName = "Membership", DbType = DatabaseType.None)]
|
||||
public partial class Menu
|
||||
{
|
||||
#region 属性
|
||||
private Int32 _ID;
|
||||
/// <summary>编号</summary>
|
||||
[DisplayName("编号")]
|
||||
[Description("编号")]
|
||||
[DataObjectField(true, true, false, 0)]
|
||||
[BindColumn("ID", "编号", "")]
|
||||
public Int32 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }
|
||||
|
||||
private String _Name;
|
||||
/// <summary>名称</summary>
|
||||
[DisplayName("名称")]
|
||||
[Description("名称")]
|
||||
[DataObjectField(false, false, false, 50)]
|
||||
[BindColumn("Name", "名称", "", Master = true)]
|
||||
public String Name { get => _Name; set { if (OnPropertyChanging("Name", value)) { _Name = value; OnPropertyChanged("Name"); } } }
|
||||
|
||||
private String _DisplayName;
|
||||
/// <summary>显示名</summary>
|
||||
[DisplayName("显示名")]
|
||||
[Description("显示名")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("DisplayName", "显示名", "")]
|
||||
public String DisplayName { get => _DisplayName; set { if (OnPropertyChanging("DisplayName", value)) { _DisplayName = value; OnPropertyChanged("DisplayName"); } } }
|
||||
|
||||
private String _FullName;
|
||||
/// <summary>全名</summary>
|
||||
[DisplayName("全名")]
|
||||
[Description("全名")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("FullName", "全名", "")]
|
||||
public String FullName { get => _FullName; set { if (OnPropertyChanging("FullName", value)) { _FullName = value; OnPropertyChanged("FullName"); } } }
|
||||
|
||||
private Int32 _ParentID;
|
||||
/// <summary>父编号</summary>
|
||||
[DisplayName("父编号")]
|
||||
[Description("父编号")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("ParentID", "父编号", "")]
|
||||
public Int32 ParentID { get => _ParentID; set { if (OnPropertyChanging("ParentID", value)) { _ParentID = value; OnPropertyChanged("ParentID"); } } }
|
||||
|
||||
private String _Url;
|
||||
/// <summary>链接</summary>
|
||||
[DisplayName("链接")]
|
||||
[Description("链接")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("Url", "链接", "")]
|
||||
public String Url { get => _Url; set { if (OnPropertyChanging("Url", value)) { _Url = value; OnPropertyChanged("Url"); } } }
|
||||
|
||||
private Int32 _Sort;
|
||||
/// <summary>排序</summary>
|
||||
[DisplayName("排序")]
|
||||
[Description("排序")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Sort", "排序", "")]
|
||||
public Int32 Sort { get => _Sort; set { if (OnPropertyChanging("Sort", value)) { _Sort = value; OnPropertyChanged("Sort"); } } }
|
||||
|
||||
private String _Icon;
|
||||
/// <summary>图标</summary>
|
||||
[DisplayName("图标")]
|
||||
[Description("图标")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Icon", "图标", "")]
|
||||
public String Icon { get => _Icon; set { if (OnPropertyChanging("Icon", value)) { _Icon = value; OnPropertyChanged("Icon"); } } }
|
||||
|
||||
private Boolean _Visible;
|
||||
/// <summary>可见</summary>
|
||||
[DisplayName("可见")]
|
||||
[Description("可见")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Visible", "可见", "")]
|
||||
public Boolean Visible { get => _Visible; set { if (OnPropertyChanging("Visible", value)) { _Visible = value; OnPropertyChanged("Visible"); } } }
|
||||
|
||||
private Boolean _Necessary;
|
||||
/// <summary>必要。必要的菜单,必须至少有角色拥有这些权限,如果没有则自动授权给系统角色</summary>
|
||||
[DisplayName("必要")]
|
||||
[Description("必要。必要的菜单,必须至少有角色拥有这些权限,如果没有则自动授权给系统角色")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Necessary", "必要。必要的菜单,必须至少有角色拥有这些权限,如果没有则自动授权给系统角色", "")]
|
||||
public Boolean Necessary { get => _Necessary; set { if (OnPropertyChanging("Necessary", value)) { _Necessary = value; OnPropertyChanged("Necessary"); } } }
|
||||
|
||||
private String _Permission;
|
||||
/// <summary>权限子项。逗号分隔,每个权限子项名值竖线分隔</summary>
|
||||
[DisplayName("权限子项")]
|
||||
[Description("权限子项。逗号分隔,每个权限子项名值竖线分隔")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("Permission", "权限子项。逗号分隔,每个权限子项名值竖线分隔", "")]
|
||||
public String Permission { get => _Permission; set { if (OnPropertyChanging("Permission", value)) { _Permission = value; OnPropertyChanged("Permission"); } } }
|
||||
|
||||
private Int32 _Ex1;
|
||||
/// <summary>扩展1</summary>
|
||||
[DisplayName("扩展1")]
|
||||
[Description("扩展1")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex1", "扩展1", "")]
|
||||
public Int32 Ex1 { get => _Ex1; set { if (OnPropertyChanging("Ex1", value)) { _Ex1 = value; OnPropertyChanged("Ex1"); } } }
|
||||
|
||||
private Int32 _Ex2;
|
||||
/// <summary>扩展2</summary>
|
||||
[DisplayName("扩展2")]
|
||||
[Description("扩展2")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex2", "扩展2", "")]
|
||||
public Int32 Ex2 { get => _Ex2; set { if (OnPropertyChanging("Ex2", value)) { _Ex2 = value; OnPropertyChanged("Ex2"); } } }
|
||||
|
||||
private Double _Ex3;
|
||||
/// <summary>扩展3</summary>
|
||||
[DisplayName("扩展3")]
|
||||
[Description("扩展3")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex3", "扩展3", "")]
|
||||
public Double Ex3 { get => _Ex3; set { if (OnPropertyChanging("Ex3", value)) { _Ex3 = value; OnPropertyChanged("Ex3"); } } }
|
||||
|
||||
private String _Ex4;
|
||||
/// <summary>扩展4</summary>
|
||||
[DisplayName("扩展4")]
|
||||
[Description("扩展4")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex4", "扩展4", "")]
|
||||
public String Ex4 { get => _Ex4; set { if (OnPropertyChanging("Ex4", value)) { _Ex4 = value; OnPropertyChanged("Ex4"); } } }
|
||||
|
||||
private String _Ex5;
|
||||
/// <summary>扩展5</summary>
|
||||
[DisplayName("扩展5")]
|
||||
[Description("扩展5")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex5", "扩展5", "")]
|
||||
public String Ex5 { get => _Ex5; set { if (OnPropertyChanging("Ex5", value)) { _Ex5 = value; OnPropertyChanged("Ex5"); } } }
|
||||
|
||||
private String _Ex6;
|
||||
/// <summary>扩展6</summary>
|
||||
[DisplayName("扩展6")]
|
||||
[Description("扩展6")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex6", "扩展6", "")]
|
||||
public String Ex6 { get => _Ex6; set { if (OnPropertyChanging("Ex6", value)) { _Ex6 = value; OnPropertyChanged("Ex6"); } } }
|
||||
|
||||
private String _CreateUser;
|
||||
/// <summary>创建者</summary>
|
||||
[DisplayName("创建者")]
|
||||
[Description("创建者")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("CreateUser", "创建者", "")]
|
||||
public String CreateUser { get => _CreateUser; set { if (OnPropertyChanging("CreateUser", value)) { _CreateUser = value; OnPropertyChanged("CreateUser"); } } }
|
||||
|
||||
private Int32 _CreateUserID;
|
||||
/// <summary>创建用户</summary>
|
||||
[DisplayName("创建用户")]
|
||||
[Description("创建用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateUserID", "创建用户", "")]
|
||||
public Int32 CreateUserID { get => _CreateUserID; set { if (OnPropertyChanging("CreateUserID", value)) { _CreateUserID = value; OnPropertyChanged("CreateUserID"); } } }
|
||||
|
||||
private String _CreateIP;
|
||||
/// <summary>创建地址</summary>
|
||||
[DisplayName("创建地址")]
|
||||
[Description("创建地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("CreateIP", "创建地址", "")]
|
||||
public String CreateIP { get => _CreateIP; set { if (OnPropertyChanging("CreateIP", value)) { _CreateIP = value; OnPropertyChanged("CreateIP"); } } }
|
||||
|
||||
private DateTime _CreateTime;
|
||||
/// <summary>创建时间</summary>
|
||||
[DisplayName("创建时间")]
|
||||
[Description("创建时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateTime", "创建时间", "")]
|
||||
public DateTime CreateTime { get => _CreateTime; set { if (OnPropertyChanging("CreateTime", value)) { _CreateTime = value; OnPropertyChanged("CreateTime"); } } }
|
||||
|
||||
private String _UpdateUser;
|
||||
/// <summary>更新者</summary>
|
||||
[DisplayName("更新者")]
|
||||
[Description("更新者")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateUser", "更新者", "")]
|
||||
public String UpdateUser { get => _UpdateUser; set { if (OnPropertyChanging("UpdateUser", value)) { _UpdateUser = value; OnPropertyChanged("UpdateUser"); } } }
|
||||
|
||||
private Int32 _UpdateUserID;
|
||||
/// <summary>更新用户</summary>
|
||||
[DisplayName("更新用户")]
|
||||
[Description("更新用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateUserID", "更新用户", "")]
|
||||
public Int32 UpdateUserID { get => _UpdateUserID; set { if (OnPropertyChanging("UpdateUserID", value)) { _UpdateUserID = value; OnPropertyChanged("UpdateUserID"); } } }
|
||||
|
||||
private String _UpdateIP;
|
||||
/// <summary>更新地址</summary>
|
||||
[DisplayName("更新地址")]
|
||||
[Description("更新地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateIP", "更新地址", "")]
|
||||
public String UpdateIP { get => _UpdateIP; set { if (OnPropertyChanging("UpdateIP", value)) { _UpdateIP = value; OnPropertyChanged("UpdateIP"); } } }
|
||||
|
||||
private DateTime _UpdateTime;
|
||||
/// <summary>更新时间</summary>
|
||||
[DisplayName("更新时间")]
|
||||
[Description("更新时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateTime", "更新时间", "")]
|
||||
public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }
|
||||
|
||||
private String _Remark;
|
||||
/// <summary>备注</summary>
|
||||
[DisplayName("备注")]
|
||||
[Description("备注")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("Remark", "备注", "")]
|
||||
public String Remark { get => _Remark; set { if (OnPropertyChanging("Remark", value)) { _Remark = value; OnPropertyChanged("Remark"); } } }
|
||||
#endregion
|
||||
|
||||
#region 获取/设置 字段值
|
||||
/// <summary>获取/设置 字段值</summary>
|
||||
/// <param name="name">字段名</param>
|
||||
/// <returns></returns>
|
||||
public override Object this[String name]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": return _ID;
|
||||
case "Name": return _Name;
|
||||
case "DisplayName": return _DisplayName;
|
||||
case "FullName": return _FullName;
|
||||
case "ParentID": return _ParentID;
|
||||
case "Url": return _Url;
|
||||
case "Sort": return _Sort;
|
||||
case "Icon": return _Icon;
|
||||
case "Visible": return _Visible;
|
||||
case "Necessary": return _Necessary;
|
||||
case "Permission": return _Permission;
|
||||
case "Ex1": return _Ex1;
|
||||
case "Ex2": return _Ex2;
|
||||
case "Ex3": return _Ex3;
|
||||
case "Ex4": return _Ex4;
|
||||
case "Ex5": return _Ex5;
|
||||
case "Ex6": return _Ex6;
|
||||
case "CreateUser": return _CreateUser;
|
||||
case "CreateUserID": return _CreateUserID;
|
||||
case "CreateIP": return _CreateIP;
|
||||
case "CreateTime": return _CreateTime;
|
||||
case "UpdateUser": return _UpdateUser;
|
||||
case "UpdateUserID": return _UpdateUserID;
|
||||
case "UpdateIP": return _UpdateIP;
|
||||
case "UpdateTime": return _UpdateTime;
|
||||
case "Remark": return _Remark;
|
||||
default: return base[name];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": _ID = value.ToInt(); break;
|
||||
case "Name": _Name = Convert.ToString(value); break;
|
||||
case "DisplayName": _DisplayName = Convert.ToString(value); break;
|
||||
case "FullName": _FullName = Convert.ToString(value); break;
|
||||
case "ParentID": _ParentID = value.ToInt(); break;
|
||||
case "Url": _Url = Convert.ToString(value); break;
|
||||
case "Sort": _Sort = value.ToInt(); break;
|
||||
case "Icon": _Icon = Convert.ToString(value); break;
|
||||
case "Visible": _Visible = value.ToBoolean(); break;
|
||||
case "Necessary": _Necessary = value.ToBoolean(); break;
|
||||
case "Permission": _Permission = Convert.ToString(value); break;
|
||||
case "Ex1": _Ex1 = value.ToInt(); break;
|
||||
case "Ex2": _Ex2 = value.ToInt(); break;
|
||||
case "Ex3": _Ex3 = value.ToDouble(); break;
|
||||
case "Ex4": _Ex4 = Convert.ToString(value); break;
|
||||
case "Ex5": _Ex5 = Convert.ToString(value); break;
|
||||
case "Ex6": _Ex6 = Convert.ToString(value); break;
|
||||
case "CreateUser": _CreateUser = Convert.ToString(value); break;
|
||||
case "CreateUserID": _CreateUserID = value.ToInt(); break;
|
||||
case "CreateIP": _CreateIP = Convert.ToString(value); break;
|
||||
case "CreateTime": _CreateTime = value.ToDateTime(); break;
|
||||
case "UpdateUser": _UpdateUser = Convert.ToString(value); break;
|
||||
case "UpdateUserID": _UpdateUserID = value.ToInt(); break;
|
||||
case "UpdateIP": _UpdateIP = Convert.ToString(value); break;
|
||||
case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
|
||||
case "Remark": _Remark = Convert.ToString(value); break;
|
||||
default: base[name] = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字段名
|
||||
/// <summary>取得菜单字段信息的快捷方式</summary>
|
||||
public partial class _
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public static readonly Field ID = FindByName("ID");
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public static readonly Field Name = FindByName("Name");
|
||||
|
||||
/// <summary>显示名</summary>
|
||||
public static readonly Field DisplayName = FindByName("DisplayName");
|
||||
|
||||
/// <summary>全名</summary>
|
||||
public static readonly Field FullName = FindByName("FullName");
|
||||
|
||||
/// <summary>父编号</summary>
|
||||
public static readonly Field ParentID = FindByName("ParentID");
|
||||
|
||||
/// <summary>链接</summary>
|
||||
public static readonly Field Url = FindByName("Url");
|
||||
|
||||
/// <summary>排序</summary>
|
||||
public static readonly Field Sort = FindByName("Sort");
|
||||
|
||||
/// <summary>图标</summary>
|
||||
public static readonly Field Icon = FindByName("Icon");
|
||||
|
||||
/// <summary>可见</summary>
|
||||
public static readonly Field Visible = FindByName("Visible");
|
||||
|
||||
/// <summary>必要。必要的菜单,必须至少有角色拥有这些权限,如果没有则自动授权给系统角色</summary>
|
||||
public static readonly Field Necessary = FindByName("Necessary");
|
||||
|
||||
/// <summary>权限子项。逗号分隔,每个权限子项名值竖线分隔</summary>
|
||||
public static readonly Field Permission = FindByName("Permission");
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public static readonly Field Ex1 = FindByName("Ex1");
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public static readonly Field Ex2 = FindByName("Ex2");
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public static readonly Field Ex3 = FindByName("Ex3");
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public static readonly Field Ex4 = FindByName("Ex4");
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public static readonly Field Ex5 = FindByName("Ex5");
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public static readonly Field Ex6 = FindByName("Ex6");
|
||||
|
||||
/// <summary>创建者</summary>
|
||||
public static readonly Field CreateUser = FindByName("CreateUser");
|
||||
|
||||
/// <summary>创建用户</summary>
|
||||
public static readonly Field CreateUserID = FindByName("CreateUserID");
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public static readonly Field CreateIP = FindByName("CreateIP");
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public static readonly Field CreateTime = FindByName("CreateTime");
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public static readonly Field UpdateUser = FindByName("UpdateUser");
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public static readonly Field UpdateUserID = FindByName("UpdateUserID");
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public static readonly Field UpdateIP = FindByName("UpdateIP");
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public static readonly Field UpdateTime = FindByName("UpdateTime");
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public static readonly Field Remark = FindByName("Remark");
|
||||
|
||||
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||
}
|
||||
|
||||
/// <summary>取得菜单字段名称的快捷方式</summary>
|
||||
public partial class __
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public const String ID = "ID";
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public const String Name = "Name";
|
||||
|
||||
/// <summary>显示名</summary>
|
||||
public const String DisplayName = "DisplayName";
|
||||
|
||||
/// <summary>全名</summary>
|
||||
public const String FullName = "FullName";
|
||||
|
||||
/// <summary>父编号</summary>
|
||||
public const String ParentID = "ParentID";
|
||||
|
||||
/// <summary>链接</summary>
|
||||
public const String Url = "Url";
|
||||
|
||||
/// <summary>排序</summary>
|
||||
public const String Sort = "Sort";
|
||||
|
||||
/// <summary>图标</summary>
|
||||
public const String Icon = "Icon";
|
||||
|
||||
/// <summary>可见</summary>
|
||||
public const String Visible = "Visible";
|
||||
|
||||
/// <summary>必要。必要的菜单,必须至少有角色拥有这些权限,如果没有则自动授权给系统角色</summary>
|
||||
public const String Necessary = "Necessary";
|
||||
|
||||
/// <summary>权限子项。逗号分隔,每个权限子项名值竖线分隔</summary>
|
||||
public const String Permission = "Permission";
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public const String Ex1 = "Ex1";
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public const String Ex2 = "Ex2";
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public const String Ex3 = "Ex3";
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public const String Ex4 = "Ex4";
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public const String Ex5 = "Ex5";
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public const String Ex6 = "Ex6";
|
||||
|
||||
/// <summary>创建者</summary>
|
||||
public const String CreateUser = "CreateUser";
|
||||
|
||||
/// <summary>创建用户</summary>
|
||||
public const String CreateUserID = "CreateUserID";
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public const String CreateIP = "CreateIP";
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public const String CreateTime = "CreateTime";
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public const String UpdateUser = "UpdateUser";
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public const String UpdateUserID = "UpdateUserID";
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public const String UpdateIP = "UpdateIP";
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public const String UpdateTime = "UpdateTime";
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public const String Remark = "Remark";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>角色</summary>
|
||||
public partial class Role : Entity<Role>
|
||||
{
|
||||
#region 对象操作
|
||||
static Role()
|
||||
{
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(nameof(Ex1));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<UserModule>();
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Modules.Add<IPModule>();
|
||||
|
||||
// 单对象缓存
|
||||
var sc = Meta.SingleCache;
|
||||
sc.FindSlaveKeyMethod = k => Find(_.Name == k);
|
||||
sc.GetSlaveKeyMethod = e => e.Name;
|
||||
}
|
||||
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 这里验证参数范围,建议抛出参数异常,指定参数名,前端用户界面可以捕获参数异常并聚焦到对应的参数输入框
|
||||
if (Name.IsNullOrEmpty()) throw new ArgumentNullException(nameof(Name), "名称不能为空!");
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 处理当前已登录用户信息,可以由UserModule过滤器代劳
|
||||
/*var user = ManageProvider.User;
|
||||
if (user != null)
|
||||
{
|
||||
if (isNew && !Dirtys[nameof(CreateUserID)]) CreateUserID = user.ID;
|
||||
if (!Dirtys[nameof(UpdateUserID)]) UpdateUserID = user.ID;
|
||||
}*/
|
||||
//if (isNew && !Dirtys[nameof(CreateTime)]) CreateTime = DateTime.Now;
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
//if (isNew && !Dirtys[nameof(CreateIP)]) CreateIP = ManageProvider.UserHost;
|
||||
//if (!Dirtys[nameof(UpdateIP)]) UpdateIP = ManageProvider.UserHost;
|
||||
|
||||
// 检查唯一索引
|
||||
// CheckExist(isNew, nameof(Name));
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Session.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Role[角色]数据……");
|
||||
|
||||
// var entity = new Role();
|
||||
// entity.Name = "abc";
|
||||
// entity.Enable = true;
|
||||
// entity.IsSystem = true;
|
||||
// entity.Permission = "abc";
|
||||
// entity.Ex1 = 0;
|
||||
// entity.Ex2 = 0;
|
||||
// entity.Ex3 = 0.0;
|
||||
// entity.Ex4 = "abc";
|
||||
// entity.Ex5 = "abc";
|
||||
// entity.Ex6 = "abc";
|
||||
// entity.CreateUser = "abc";
|
||||
// entity.CreateUserID = 0;
|
||||
// entity.CreateIP = "abc";
|
||||
// entity.CreateTime = DateTime.Now;
|
||||
// entity.UpdateUser = "abc";
|
||||
// entity.UpdateUserID = 0;
|
||||
// entity.UpdateIP = "abc";
|
||||
// entity.UpdateTime = DateTime.Now;
|
||||
// entity.Remark = "abc";
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化Role[角色]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static Role FindByID(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
|
||||
|
||||
// 单对象缓存
|
||||
return Meta.SingleCache[id];
|
||||
|
||||
//return Find(_.ID == id);
|
||||
}
|
||||
|
||||
/// <summary>根据名称查找</summary>
|
||||
/// <param name="name">名称</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static Role FindByName(String name)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name.EqualIgnoreCase(name));
|
||||
|
||||
// 单对象缓存
|
||||
//return Meta.SingleCache.GetItemWithSlaveKey(name) as Role;
|
||||
|
||||
return Find(_.Name == name);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
/// <summary>高级查询</summary>
|
||||
/// <param name="name">名称</param>
|
||||
/// <param name="start">更新时间开始</param>
|
||||
/// <param name="end">更新时间结束</param>
|
||||
/// <param name="key">关键字</param>
|
||||
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Role> Search(String name, DateTime start, DateTime end, String key, PageParameter page)
|
||||
{
|
||||
var exp = new WhereExpression();
|
||||
|
||||
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
|
||||
exp &= _.UpdateTime.Between(start, end);
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Name.Contains(key) | _.Permission.Contains(key) | _.Ex4.Contains(key) | _.Ex5.Contains(key) | _.Ex6.Contains(key) | _.CreateUser.Contains(key) | _.CreateIP.Contains(key) | _.UpdateUser.Contains(key) | _.UpdateIP.Contains(key) | _.Remark.Contains(key);
|
||||
|
||||
return FindAll(exp, page);
|
||||
}
|
||||
|
||||
// Select Count(ID) as ID,Category From Role Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By ID Desc limit 20
|
||||
//static readonly FieldCache<Role> _CategoryCache = new FieldCache<Role>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>角色</summary>
|
||||
[Serializable]
|
||||
[DataObject]
|
||||
[Description("角色")]
|
||||
[BindIndex("IU_Role_Name", true, "Name")]
|
||||
[BindTable("Role", Description = "角色", ConnName = "Membership", DbType = DatabaseType.None)]
|
||||
public partial class Role
|
||||
{
|
||||
#region 属性
|
||||
private Int32 _ID;
|
||||
/// <summary>编号</summary>
|
||||
[DisplayName("编号")]
|
||||
[Description("编号")]
|
||||
[DataObjectField(true, true, false, 0)]
|
||||
[BindColumn("ID", "编号", "")]
|
||||
public Int32 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }
|
||||
|
||||
private String _Name;
|
||||
/// <summary>名称</summary>
|
||||
[DisplayName("名称")]
|
||||
[Description("名称")]
|
||||
[DataObjectField(false, false, false, 50)]
|
||||
[BindColumn("Name", "名称", "", Master = true)]
|
||||
public String Name { get => _Name; set { if (OnPropertyChanging("Name", value)) { _Name = value; OnPropertyChanged("Name"); } } }
|
||||
|
||||
private Boolean _Enable;
|
||||
/// <summary>启用</summary>
|
||||
[DisplayName("启用")]
|
||||
[Description("启用")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Enable", "启用", "")]
|
||||
public Boolean Enable { get => _Enable; set { if (OnPropertyChanging("Enable", value)) { _Enable = value; OnPropertyChanged("Enable"); } } }
|
||||
|
||||
private Boolean _IsSystem;
|
||||
/// <summary>系统。用于业务系统开发使用,不受数据权限约束,禁止修改名称或删除</summary>
|
||||
[DisplayName("系统")]
|
||||
[Description("系统。用于业务系统开发使用,不受数据权限约束,禁止修改名称或删除")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("IsSystem", "系统。用于业务系统开发使用,不受数据权限约束,禁止修改名称或删除", "")]
|
||||
public Boolean IsSystem { get => _IsSystem; set { if (OnPropertyChanging("IsSystem", value)) { _IsSystem = value; OnPropertyChanged("IsSystem"); } } }
|
||||
|
||||
private String _Permission;
|
||||
/// <summary>权限。对不同资源的权限,逗号分隔,每个资源的权限子项竖线分隔</summary>
|
||||
[DisplayName("权限")]
|
||||
[Description("权限。对不同资源的权限,逗号分隔,每个资源的权限子项竖线分隔")]
|
||||
[DataObjectField(false, false, true, -1)]
|
||||
[BindColumn("Permission", "权限。对不同资源的权限,逗号分隔,每个资源的权限子项竖线分隔", "")]
|
||||
public String Permission { get => _Permission; set { if (OnPropertyChanging("Permission", value)) { _Permission = value; OnPropertyChanged("Permission"); } } }
|
||||
|
||||
private Int32 _Ex1;
|
||||
/// <summary>扩展1</summary>
|
||||
[DisplayName("扩展1")]
|
||||
[Description("扩展1")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex1", "扩展1", "")]
|
||||
public Int32 Ex1 { get => _Ex1; set { if (OnPropertyChanging("Ex1", value)) { _Ex1 = value; OnPropertyChanged("Ex1"); } } }
|
||||
|
||||
private Int32 _Ex2;
|
||||
/// <summary>扩展2</summary>
|
||||
[DisplayName("扩展2")]
|
||||
[Description("扩展2")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex2", "扩展2", "")]
|
||||
public Int32 Ex2 { get => _Ex2; set { if (OnPropertyChanging("Ex2", value)) { _Ex2 = value; OnPropertyChanged("Ex2"); } } }
|
||||
|
||||
private Double _Ex3;
|
||||
/// <summary>扩展3</summary>
|
||||
[DisplayName("扩展3")]
|
||||
[Description("扩展3")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex3", "扩展3", "")]
|
||||
public Double Ex3 { get => _Ex3; set { if (OnPropertyChanging("Ex3", value)) { _Ex3 = value; OnPropertyChanged("Ex3"); } } }
|
||||
|
||||
private String _Ex4;
|
||||
/// <summary>扩展4</summary>
|
||||
[DisplayName("扩展4")]
|
||||
[Description("扩展4")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex4", "扩展4", "")]
|
||||
public String Ex4 { get => _Ex4; set { if (OnPropertyChanging("Ex4", value)) { _Ex4 = value; OnPropertyChanged("Ex4"); } } }
|
||||
|
||||
private String _Ex5;
|
||||
/// <summary>扩展5</summary>
|
||||
[DisplayName("扩展5")]
|
||||
[Description("扩展5")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex5", "扩展5", "")]
|
||||
public String Ex5 { get => _Ex5; set { if (OnPropertyChanging("Ex5", value)) { _Ex5 = value; OnPropertyChanged("Ex5"); } } }
|
||||
|
||||
private String _Ex6;
|
||||
/// <summary>扩展6</summary>
|
||||
[DisplayName("扩展6")]
|
||||
[Description("扩展6")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex6", "扩展6", "")]
|
||||
public String Ex6 { get => _Ex6; set { if (OnPropertyChanging("Ex6", value)) { _Ex6 = value; OnPropertyChanged("Ex6"); } } }
|
||||
|
||||
private String _CreateUser;
|
||||
/// <summary>创建者</summary>
|
||||
[DisplayName("创建者")]
|
||||
[Description("创建者")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("CreateUser", "创建者", "")]
|
||||
public String CreateUser { get => _CreateUser; set { if (OnPropertyChanging("CreateUser", value)) { _CreateUser = value; OnPropertyChanged("CreateUser"); } } }
|
||||
|
||||
private Int32 _CreateUserID;
|
||||
/// <summary>创建用户</summary>
|
||||
[DisplayName("创建用户")]
|
||||
[Description("创建用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateUserID", "创建用户", "")]
|
||||
public Int32 CreateUserID { get => _CreateUserID; set { if (OnPropertyChanging("CreateUserID", value)) { _CreateUserID = value; OnPropertyChanged("CreateUserID"); } } }
|
||||
|
||||
private String _CreateIP;
|
||||
/// <summary>创建地址</summary>
|
||||
[DisplayName("创建地址")]
|
||||
[Description("创建地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("CreateIP", "创建地址", "")]
|
||||
public String CreateIP { get => _CreateIP; set { if (OnPropertyChanging("CreateIP", value)) { _CreateIP = value; OnPropertyChanged("CreateIP"); } } }
|
||||
|
||||
private DateTime _CreateTime;
|
||||
/// <summary>创建时间</summary>
|
||||
[DisplayName("创建时间")]
|
||||
[Description("创建时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateTime", "创建时间", "")]
|
||||
public DateTime CreateTime { get => _CreateTime; set { if (OnPropertyChanging("CreateTime", value)) { _CreateTime = value; OnPropertyChanged("CreateTime"); } } }
|
||||
|
||||
private String _UpdateUser;
|
||||
/// <summary>更新者</summary>
|
||||
[DisplayName("更新者")]
|
||||
[Description("更新者")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateUser", "更新者", "")]
|
||||
public String UpdateUser { get => _UpdateUser; set { if (OnPropertyChanging("UpdateUser", value)) { _UpdateUser = value; OnPropertyChanged("UpdateUser"); } } }
|
||||
|
||||
private Int32 _UpdateUserID;
|
||||
/// <summary>更新用户</summary>
|
||||
[DisplayName("更新用户")]
|
||||
[Description("更新用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateUserID", "更新用户", "")]
|
||||
public Int32 UpdateUserID { get => _UpdateUserID; set { if (OnPropertyChanging("UpdateUserID", value)) { _UpdateUserID = value; OnPropertyChanged("UpdateUserID"); } } }
|
||||
|
||||
private String _UpdateIP;
|
||||
/// <summary>更新地址</summary>
|
||||
[DisplayName("更新地址")]
|
||||
[Description("更新地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateIP", "更新地址", "")]
|
||||
public String UpdateIP { get => _UpdateIP; set { if (OnPropertyChanging("UpdateIP", value)) { _UpdateIP = value; OnPropertyChanged("UpdateIP"); } } }
|
||||
|
||||
private DateTime _UpdateTime;
|
||||
/// <summary>更新时间</summary>
|
||||
[DisplayName("更新时间")]
|
||||
[Description("更新时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateTime", "更新时间", "")]
|
||||
public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }
|
||||
|
||||
private String _Remark;
|
||||
/// <summary>备注</summary>
|
||||
[DisplayName("备注")]
|
||||
[Description("备注")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("Remark", "备注", "")]
|
||||
public String Remark { get => _Remark; set { if (OnPropertyChanging("Remark", value)) { _Remark = value; OnPropertyChanged("Remark"); } } }
|
||||
#endregion
|
||||
|
||||
#region 获取/设置 字段值
|
||||
/// <summary>获取/设置 字段值</summary>
|
||||
/// <param name="name">字段名</param>
|
||||
/// <returns></returns>
|
||||
public override Object this[String name]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": return _ID;
|
||||
case "Name": return _Name;
|
||||
case "Enable": return _Enable;
|
||||
case "IsSystem": return _IsSystem;
|
||||
case "Permission": return _Permission;
|
||||
case "Ex1": return _Ex1;
|
||||
case "Ex2": return _Ex2;
|
||||
case "Ex3": return _Ex3;
|
||||
case "Ex4": return _Ex4;
|
||||
case "Ex5": return _Ex5;
|
||||
case "Ex6": return _Ex6;
|
||||
case "CreateUser": return _CreateUser;
|
||||
case "CreateUserID": return _CreateUserID;
|
||||
case "CreateIP": return _CreateIP;
|
||||
case "CreateTime": return _CreateTime;
|
||||
case "UpdateUser": return _UpdateUser;
|
||||
case "UpdateUserID": return _UpdateUserID;
|
||||
case "UpdateIP": return _UpdateIP;
|
||||
case "UpdateTime": return _UpdateTime;
|
||||
case "Remark": return _Remark;
|
||||
default: return base[name];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": _ID = value.ToInt(); break;
|
||||
case "Name": _Name = Convert.ToString(value); break;
|
||||
case "Enable": _Enable = value.ToBoolean(); break;
|
||||
case "IsSystem": _IsSystem = value.ToBoolean(); break;
|
||||
case "Permission": _Permission = Convert.ToString(value); break;
|
||||
case "Ex1": _Ex1 = value.ToInt(); break;
|
||||
case "Ex2": _Ex2 = value.ToInt(); break;
|
||||
case "Ex3": _Ex3 = value.ToDouble(); break;
|
||||
case "Ex4": _Ex4 = Convert.ToString(value); break;
|
||||
case "Ex5": _Ex5 = Convert.ToString(value); break;
|
||||
case "Ex6": _Ex6 = Convert.ToString(value); break;
|
||||
case "CreateUser": _CreateUser = Convert.ToString(value); break;
|
||||
case "CreateUserID": _CreateUserID = value.ToInt(); break;
|
||||
case "CreateIP": _CreateIP = Convert.ToString(value); break;
|
||||
case "CreateTime": _CreateTime = value.ToDateTime(); break;
|
||||
case "UpdateUser": _UpdateUser = Convert.ToString(value); break;
|
||||
case "UpdateUserID": _UpdateUserID = value.ToInt(); break;
|
||||
case "UpdateIP": _UpdateIP = Convert.ToString(value); break;
|
||||
case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
|
||||
case "Remark": _Remark = Convert.ToString(value); break;
|
||||
default: base[name] = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字段名
|
||||
/// <summary>取得角色字段信息的快捷方式</summary>
|
||||
public partial class _
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public static readonly Field ID = FindByName("ID");
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public static readonly Field Name = FindByName("Name");
|
||||
|
||||
/// <summary>启用</summary>
|
||||
public static readonly Field Enable = FindByName("Enable");
|
||||
|
||||
/// <summary>系统。用于业务系统开发使用,不受数据权限约束,禁止修改名称或删除</summary>
|
||||
public static readonly Field IsSystem = FindByName("IsSystem");
|
||||
|
||||
/// <summary>权限。对不同资源的权限,逗号分隔,每个资源的权限子项竖线分隔</summary>
|
||||
public static readonly Field Permission = FindByName("Permission");
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public static readonly Field Ex1 = FindByName("Ex1");
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public static readonly Field Ex2 = FindByName("Ex2");
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public static readonly Field Ex3 = FindByName("Ex3");
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public static readonly Field Ex4 = FindByName("Ex4");
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public static readonly Field Ex5 = FindByName("Ex5");
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public static readonly Field Ex6 = FindByName("Ex6");
|
||||
|
||||
/// <summary>创建者</summary>
|
||||
public static readonly Field CreateUser = FindByName("CreateUser");
|
||||
|
||||
/// <summary>创建用户</summary>
|
||||
public static readonly Field CreateUserID = FindByName("CreateUserID");
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public static readonly Field CreateIP = FindByName("CreateIP");
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public static readonly Field CreateTime = FindByName("CreateTime");
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public static readonly Field UpdateUser = FindByName("UpdateUser");
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public static readonly Field UpdateUserID = FindByName("UpdateUserID");
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public static readonly Field UpdateIP = FindByName("UpdateIP");
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public static readonly Field UpdateTime = FindByName("UpdateTime");
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public static readonly Field Remark = FindByName("Remark");
|
||||
|
||||
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||
}
|
||||
|
||||
/// <summary>取得角色字段名称的快捷方式</summary>
|
||||
public partial class __
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public const String ID = "ID";
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public const String Name = "Name";
|
||||
|
||||
/// <summary>启用</summary>
|
||||
public const String Enable = "Enable";
|
||||
|
||||
/// <summary>系统。用于业务系统开发使用,不受数据权限约束,禁止修改名称或删除</summary>
|
||||
public const String IsSystem = "IsSystem";
|
||||
|
||||
/// <summary>权限。对不同资源的权限,逗号分隔,每个资源的权限子项竖线分隔</summary>
|
||||
public const String Permission = "Permission";
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public const String Ex1 = "Ex1";
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public const String Ex2 = "Ex2";
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public const String Ex3 = "Ex3";
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public const String Ex4 = "Ex4";
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public const String Ex5 = "Ex5";
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public const String Ex6 = "Ex6";
|
||||
|
||||
/// <summary>创建者</summary>
|
||||
public const String CreateUser = "CreateUser";
|
||||
|
||||
/// <summary>创建用户</summary>
|
||||
public const String CreateUserID = "CreateUserID";
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public const String CreateIP = "CreateIP";
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public const String CreateTime = "CreateTime";
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public const String UpdateUser = "UpdateUser";
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public const String UpdateUserID = "UpdateUserID";
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public const String UpdateIP = "UpdateIP";
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public const String UpdateTime = "UpdateTime";
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public const String Remark = "Remark";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>访问统计</summary>
|
||||
public partial class VisitStat : Entity<VisitStat>
|
||||
{
|
||||
#region 对象操作
|
||||
static VisitStat()
|
||||
{
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(nameof(Level));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 这里验证参数范围,建议抛出参数异常,指定参数名,前端用户界面可以捕获参数异常并聚焦到对应的参数输入框
|
||||
if (Page.IsNullOrEmpty()) throw new ArgumentNullException(nameof(Page), "页面不能为空!");
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
//if (isNew && !Dirtys[nameof(CreateTime)]) CreateTime = DateTime.Now;
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
|
||||
// 检查唯一索引
|
||||
// CheckExist(isNew, nameof(Page), nameof(Level), nameof(Time));
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Session.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化VisitStat[访问统计]数据……");
|
||||
|
||||
// var entity = new VisitStat();
|
||||
// entity.Level = 0;
|
||||
// entity.Time = DateTime.Now;
|
||||
// entity.Page = "abc";
|
||||
// entity.Title = "abc";
|
||||
// entity.Times = 0;
|
||||
// entity.Users = 0;
|
||||
// entity.IPs = 0;
|
||||
// entity.Error = 0;
|
||||
// entity.Cost = 0;
|
||||
// entity.MaxCost = 0;
|
||||
// entity.CreateTime = DateTime.Now;
|
||||
// entity.UpdateTime = DateTime.Now;
|
||||
// entity.Remark = "abc";
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化VisitStat[访问统计]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static VisitStat FindByID(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
|
||||
|
||||
// 单对象缓存
|
||||
return Meta.SingleCache[id];
|
||||
|
||||
//return Find(_.ID == id);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
/// <summary>高级查询</summary>
|
||||
/// <param name="level">层级</param>
|
||||
/// <param name="page">页面</param>
|
||||
/// <param name="start">时间开始</param>
|
||||
/// <param name="end">时间结束</param>
|
||||
/// <param name="key">关键字</param>
|
||||
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<VisitStat> Search(Int32 level, String page, DateTime start, DateTime end, String key, PageParameter page)
|
||||
{
|
||||
var exp = new WhereExpression();
|
||||
|
||||
if (level >= 0) exp &= _.Level == level;
|
||||
if (!page.IsNullOrEmpty()) exp &= _.Page == page;
|
||||
exp &= _.Time.Between(start, end);
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Page.Contains(key) | _.Title.Contains(key) | _.Remark.Contains(key);
|
||||
|
||||
return FindAll(exp, page);
|
||||
}
|
||||
|
||||
// Select Count(ID) as ID,Page From VisitStat Where CreateTime>'2020-01-24 00:00:00' Group By Page Order By ID Desc limit 20
|
||||
static readonly FieldCache<VisitStat> _PageCache = new FieldCache<VisitStat>(nameof(Page))
|
||||
{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
};
|
||||
|
||||
/// <summary>获取页面列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
/// <returns></returns>
|
||||
public static IDictionary<String, String> GetPageList() => _PageCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>访问统计</summary>
|
||||
[Serializable]
|
||||
[DataObject]
|
||||
[Description("访问统计")]
|
||||
[BindIndex("IU_VisitStat_Page_Level_Time", true, "Page,Level,Time")]
|
||||
[BindIndex("IX_VisitStat_Level_Time", false, "Level,Time")]
|
||||
[BindTable("VisitStat", Description = "访问统计", ConnName = "Log", DbType = DatabaseType.None)]
|
||||
public partial class VisitStat
|
||||
{
|
||||
#region 属性
|
||||
private Int32 _ID;
|
||||
/// <summary>编号</summary>
|
||||
[DisplayName("编号")]
|
||||
[Description("编号")]
|
||||
[DataObjectField(true, true, false, 0)]
|
||||
[BindColumn("ID", "编号", "")]
|
||||
public Int32 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }
|
||||
|
||||
private XCode.Statistics.StatLevels _Level;
|
||||
/// <summary>层级</summary>
|
||||
[DisplayName("层级")]
|
||||
[Description("层级")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Level", "层级", "")]
|
||||
public XCode.Statistics.StatLevels Level { get => _Level; set { if (OnPropertyChanging("Level", value)) { _Level = value; OnPropertyChanged("Level"); } } }
|
||||
|
||||
private DateTime _Time;
|
||||
/// <summary>时间</summary>
|
||||
[DisplayName("时间")]
|
||||
[Description("时间")]
|
||||
[DataObjectField(false, false, true, 0)]
|
||||
[BindColumn("Time", "时间", "")]
|
||||
public DateTime Time { get => _Time; set { if (OnPropertyChanging("Time", value)) { _Time = value; OnPropertyChanged("Time"); } } }
|
||||
|
||||
private String _Page;
|
||||
/// <summary>页面</summary>
|
||||
[DisplayName("页面")]
|
||||
[Description("页面")]
|
||||
[DataObjectField(false, false, false, 50)]
|
||||
[BindColumn("Page", "页面", "")]
|
||||
public String Page { get => _Page; set { if (OnPropertyChanging("Page", value)) { _Page = value; OnPropertyChanged("Page"); } } }
|
||||
|
||||
private String _Title;
|
||||
/// <summary>标题</summary>
|
||||
[DisplayName("标题")]
|
||||
[Description("标题")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Title", "标题", "", Master = true)]
|
||||
public String Title { get => _Title; set { if (OnPropertyChanging("Title", value)) { _Title = value; OnPropertyChanged("Title"); } } }
|
||||
|
||||
private Int32 _Times;
|
||||
/// <summary>次数</summary>
|
||||
[DisplayName("次数")]
|
||||
[Description("次数")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Times", "次数", "")]
|
||||
public Int32 Times { get => _Times; set { if (OnPropertyChanging("Times", value)) { _Times = value; OnPropertyChanged("Times"); } } }
|
||||
|
||||
private Int32 _Users;
|
||||
/// <summary>用户</summary>
|
||||
[DisplayName("用户")]
|
||||
[Description("用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Users", "用户", "")]
|
||||
public Int32 Users { get => _Users; set { if (OnPropertyChanging("Users", value)) { _Users = value; OnPropertyChanged("Users"); } } }
|
||||
|
||||
private Int32 _IPs;
|
||||
/// <summary>IP</summary>
|
||||
[DisplayName("IP")]
|
||||
[Description("IP")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("IPs", "IP", "")]
|
||||
public Int32 IPs { get => _IPs; set { if (OnPropertyChanging("IPs", value)) { _IPs = value; OnPropertyChanged("IPs"); } } }
|
||||
|
||||
private Int32 _Error;
|
||||
/// <summary>错误</summary>
|
||||
[DisplayName("错误")]
|
||||
[Description("错误")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Error", "错误", "")]
|
||||
public Int32 Error { get => _Error; set { if (OnPropertyChanging("Error", value)) { _Error = value; OnPropertyChanged("Error"); } } }
|
||||
|
||||
private Int32 _Cost;
|
||||
/// <summary>耗时。毫秒</summary>
|
||||
[DisplayName("耗时")]
|
||||
[Description("耗时。毫秒")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Cost", "耗时。毫秒", "")]
|
||||
public Int32 Cost { get => _Cost; set { if (OnPropertyChanging("Cost", value)) { _Cost = value; OnPropertyChanged("Cost"); } } }
|
||||
|
||||
private Int32 _MaxCost;
|
||||
/// <summary>最大耗时。毫秒</summary>
|
||||
[DisplayName("最大耗时")]
|
||||
[Description("最大耗时。毫秒")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("MaxCost", "最大耗时。毫秒", "")]
|
||||
public Int32 MaxCost { get => _MaxCost; set { if (OnPropertyChanging("MaxCost", value)) { _MaxCost = value; OnPropertyChanged("MaxCost"); } } }
|
||||
|
||||
private DateTime _CreateTime;
|
||||
/// <summary>创建时间</summary>
|
||||
[DisplayName("创建时间")]
|
||||
[Description("创建时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateTime", "创建时间", "")]
|
||||
public DateTime CreateTime { get => _CreateTime; set { if (OnPropertyChanging("CreateTime", value)) { _CreateTime = value; OnPropertyChanged("CreateTime"); } } }
|
||||
|
||||
private DateTime _UpdateTime;
|
||||
/// <summary>更新时间</summary>
|
||||
[DisplayName("更新时间")]
|
||||
[Description("更新时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateTime", "更新时间", "")]
|
||||
public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }
|
||||
|
||||
private String _Remark;
|
||||
/// <summary>详细信息</summary>
|
||||
[DisplayName("详细信息")]
|
||||
[Description("详细信息")]
|
||||
[DataObjectField(false, false, true, 5000)]
|
||||
[BindColumn("Remark", "详细信息", "")]
|
||||
public String Remark { get => _Remark; set { if (OnPropertyChanging("Remark", value)) { _Remark = value; OnPropertyChanged("Remark"); } } }
|
||||
#endregion
|
||||
|
||||
#region 获取/设置 字段值
|
||||
/// <summary>获取/设置 字段值</summary>
|
||||
/// <param name="name">字段名</param>
|
||||
/// <returns></returns>
|
||||
public override Object this[String name]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": return _ID;
|
||||
case "Level": return _Level;
|
||||
case "Time": return _Time;
|
||||
case "Page": return _Page;
|
||||
case "Title": return _Title;
|
||||
case "Times": return _Times;
|
||||
case "Users": return _Users;
|
||||
case "IPs": return _IPs;
|
||||
case "Error": return _Error;
|
||||
case "Cost": return _Cost;
|
||||
case "MaxCost": return _MaxCost;
|
||||
case "CreateTime": return _CreateTime;
|
||||
case "UpdateTime": return _UpdateTime;
|
||||
case "Remark": return _Remark;
|
||||
default: return base[name];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": _ID = value.ToInt(); break;
|
||||
case "Level": _Level = (XCode.Statistics.StatLevels)value.ToInt(); break;
|
||||
case "Time": _Time = value.ToDateTime(); break;
|
||||
case "Page": _Page = Convert.ToString(value); break;
|
||||
case "Title": _Title = Convert.ToString(value); break;
|
||||
case "Times": _Times = value.ToInt(); break;
|
||||
case "Users": _Users = value.ToInt(); break;
|
||||
case "IPs": _IPs = value.ToInt(); break;
|
||||
case "Error": _Error = value.ToInt(); break;
|
||||
case "Cost": _Cost = value.ToInt(); break;
|
||||
case "MaxCost": _MaxCost = value.ToInt(); break;
|
||||
case "CreateTime": _CreateTime = value.ToDateTime(); break;
|
||||
case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
|
||||
case "Remark": _Remark = Convert.ToString(value); break;
|
||||
default: base[name] = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字段名
|
||||
/// <summary>取得访问统计字段信息的快捷方式</summary>
|
||||
public partial class _
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public static readonly Field ID = FindByName("ID");
|
||||
|
||||
/// <summary>层级</summary>
|
||||
public static readonly Field Level = FindByName("Level");
|
||||
|
||||
/// <summary>时间</summary>
|
||||
public static readonly Field Time = FindByName("Time");
|
||||
|
||||
/// <summary>页面</summary>
|
||||
public static readonly Field Page = FindByName("Page");
|
||||
|
||||
/// <summary>标题</summary>
|
||||
public static readonly Field Title = FindByName("Title");
|
||||
|
||||
/// <summary>次数</summary>
|
||||
public static readonly Field Times = FindByName("Times");
|
||||
|
||||
/// <summary>用户</summary>
|
||||
public static readonly Field Users = FindByName("Users");
|
||||
|
||||
/// <summary>IP</summary>
|
||||
public static readonly Field IPs = FindByName("IPs");
|
||||
|
||||
/// <summary>错误</summary>
|
||||
public static readonly Field Error = FindByName("Error");
|
||||
|
||||
/// <summary>耗时。毫秒</summary>
|
||||
public static readonly Field Cost = FindByName("Cost");
|
||||
|
||||
/// <summary>最大耗时。毫秒</summary>
|
||||
public static readonly Field MaxCost = FindByName("MaxCost");
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public static readonly Field CreateTime = FindByName("CreateTime");
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public static readonly Field UpdateTime = FindByName("UpdateTime");
|
||||
|
||||
/// <summary>详细信息</summary>
|
||||
public static readonly Field Remark = FindByName("Remark");
|
||||
|
||||
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||
}
|
||||
|
||||
/// <summary>取得访问统计字段名称的快捷方式</summary>
|
||||
public partial class __
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public const String ID = "ID";
|
||||
|
||||
/// <summary>层级</summary>
|
||||
public const String Level = "Level";
|
||||
|
||||
/// <summary>时间</summary>
|
||||
public const String Time = "Time";
|
||||
|
||||
/// <summary>页面</summary>
|
||||
public const String Page = "Page";
|
||||
|
||||
/// <summary>标题</summary>
|
||||
public const String Title = "Title";
|
||||
|
||||
/// <summary>次数</summary>
|
||||
public const String Times = "Times";
|
||||
|
||||
/// <summary>用户</summary>
|
||||
public const String Users = "Users";
|
||||
|
||||
/// <summary>IP</summary>
|
||||
public const String IPs = "IPs";
|
||||
|
||||
/// <summary>错误</summary>
|
||||
public const String Error = "Error";
|
||||
|
||||
/// <summary>耗时。毫秒</summary>
|
||||
public const String Cost = "Cost";
|
||||
|
||||
/// <summary>最大耗时。毫秒</summary>
|
||||
public const String MaxCost = "MaxCost";
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public const String CreateTime = "CreateTime";
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public const String UpdateTime = "UpdateTime";
|
||||
|
||||
/// <summary>详细信息</summary>
|
||||
public const String Remark = "Remark";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>部门。组织机构,多级树状结构</summary>
|
||||
public partial class Department : Entity<Department>
|
||||
{
|
||||
#region 对象操作
|
||||
static Department()
|
||||
{
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(nameof(ParentID));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<UserModule>();
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Modules.Add<IPModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 这里验证参数范围,建议抛出参数异常,指定参数名,前端用户界面可以捕获参数异常并聚焦到对应的参数输入框
|
||||
if (Name.IsNullOrEmpty()) throw new ArgumentNullException(nameof(Name), "名称不能为空!");
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 处理当前已登录用户信息,可以由UserModule过滤器代劳
|
||||
/*var user = ManageProvider.User;
|
||||
if (user != null)
|
||||
{
|
||||
if (isNew && !Dirtys[nameof(CreateUserID)]) CreateUserID = user.ID;
|
||||
if (!Dirtys[nameof(UpdateUserID)]) UpdateUserID = user.ID;
|
||||
}*/
|
||||
//if (isNew && !Dirtys[nameof(CreateTime)]) CreateTime = DateTime.Now;
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
//if (isNew && !Dirtys[nameof(CreateIP)]) CreateIP = ManageProvider.UserHost;
|
||||
//if (!Dirtys[nameof(UpdateIP)]) UpdateIP = ManageProvider.UserHost;
|
||||
|
||||
// 检查唯一索引
|
||||
// CheckExist(isNew, nameof(ParentID), nameof(Name));
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Session.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Department[部门]数据……");
|
||||
|
||||
// var entity = new Department();
|
||||
// entity.Code = "abc";
|
||||
// entity.Name = "abc";
|
||||
// entity.FullName = "abc";
|
||||
// entity.ParentID = 0;
|
||||
// entity.Level = 0;
|
||||
// entity.Sort = 0;
|
||||
// entity.Enable = true;
|
||||
// entity.Visible = true;
|
||||
// entity.ManagerID = 0;
|
||||
// entity.Ex1 = 0;
|
||||
// entity.Ex2 = 0;
|
||||
// entity.Ex3 = 0.0;
|
||||
// entity.Ex4 = "abc";
|
||||
// entity.Ex5 = "abc";
|
||||
// entity.Ex6 = "abc";
|
||||
// entity.CreateUser = "abc";
|
||||
// entity.CreateUserID = 0;
|
||||
// entity.CreateIP = "abc";
|
||||
// entity.CreateTime = DateTime.Now;
|
||||
// entity.UpdateUser = "abc";
|
||||
// entity.UpdateUserID = 0;
|
||||
// entity.UpdateIP = "abc";
|
||||
// entity.UpdateTime = DateTime.Now;
|
||||
// entity.Remark = "abc";
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化Department[部门]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static Department FindByID(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
|
||||
|
||||
// 单对象缓存
|
||||
return Meta.SingleCache[id];
|
||||
|
||||
//return Find(_.ID == id);
|
||||
}
|
||||
|
||||
/// <summary>根据名称查找</summary>
|
||||
/// <param name="name">名称</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Department> FindAllByName(String name)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Name.EqualIgnoreCase(name));
|
||||
|
||||
return FindAll(_.Name == name);
|
||||
}
|
||||
|
||||
/// <summary>根据父级、名称查找</summary>
|
||||
/// <param name="parentId">父级</param>
|
||||
/// <param name="name">名称</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static Department FindByParentIDAndName(Int32 parentId, String name)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ParentID == parentId && e.Name.EqualIgnoreCase(name));
|
||||
|
||||
return Find(_.ParentID == parentId & _.Name == name);
|
||||
}
|
||||
|
||||
/// <summary>根据代码查找</summary>
|
||||
/// <param name="code">代码</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Department> FindAllByCode(String code)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.Code.EqualIgnoreCase(code));
|
||||
|
||||
return FindAll(_.Code == code);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
/// <summary>高级查询</summary>
|
||||
/// <param name="code">代码</param>
|
||||
/// <param name="name">名称</param>
|
||||
/// <param name="parentId">父级</param>
|
||||
/// <param name="start">更新时间开始</param>
|
||||
/// <param name="end">更新时间结束</param>
|
||||
/// <param name="key">关键字</param>
|
||||
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||
/// <returns>实体列表</returns>
|
||||
public static IList<Department> Search(String code, String name, Int32 parentId, DateTime start, DateTime end, String key, PageParameter page)
|
||||
{
|
||||
var exp = new WhereExpression();
|
||||
|
||||
if (!code.IsNullOrEmpty()) exp &= _.Code == code;
|
||||
if (!name.IsNullOrEmpty()) exp &= _.Name == name;
|
||||
if (parentId >= 0) exp &= _.ParentID == parentId;
|
||||
exp &= _.UpdateTime.Between(start, end);
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Code.Contains(key) | _.Name.Contains(key) | _.FullName.Contains(key) | _.Ex4.Contains(key) | _.Ex5.Contains(key) | _.Ex6.Contains(key) | _.CreateUser.Contains(key) | _.CreateIP.Contains(key) | _.UpdateUser.Contains(key) | _.UpdateIP.Contains(key) | _.Remark.Contains(key);
|
||||
|
||||
return FindAll(exp, page);
|
||||
}
|
||||
|
||||
// Select Count(ID) as ID,Code From Department Where CreateTime>'2020-01-24 00:00:00' Group By Code Order By ID Desc limit 20
|
||||
static readonly FieldCache<Department> _CodeCache = new FieldCache<Department>(nameof(Code))
|
||||
{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
};
|
||||
|
||||
/// <summary>获取代码列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
/// <returns></returns>
|
||||
public static IDictionary<String, String> GetCodeList() => _CodeCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
|
||||
namespace XCode.Membership
|
||||
{
|
||||
/// <summary>部门。组织机构,多级树状结构</summary>
|
||||
[Serializable]
|
||||
[DataObject]
|
||||
[Description("部门。组织机构,多级树状结构")]
|
||||
[BindIndex("IX_Department_Name", false, "Name")]
|
||||
[BindIndex("IU_Department_ParentID_Name", true, "ParentID,Name")]
|
||||
[BindIndex("IX_Department_Code", false, "Code")]
|
||||
[BindIndex("IX_Department_UpdateTime", false, "UpdateTime")]
|
||||
[BindTable("Department", Description = "部门。组织机构,多级树状结构", ConnName = "Membership", DbType = DatabaseType.None)]
|
||||
public partial class Department
|
||||
{
|
||||
#region 属性
|
||||
private Int32 _ID;
|
||||
/// <summary>编号</summary>
|
||||
[DisplayName("编号")]
|
||||
[Description("编号")]
|
||||
[DataObjectField(true, true, false, 0)]
|
||||
[BindColumn("ID", "编号", "")]
|
||||
public Int32 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }
|
||||
|
||||
private String _Code;
|
||||
/// <summary>代码</summary>
|
||||
[DisplayName("代码")]
|
||||
[Description("代码")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Code", "代码", "")]
|
||||
public String Code { get => _Code; set { if (OnPropertyChanging("Code", value)) { _Code = value; OnPropertyChanged("Code"); } } }
|
||||
|
||||
private String _Name;
|
||||
/// <summary>名称</summary>
|
||||
[DisplayName("名称")]
|
||||
[Description("名称")]
|
||||
[DataObjectField(false, false, false, 50)]
|
||||
[BindColumn("Name", "名称", "", Master = true)]
|
||||
public String Name { get => _Name; set { if (OnPropertyChanging("Name", value)) { _Name = value; OnPropertyChanged("Name"); } } }
|
||||
|
||||
private String _FullName;
|
||||
/// <summary>全名</summary>
|
||||
[DisplayName("全名")]
|
||||
[Description("全名")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("FullName", "全名", "")]
|
||||
public String FullName { get => _FullName; set { if (OnPropertyChanging("FullName", value)) { _FullName = value; OnPropertyChanged("FullName"); } } }
|
||||
|
||||
private Int32 _ParentID;
|
||||
/// <summary>父级</summary>
|
||||
[DisplayName("父级")]
|
||||
[Description("父级")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("ParentID", "父级", "")]
|
||||
public Int32 ParentID { get => _ParentID; set { if (OnPropertyChanging("ParentID", value)) { _ParentID = value; OnPropertyChanged("ParentID"); } } }
|
||||
|
||||
private Int32 _Level;
|
||||
/// <summary>层级。树状结构的层级</summary>
|
||||
[DisplayName("层级")]
|
||||
[Description("层级。树状结构的层级")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Level", "层级。树状结构的层级", "")]
|
||||
public Int32 Level { get => _Level; set { if (OnPropertyChanging("Level", value)) { _Level = value; OnPropertyChanged("Level"); } } }
|
||||
|
||||
private Int32 _Sort;
|
||||
/// <summary>排序。同级内排序</summary>
|
||||
[DisplayName("排序")]
|
||||
[Description("排序。同级内排序")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Sort", "排序。同级内排序", "")]
|
||||
public Int32 Sort { get => _Sort; set { if (OnPropertyChanging("Sort", value)) { _Sort = value; OnPropertyChanged("Sort"); } } }
|
||||
|
||||
private Boolean _Enable;
|
||||
/// <summary>启用</summary>
|
||||
[DisplayName("启用")]
|
||||
[Description("启用")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Enable", "启用", "")]
|
||||
public Boolean Enable { get => _Enable; set { if (OnPropertyChanging("Enable", value)) { _Enable = value; OnPropertyChanged("Enable"); } } }
|
||||
|
||||
private Boolean _Visible;
|
||||
/// <summary>可见</summary>
|
||||
[DisplayName("可见")]
|
||||
[Description("可见")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Visible", "可见", "")]
|
||||
public Boolean Visible { get => _Visible; set { if (OnPropertyChanging("Visible", value)) { _Visible = value; OnPropertyChanged("Visible"); } } }
|
||||
|
||||
private Int32 _ManagerID;
|
||||
/// <summary>管理者</summary>
|
||||
[DisplayName("管理者")]
|
||||
[Description("管理者")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("ManagerID", "管理者", "")]
|
||||
public Int32 ManagerID { get => _ManagerID; set { if (OnPropertyChanging("ManagerID", value)) { _ManagerID = value; OnPropertyChanged("ManagerID"); } } }
|
||||
|
||||
private Int32 _Ex1;
|
||||
/// <summary>扩展1</summary>
|
||||
[DisplayName("扩展1")]
|
||||
[Description("扩展1")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex1", "扩展1", "")]
|
||||
public Int32 Ex1 { get => _Ex1; set { if (OnPropertyChanging("Ex1", value)) { _Ex1 = value; OnPropertyChanged("Ex1"); } } }
|
||||
|
||||
private Int32 _Ex2;
|
||||
/// <summary>扩展2</summary>
|
||||
[DisplayName("扩展2")]
|
||||
[Description("扩展2")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex2", "扩展2", "")]
|
||||
public Int32 Ex2 { get => _Ex2; set { if (OnPropertyChanging("Ex2", value)) { _Ex2 = value; OnPropertyChanged("Ex2"); } } }
|
||||
|
||||
private Double _Ex3;
|
||||
/// <summary>扩展3</summary>
|
||||
[DisplayName("扩展3")]
|
||||
[Description("扩展3")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("Ex3", "扩展3", "")]
|
||||
public Double Ex3 { get => _Ex3; set { if (OnPropertyChanging("Ex3", value)) { _Ex3 = value; OnPropertyChanged("Ex3"); } } }
|
||||
|
||||
private String _Ex4;
|
||||
/// <summary>扩展4</summary>
|
||||
[DisplayName("扩展4")]
|
||||
[Description("扩展4")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex4", "扩展4", "")]
|
||||
public String Ex4 { get => _Ex4; set { if (OnPropertyChanging("Ex4", value)) { _Ex4 = value; OnPropertyChanged("Ex4"); } } }
|
||||
|
||||
private String _Ex5;
|
||||
/// <summary>扩展5</summary>
|
||||
[DisplayName("扩展5")]
|
||||
[Description("扩展5")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex5", "扩展5", "")]
|
||||
public String Ex5 { get => _Ex5; set { if (OnPropertyChanging("Ex5", value)) { _Ex5 = value; OnPropertyChanged("Ex5"); } } }
|
||||
|
||||
private String _Ex6;
|
||||
/// <summary>扩展6</summary>
|
||||
[DisplayName("扩展6")]
|
||||
[Description("扩展6")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Ex6", "扩展6", "")]
|
||||
public String Ex6 { get => _Ex6; set { if (OnPropertyChanging("Ex6", value)) { _Ex6 = value; OnPropertyChanged("Ex6"); } } }
|
||||
|
||||
private String _CreateUser;
|
||||
/// <summary>创建者</summary>
|
||||
[DisplayName("创建者")]
|
||||
[Description("创建者")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("CreateUser", "创建者", "")]
|
||||
public String CreateUser { get => _CreateUser; set { if (OnPropertyChanging("CreateUser", value)) { _CreateUser = value; OnPropertyChanged("CreateUser"); } } }
|
||||
|
||||
private Int32 _CreateUserID;
|
||||
/// <summary>创建用户</summary>
|
||||
[DisplayName("创建用户")]
|
||||
[Description("创建用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateUserID", "创建用户", "")]
|
||||
public Int32 CreateUserID { get => _CreateUserID; set { if (OnPropertyChanging("CreateUserID", value)) { _CreateUserID = value; OnPropertyChanged("CreateUserID"); } } }
|
||||
|
||||
private String _CreateIP;
|
||||
/// <summary>创建地址</summary>
|
||||
[DisplayName("创建地址")]
|
||||
[Description("创建地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("CreateIP", "创建地址", "")]
|
||||
public String CreateIP { get => _CreateIP; set { if (OnPropertyChanging("CreateIP", value)) { _CreateIP = value; OnPropertyChanged("CreateIP"); } } }
|
||||
|
||||
private DateTime _CreateTime;
|
||||
/// <summary>创建时间</summary>
|
||||
[DisplayName("创建时间")]
|
||||
[Description("创建时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("CreateTime", "创建时间", "")]
|
||||
public DateTime CreateTime { get => _CreateTime; set { if (OnPropertyChanging("CreateTime", value)) { _CreateTime = value; OnPropertyChanged("CreateTime"); } } }
|
||||
|
||||
private String _UpdateUser;
|
||||
/// <summary>更新者</summary>
|
||||
[DisplayName("更新者")]
|
||||
[Description("更新者")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateUser", "更新者", "")]
|
||||
public String UpdateUser { get => _UpdateUser; set { if (OnPropertyChanging("UpdateUser", value)) { _UpdateUser = value; OnPropertyChanged("UpdateUser"); } } }
|
||||
|
||||
private Int32 _UpdateUserID;
|
||||
/// <summary>更新用户</summary>
|
||||
[DisplayName("更新用户")]
|
||||
[Description("更新用户")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateUserID", "更新用户", "")]
|
||||
public Int32 UpdateUserID { get => _UpdateUserID; set { if (OnPropertyChanging("UpdateUserID", value)) { _UpdateUserID = value; OnPropertyChanged("UpdateUserID"); } } }
|
||||
|
||||
private String _UpdateIP;
|
||||
/// <summary>更新地址</summary>
|
||||
[DisplayName("更新地址")]
|
||||
[Description("更新地址")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("UpdateIP", "更新地址", "")]
|
||||
public String UpdateIP { get => _UpdateIP; set { if (OnPropertyChanging("UpdateIP", value)) { _UpdateIP = value; OnPropertyChanged("UpdateIP"); } } }
|
||||
|
||||
private DateTime _UpdateTime;
|
||||
/// <summary>更新时间</summary>
|
||||
[DisplayName("更新时间")]
|
||||
[Description("更新时间")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UpdateTime", "更新时间", "")]
|
||||
public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }
|
||||
|
||||
private String _Remark;
|
||||
/// <summary>备注</summary>
|
||||
[DisplayName("备注")]
|
||||
[Description("备注")]
|
||||
[DataObjectField(false, false, true, 200)]
|
||||
[BindColumn("Remark", "备注", "")]
|
||||
public String Remark { get => _Remark; set { if (OnPropertyChanging("Remark", value)) { _Remark = value; OnPropertyChanged("Remark"); } } }
|
||||
#endregion
|
||||
|
||||
#region 获取/设置 字段值
|
||||
/// <summary>获取/设置 字段值</summary>
|
||||
/// <param name="name">字段名</param>
|
||||
/// <returns></returns>
|
||||
public override Object this[String name]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": return _ID;
|
||||
case "Code": return _Code;
|
||||
case "Name": return _Name;
|
||||
case "FullName": return _FullName;
|
||||
case "ParentID": return _ParentID;
|
||||
case "Level": return _Level;
|
||||
case "Sort": return _Sort;
|
||||
case "Enable": return _Enable;
|
||||
case "Visible": return _Visible;
|
||||
case "ManagerID": return _ManagerID;
|
||||
case "Ex1": return _Ex1;
|
||||
case "Ex2": return _Ex2;
|
||||
case "Ex3": return _Ex3;
|
||||
case "Ex4": return _Ex4;
|
||||
case "Ex5": return _Ex5;
|
||||
case "Ex6": return _Ex6;
|
||||
case "CreateUser": return _CreateUser;
|
||||
case "CreateUserID": return _CreateUserID;
|
||||
case "CreateIP": return _CreateIP;
|
||||
case "CreateTime": return _CreateTime;
|
||||
case "UpdateUser": return _UpdateUser;
|
||||
case "UpdateUserID": return _UpdateUserID;
|
||||
case "UpdateIP": return _UpdateIP;
|
||||
case "UpdateTime": return _UpdateTime;
|
||||
case "Remark": return _Remark;
|
||||
default: return base[name];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "ID": _ID = value.ToInt(); break;
|
||||
case "Code": _Code = Convert.ToString(value); break;
|
||||
case "Name": _Name = Convert.ToString(value); break;
|
||||
case "FullName": _FullName = Convert.ToString(value); break;
|
||||
case "ParentID": _ParentID = value.ToInt(); break;
|
||||
case "Level": _Level = value.ToInt(); break;
|
||||
case "Sort": _Sort = value.ToInt(); break;
|
||||
case "Enable": _Enable = value.ToBoolean(); break;
|
||||
case "Visible": _Visible = value.ToBoolean(); break;
|
||||
case "ManagerID": _ManagerID = value.ToInt(); break;
|
||||
case "Ex1": _Ex1 = value.ToInt(); break;
|
||||
case "Ex2": _Ex2 = value.ToInt(); break;
|
||||
case "Ex3": _Ex3 = value.ToDouble(); break;
|
||||
case "Ex4": _Ex4 = Convert.ToString(value); break;
|
||||
case "Ex5": _Ex5 = Convert.ToString(value); break;
|
||||
case "Ex6": _Ex6 = Convert.ToString(value); break;
|
||||
case "CreateUser": _CreateUser = Convert.ToString(value); break;
|
||||
case "CreateUserID": _CreateUserID = value.ToInt(); break;
|
||||
case "CreateIP": _CreateIP = Convert.ToString(value); break;
|
||||
case "CreateTime": _CreateTime = value.ToDateTime(); break;
|
||||
case "UpdateUser": _UpdateUser = Convert.ToString(value); break;
|
||||
case "UpdateUserID": _UpdateUserID = value.ToInt(); break;
|
||||
case "UpdateIP": _UpdateIP = Convert.ToString(value); break;
|
||||
case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
|
||||
case "Remark": _Remark = Convert.ToString(value); break;
|
||||
default: base[name] = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字段名
|
||||
/// <summary>取得部门字段信息的快捷方式</summary>
|
||||
public partial class _
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public static readonly Field ID = FindByName("ID");
|
||||
|
||||
/// <summary>代码</summary>
|
||||
public static readonly Field Code = FindByName("Code");
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public static readonly Field Name = FindByName("Name");
|
||||
|
||||
/// <summary>全名</summary>
|
||||
public static readonly Field FullName = FindByName("FullName");
|
||||
|
||||
/// <summary>父级</summary>
|
||||
public static readonly Field ParentID = FindByName("ParentID");
|
||||
|
||||
/// <summary>层级。树状结构的层级</summary>
|
||||
public static readonly Field Level = FindByName("Level");
|
||||
|
||||
/// <summary>排序。同级内排序</summary>
|
||||
public static readonly Field Sort = FindByName("Sort");
|
||||
|
||||
/// <summary>启用</summary>
|
||||
public static readonly Field Enable = FindByName("Enable");
|
||||
|
||||
/// <summary>可见</summary>
|
||||
public static readonly Field Visible = FindByName("Visible");
|
||||
|
||||
/// <summary>管理者</summary>
|
||||
public static readonly Field ManagerID = FindByName("ManagerID");
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public static readonly Field Ex1 = FindByName("Ex1");
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public static readonly Field Ex2 = FindByName("Ex2");
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public static readonly Field Ex3 = FindByName("Ex3");
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public static readonly Field Ex4 = FindByName("Ex4");
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public static readonly Field Ex5 = FindByName("Ex5");
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public static readonly Field Ex6 = FindByName("Ex6");
|
||||
|
||||
/// <summary>创建者</summary>
|
||||
public static readonly Field CreateUser = FindByName("CreateUser");
|
||||
|
||||
/// <summary>创建用户</summary>
|
||||
public static readonly Field CreateUserID = FindByName("CreateUserID");
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public static readonly Field CreateIP = FindByName("CreateIP");
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public static readonly Field CreateTime = FindByName("CreateTime");
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public static readonly Field UpdateUser = FindByName("UpdateUser");
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public static readonly Field UpdateUserID = FindByName("UpdateUserID");
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public static readonly Field UpdateIP = FindByName("UpdateIP");
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public static readonly Field UpdateTime = FindByName("UpdateTime");
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public static readonly Field Remark = FindByName("Remark");
|
||||
|
||||
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||
}
|
||||
|
||||
/// <summary>取得部门字段名称的快捷方式</summary>
|
||||
public partial class __
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public const String ID = "ID";
|
||||
|
||||
/// <summary>代码</summary>
|
||||
public const String Code = "Code";
|
||||
|
||||
/// <summary>名称</summary>
|
||||
public const String Name = "Name";
|
||||
|
||||
/// <summary>全名</summary>
|
||||
public const String FullName = "FullName";
|
||||
|
||||
/// <summary>父级</summary>
|
||||
public const String ParentID = "ParentID";
|
||||
|
||||
/// <summary>层级。树状结构的层级</summary>
|
||||
public const String Level = "Level";
|
||||
|
||||
/// <summary>排序。同级内排序</summary>
|
||||
public const String Sort = "Sort";
|
||||
|
||||
/// <summary>启用</summary>
|
||||
public const String Enable = "Enable";
|
||||
|
||||
/// <summary>可见</summary>
|
||||
public const String Visible = "Visible";
|
||||
|
||||
/// <summary>管理者</summary>
|
||||
public const String ManagerID = "ManagerID";
|
||||
|
||||
/// <summary>扩展1</summary>
|
||||
public const String Ex1 = "Ex1";
|
||||
|
||||
/// <summary>扩展2</summary>
|
||||
public const String Ex2 = "Ex2";
|
||||
|
||||
/// <summary>扩展3</summary>
|
||||
public const String Ex3 = "Ex3";
|
||||
|
||||
/// <summary>扩展4</summary>
|
||||
public const String Ex4 = "Ex4";
|
||||
|
||||
/// <summary>扩展5</summary>
|
||||
public const String Ex5 = "Ex5";
|
||||
|
||||
/// <summary>扩展6</summary>
|
||||
public const String Ex6 = "Ex6";
|
||||
|
||||
/// <summary>创建者</summary>
|
||||
public const String CreateUser = "CreateUser";
|
||||
|
||||
/// <summary>创建用户</summary>
|
||||
public const String CreateUserID = "CreateUserID";
|
||||
|
||||
/// <summary>创建地址</summary>
|
||||
public const String CreateIP = "CreateIP";
|
||||
|
||||
/// <summary>创建时间</summary>
|
||||
public const String CreateTime = "CreateTime";
|
||||
|
||||
/// <summary>更新者</summary>
|
||||
public const String UpdateUser = "UpdateUser";
|
||||
|
||||
/// <summary>更新用户</summary>
|
||||
public const String UpdateUserID = "UpdateUserID";
|
||||
|
||||
/// <summary>更新地址</summary>
|
||||
public const String UpdateIP = "UpdateIP";
|
||||
|
||||
/// <summary>更新时间</summary>
|
||||
public const String UpdateTime = "UpdateTime";
|
||||
|
||||
/// <summary>备注</summary>
|
||||
public const String Remark = "Remark";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,21 @@
|
||||
<#@ template language="C#" hostSpecific="true" debug="true" #>
|
||||
<#@ assembly name="netstandard" #>
|
||||
<#@ assembly name="$(ProjectDir)\$(OutputPath)\NewLife.Core.dll" #>
|
||||
<#@ assembly name="$(ProjectDir)\$(OutputPath)\XCode.dll" #>
|
||||
<#@ assembly name="$(ProjectDir)\..\DLL\NewLife.Core.dll" #>
|
||||
<#@ assembly name="$(ProjectDir)\..\DLL\XCode.dll" #>
|
||||
<#@ import namespace="System.Diagnostics" #>
|
||||
<#@ import namespace="System.IO" #>
|
||||
<#@ import namespace="XCode.Code" #>
|
||||
<#@ import namespace="XCode.DataAccessLayer" #>
|
||||
<#@ output extension=".log" #>
|
||||
<#
|
||||
// 设置当前工作目录
|
||||
PathHelper.BasePath = Host.ResolvePath(".");
|
||||
|
||||
// 设置如何格式化字段名,默认去掉下划线并转驼峰命名
|
||||
//ModelResolver.Current = new ModelResolver { TrimUnderline = false, Camel = false };
|
||||
|
||||
// 加载模型文件,得到数据表
|
||||
var option = new BuilderOption();
|
||||
var tables = ClassBuilder.LoadModels(null, option, out var atts);
|
||||
var tables = ClassBuilder.LoadModels("data.project.xml", option, out var atts);
|
||||
EntityBuilder.FixModelFile(null, option, atts, tables);
|
||||
|
||||
|
||||
// 生成实体类
|
||||
//option.BaseClass = "I{name}";
|
||||
//option.ModelNameForCopy = "I{name}";
|
||||
@@ -35,16 +32,4 @@
|
||||
option.ClassNameTemplate = null;
|
||||
option.Output = @"Output\EntityInterfaces\";
|
||||
//ClassBuilder.BuildInterfaces(tables, option);
|
||||
|
||||
// 精确控制生成
|
||||
/*foreach (var item in tables)
|
||||
{
|
||||
var builder = new ClassBuilder
|
||||
{
|
||||
Table = item,
|
||||
Option = option.Clone(),
|
||||
};
|
||||
builder.Execute();
|
||||
builder.Save(null, true, false);
|
||||
}*/
|
||||
#>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Tables Version="9.16.7426.38239" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://www.newlifex.com http://www.newlifex.com/Model2020.xsd" NameSpace="XCode.Membership" ConnName="Membership" Output="" BaseClass="Entity" ChineseFileName="True" IgnoreNameCase="True" xmlns="http://www.newlifex.com/Model2020.xsd">
|
||||
<Tables xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://www.newlifex.com http://www.newlifex.com/Model2020.xsd" NameSpace="XCode.Membership" ConnName="Membership" Output=".\Entity\Membership" BaseClass="Entity" xmlns="http://www.newlifex.com/Model2020.xsd">
|
||||
<Table Name="User" Description="用户">
|
||||
<Columns>
|
||||
<Column Name="ID" DataType="Int32" Identity="True" PrimaryKey="True" Description="编号" />
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("XCoder")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("XCoder")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("71539325-194b-4d56-8d88-562b33004406")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,89 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{71539325-194B-4D56-8D88-562B33004406}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>XCoder</RootNamespace>
|
||||
<AssemblyName>XCoder</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="NewLife.Core, Version=8.11.7983.14989, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NewLife.Core.8.11.2021.1109\lib\net46\NewLife.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="XCode, Version=10.3.7983.14994, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NewLife.XCode.10.3.2021.1109\lib\net45\XCode.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Entity\Build.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Build.log</LastGenOutput>
|
||||
</Content>
|
||||
<Content Include="Entity\Build_netcore.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Build_netcore.log</LastGenOutput>
|
||||
</Content>
|
||||
<Content Include="Entity\data.project.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Entity\Model.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Entity\Build.log">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Build.tt</DependentUpon>
|
||||
</None>
|
||||
<None Include="Entity\Build_netcore.log">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Build_netcore.tt</DependentUpon>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Model.log">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Model.tt</DependentUpon>
|
||||
</None>
|
||||
<None Update="Model.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>Model.log</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -22,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -61,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Tags[Tag标签]数据……");
|
||||
|
||||
// var entity = new Tags();
|
||||
// entity.Id = 0;
|
||||
// entity.TagName = "abc";
|
||||
// entity.Keywords = "abc";
|
||||
// entity.Description = "abc";
|
||||
@@ -115,7 +115,7 @@ namespace COMCMS.Core
|
||||
public static IList<Tags> FindAllByTagName(String tagName)
|
||||
{
|
||||
// 实体缓存
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.TagName == tagName);
|
||||
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.TagName.EqualIgnoreCase(tagName));
|
||||
|
||||
return FindAll(_.TagName == tagName);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ namespace COMCMS.Core
|
||||
var exp = new WhereExpression();
|
||||
|
||||
if (!tagName.IsNullOrEmpty()) exp &= _.TagName == tagName;
|
||||
if (!key.IsNullOrEmpty()) exp &= _.Keywords.Contains(key) | _.Description.Contains(key);
|
||||
if (!key.IsNullOrEmpty()) exp &= _.TagName.Contains(key) | _.Keywords.Contains(key) | _.Description.Contains(key);
|
||||
|
||||
return FindAll(exp, page);
|
||||
}
|
||||
@@ -22,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -61,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化TagsDetail[Tag标签详情]数据……");
|
||||
|
||||
// var entity = new TagsDetail();
|
||||
// entity.Id = 0;
|
||||
// entity.TagsId = 0;
|
||||
// entity.TagName = "abc";
|
||||
// entity.TypeId = 0;
|
||||
@@ -95,12 +95,6 @@ namespace COMCMS.Core
|
||||
//[ScriptIgnore]
|
||||
public Tags Tags => Extends.Get(nameof(Tags), k => Tags.FindById(TagsId));
|
||||
|
||||
/// <summary>所属标签ID</summary>
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("所属标签ID")]
|
||||
[Map(nameof(TagsId), typeof(Tags), "Id")]
|
||||
public Int32 TagsId => Tags != null ? Tags.Id : 0;
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static Coupon()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.KId);
|
||||
//df.Add(nameof(KId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
DiscuountRates = Math.Round(DiscuountRates, 6);
|
||||
@@ -60,7 +66,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Coupon[优惠券]数据……");
|
||||
|
||||
// var entity = new Coupon();
|
||||
// entity.Id = 0;
|
||||
// entity.ItemNO = "abc";
|
||||
// entity.KId = 0;
|
||||
// entity.CouponType = 0;
|
||||
@@ -118,6 +123,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From Coupon Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<Coupon> _CategoryCache = new FieldCache<Coupon>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static CouponUseLog()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.UId);
|
||||
//df.Add(nameof(UId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化CouponUseLog[优惠券使用记录]数据……");
|
||||
|
||||
// var entity = new CouponUseLog();
|
||||
// entity.Id = 0;
|
||||
// entity.UId = 0;
|
||||
// entity.CouponId = 0;
|
||||
// entity.ItemNO = "abc";
|
||||
@@ -89,27 +94,15 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>优惠券ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Coupon Coupon { get { return Extends.Get(nameof(Coupon), k => Coupon.FindById(CouponId)); } }
|
||||
|
||||
/// <summary>优惠券ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("优惠券ID")]
|
||||
[Map(__.CouponId, typeof(Coupon), "Id")]
|
||||
public Int32 CouponId { get { return Coupon != null ? Coupon.Id : 0; } }
|
||||
/// <summary>订单编号</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
public Order Order { get { return Extends.Get(nameof(Order), k => Order.FindById(OrderId)); } }
|
||||
public Coupon Coupon => Extends.Get(nameof(Coupon), k => Coupon.FindById(CouponId));
|
||||
|
||||
/// <summary>订单编号</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("订单编号")]
|
||||
[Map(__.OrderId, typeof(Order), "Id")]
|
||||
public Int32 OrderId { get { return Order != null ? Order.Id : 0; } }
|
||||
public Order Order => Extends.Get(nameof(Order), k => Order.FindById(OrderId));
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -131,6 +124,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From CouponUseLog Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<CouponUseLog> _CategoryCache = new FieldCache<CouponUseLog>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static CouponKind()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.IsLimit);
|
||||
//df.Add(nameof(IsLimit));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化CouponKind[优惠券分类]数据……");
|
||||
|
||||
// var entity = new CouponKind();
|
||||
// entity.Id = 0;
|
||||
// entity.IsLimit = 0;
|
||||
// entity.KindName = "abc";
|
||||
// entity.CouponType = 0;
|
||||
@@ -107,6 +112,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From CouponKind Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<CouponKind> _CategoryCache = new FieldCache<CouponKind>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -8,6 +8,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -21,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -35,13 +37,16 @@ namespace COMCMS.Core
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
}
|
||||
@@ -56,7 +61,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化WeixinResponseContent[公众平台回复信息]数据……");
|
||||
|
||||
// var entity = new WeixinResponseContent();
|
||||
// entity.Id = 0;
|
||||
// entity.OpenId = "abc";
|
||||
// entity.RequestType = "abc";
|
||||
// entity.RequestContent = "abc";
|
||||
@@ -106,6 +110,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From WeixinResponseContent Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<WeixinResponseContent> _CategoryCache = new FieldCache<WeixinResponseContent>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -33,13 +36,16 @@ namespace COMCMS.Core
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -53,7 +59,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化OtherConfig[其他配置]数据……");
|
||||
|
||||
// var entity = new OtherConfig();
|
||||
// entity.Id = 0;
|
||||
// entity.ConfigName = "abc";
|
||||
// entity.ConfigValue = "abc";
|
||||
// entity.LastUpdateTime = DateTime.Now;
|
||||
@@ -99,6 +104,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From OtherConfig Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<OtherConfig> _CategoryCache = new FieldCache<OtherConfig>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static Link()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.KId);
|
||||
//df.Add(nameof(KId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Link[友情连接详情]数据……");
|
||||
|
||||
// var entity = new Link();
|
||||
// entity.Id = 0;
|
||||
// entity.KId = 0;
|
||||
// entity.Title = "abc";
|
||||
// entity.LinkURL = "abc";
|
||||
@@ -106,6 +111,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From Link Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<Link> _CategoryCache = new FieldCache<Link>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static LinkKind()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.Rank);
|
||||
//df.Add(nameof(Rank));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化LinkKind[友情链接分类]数据……");
|
||||
|
||||
// var entity = new LinkKind();
|
||||
// entity.Id = 0;
|
||||
// entity.KindName = "abc";
|
||||
// entity.KindInfo = "abc";
|
||||
// entity.Pic = "abc";
|
||||
@@ -103,6 +108,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From LinkKind Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<LinkKind> _CategoryCache = new FieldCache<LinkKind>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static AdminMenu()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.PId);
|
||||
//df.Add(nameof(PId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化AdminMenu[后台菜单]数据……");
|
||||
|
||||
// var entity = new AdminMenu();
|
||||
// entity.Id = 0;
|
||||
// entity.MenuKey = "abc";
|
||||
// entity.MenuName = "abc";
|
||||
// entity.PermissionKey = "abc";
|
||||
@@ -111,6 +116,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From AdminMenu Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<AdminMenu> _CategoryCache = new FieldCache<AdminMenu>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static AdminMenuEvent()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.MenuId);
|
||||
//df.Add(nameof(MenuId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化AdminMenuEvent[后台菜单对应的事件权限]数据……");
|
||||
|
||||
// var entity = new AdminMenuEvent();
|
||||
// entity.Id = 0;
|
||||
// entity.MenuId = 0;
|
||||
// entity.MenuKey = "abc";
|
||||
// entity.EventId = 0;
|
||||
@@ -104,6 +109,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From AdminMenuEvent Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<AdminMenuEvent> _CategoryCache = new FieldCache<AdminMenuEvent>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,21 +32,24 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static Product()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.KId);
|
||||
//df.Add(nameof(KId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
Price = Math.Round(Price, 6);
|
||||
@@ -64,7 +70,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Product[商品]数据……");
|
||||
|
||||
// var entity = new Product();
|
||||
// entity.Id = 0;
|
||||
// entity.KId = 0;
|
||||
// entity.BId = 0;
|
||||
// entity.ShopId = 0;
|
||||
@@ -152,27 +157,19 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>店铺ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Shop Shop { get { return Extends.Get(nameof(Shop), k => Shop.FindById(ShopId)); } }
|
||||
|
||||
/// <summary>店铺ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("店铺ID")]
|
||||
[Map(__.ShopId, typeof(Shop), "Id")]
|
||||
public Int32 ShopId { get { return Shop != null ? Shop.Id : 0; } }
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
public Ads Ads { get { return Extends.Get(nameof(Ads), k => Ads.FindById(AdsId)); } }
|
||||
public Shop Shop => Extends.Get(nameof(Shop), k => Shop.FindById(ShopId));
|
||||
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("广告ID")]
|
||||
[Map(__.AdsId, typeof(Ads), "Id")]
|
||||
public String AdsTitle { get { return Ads?.Title; } }
|
||||
public Ads Ads => Extends.Get(nameof(Ads), k => Ads.FindById(AdsId));
|
||||
|
||||
/// <summary>广告ID</summary>
|
||||
[Map(nameof(AdsId), typeof(Ads), "Id")]
|
||||
public String AdsTitle => Ads?.Title;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -194,6 +191,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From Product Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<Product> _CategoryCache = new FieldCache<Product>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static Category()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.IsList);
|
||||
//df.Add(nameof(IsList));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Category[商品栏目]数据……");
|
||||
|
||||
// var entity = new Category();
|
||||
// entity.Id = 0;
|
||||
// entity.KindName = "abc";
|
||||
// entity.SubTitle = "abc";
|
||||
// entity.KindTitle = "abc";
|
||||
@@ -110,16 +115,14 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Ads Ads { get { return Extends.Get(nameof(Ads), k => Ads.FindById(AdsId)); } }
|
||||
public Ads Ads => Extends.Get(nameof(Ads), k => Ads.FindById(AdsId));
|
||||
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("广告ID")]
|
||||
[Map(__.AdsId, typeof(Ads), "Id")]
|
||||
public String AdsTitle { get { return Ads?.Title; } }
|
||||
[Map(nameof(AdsId), typeof(Ads), "Id")]
|
||||
public String AdsTitle => Ads?.Title;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -141,6 +144,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From Category Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<Category> _CategoryCache = new FieldCache<Category>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static Shop()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.KId);
|
||||
//df.Add(nameof(KId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
Latitude = Math.Round(Latitude, 6);
|
||||
@@ -66,7 +72,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Shop[商家]数据……");
|
||||
|
||||
// var entity = new Shop();
|
||||
// entity.Id = 0;
|
||||
// entity.ShopName = "abc";
|
||||
// entity.KId = 0;
|
||||
// entity.AId = 0;
|
||||
@@ -156,6 +161,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From Shop Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<Shop> _CategoryCache = new FieldCache<Shop>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static ShopCategory()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.IsList);
|
||||
//df.Add(nameof(IsList));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化ShopCategory[商家分类]数据……");
|
||||
|
||||
// var entity = new ShopCategory();
|
||||
// entity.Id = 0;
|
||||
// entity.KindName = "abc";
|
||||
// entity.SubTitle = "abc";
|
||||
// entity.KindTitle = "abc";
|
||||
@@ -109,16 +114,14 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Ads Ads { get { return Extends.Get(nameof(Ads), k => Ads.FindById(AdsId)); } }
|
||||
public Ads Ads => Extends.Get(nameof(Ads), k => Ads.FindById(AdsId));
|
||||
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("广告ID")]
|
||||
[Map(__.AdsId, typeof(Ads), "Id")]
|
||||
public String AdsTitle { get { return Ads?.Title; } }
|
||||
[Map(nameof(AdsId), typeof(Ads), "Id")]
|
||||
public String AdsTitle => Ads?.Title;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -140,6 +143,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From ShopCategory Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<ShopCategory> _CategoryCache = new FieldCache<ShopCategory>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static OnlinePayOrder()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.OrderId);
|
||||
//df.Add(nameof(OrderId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
TotalPrice = Math.Round(TotalPrice, 6);
|
||||
@@ -58,7 +64,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化OnlinePayOrder[在线支付订单]数据……");
|
||||
|
||||
// var entity = new OnlinePayOrder();
|
||||
// entity.Id = 0;
|
||||
// entity.PayOrderNum = "abc";
|
||||
// entity.OrderId = 0;
|
||||
// entity.OrderNum = "abc";
|
||||
@@ -79,6 +84,7 @@ namespace COMCMS.Core
|
||||
// entity.TypeId = 0;
|
||||
// entity.MyType = 0;
|
||||
// entity.Title = "abc";
|
||||
// entity.OutTradeNo = "abc";
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化OnlinePayOrder[在线支付订单]数据!");
|
||||
@@ -101,16 +107,10 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>订单ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Order Order { get { return Extends.Get(nameof(Order), k => Order.FindById(OrderId)); } }
|
||||
public Order Order => Extends.Get(nameof(Order), k => Order.FindById(OrderId));
|
||||
|
||||
/// <summary>订单ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("订单ID")]
|
||||
[Map(__.OrderId, typeof(Order), "Id")]
|
||||
public Int32 OrderId { get { return Order != null ? Order.Id : 0; } }
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -132,6 +132,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From OnlinePayOrder Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<OnlinePayOrder> _CategoryCache = new FieldCache<OnlinePayOrder>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static WXAppSession()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.UId);
|
||||
//df.Add(nameof(UId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化WXAppSession[小程序Session]数据……");
|
||||
|
||||
// var entity = new WXAppSession();
|
||||
// entity.Id = 0;
|
||||
// entity.UId = 0;
|
||||
// entity.Ip = "abc";
|
||||
// entity.Key = "abc";
|
||||
@@ -105,6 +110,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From WXAppSession Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<WXAppSession> _CategoryCache = new FieldCache<WXAppSession>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static AdsKind()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.Rank);
|
||||
//df.Add(nameof(Rank));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化AdsKind[广告类别]数据……");
|
||||
|
||||
// var entity = new AdsKind();
|
||||
// entity.Id = 0;
|
||||
// entity.KindName = "abc";
|
||||
// entity.KindInfo = "abc";
|
||||
// entity.Rank = 0;
|
||||
@@ -102,6 +107,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From AdsKind Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<AdsKind> _CategoryCache = new FieldCache<AdsKind>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static Ads()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.KId);
|
||||
//df.Add(nameof(KId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Ads[广告详情]数据……");
|
||||
|
||||
// var entity = new Ads();
|
||||
// entity.Id = 0;
|
||||
// entity.Title = "abc";
|
||||
// entity.Content = "abc";
|
||||
// entity.KId = 0;
|
||||
@@ -107,6 +112,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From Ads Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<Ads> _CategoryCache = new FieldCache<Ads>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -8,6 +8,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -21,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -30,21 +32,24 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static WeixinRequestRule()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.RequestType);
|
||||
//df.Add(nameof(RequestType));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
}
|
||||
@@ -59,7 +64,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化WeixinRequestRule[微信公众号回复规则]数据……");
|
||||
|
||||
// var entity = new WeixinRequestRule();
|
||||
// entity.Id = 0;
|
||||
// entity.RuleName = "abc";
|
||||
// entity.Keywords = "abc";
|
||||
// entity.RequestType = 0;
|
||||
@@ -111,6 +115,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From WeixinRequestRule Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<WeixinRequestRule> _CategoryCache = new FieldCache<WeixinRequestRule>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,21 +32,24 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static Food()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.KId);
|
||||
//df.Add(nameof(KId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
Price = Math.Round(Price, 6);
|
||||
@@ -64,7 +70,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Food[快餐]数据……");
|
||||
|
||||
// var entity = new Food();
|
||||
// entity.Id = 0;
|
||||
// entity.KId = 0;
|
||||
// entity.BId = 0;
|
||||
// entity.ShopId = 0;
|
||||
@@ -151,27 +156,19 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>店铺ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Shop Shop { get { return Extends.Get(nameof(Shop), k => Shop.FindById(ShopId)); } }
|
||||
|
||||
/// <summary>店铺ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("店铺ID")]
|
||||
[Map(__.ShopId, typeof(Shop), "Id")]
|
||||
public Int32 ShopId { get { return Shop != null ? Shop.Id : 0; } }
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
public Ads Ads { get { return Extends.Get(nameof(Ads), k => Ads.FindById(AdsId)); } }
|
||||
public Shop Shop => Extends.Get(nameof(Shop), k => Shop.FindById(ShopId));
|
||||
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("广告ID")]
|
||||
[Map(__.AdsId, typeof(Ads), "Id")]
|
||||
public String AdsTitle { get { return Ads?.Title; } }
|
||||
public Ads Ads => Extends.Get(nameof(Ads), k => Ads.FindById(AdsId));
|
||||
|
||||
/// <summary>广告ID</summary>
|
||||
[Map(nameof(AdsId), typeof(Ads), "Id")]
|
||||
public String AdsTitle => Ads?.Title;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -193,6 +190,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From Food Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<Food> _CategoryCache = new FieldCache<Food>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -8,6 +8,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -21,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -32,18 +34,21 @@ namespace COMCMS.Core
|
||||
{
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.Rank);
|
||||
//df.Add(nameof(Rank));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -57,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化DataDictionary[数据字典]数据……");
|
||||
|
||||
// var entity = new DataDictionary();
|
||||
// entity.Id = 0;
|
||||
// entity.Key = "abc";
|
||||
// entity.Description = "abc";
|
||||
// entity.Rank = 0;
|
||||
@@ -106,7 +110,7 @@ namespace COMCMS.Core
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From DataDictionary Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<DataDictionary> _CategoryCache = new FieldCache<DataDictionary>(_.Category)
|
||||
//static readonly FieldCache<DataDictionary> _CategoryCache = new FieldCache<DataDictionary>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
@@ -8,6 +8,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -21,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -32,18 +34,21 @@ namespace COMCMS.Core
|
||||
{
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.DataDictionaryId);
|
||||
//df.Add(nameof(DataDictionaryId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -57,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化DataDictionaryDetail[数据字典详情]数据……");
|
||||
|
||||
// var entity = new DataDictionaryDetail();
|
||||
// entity.Id = 0;
|
||||
// entity.DataDictionaryId = 0;
|
||||
// entity.Val = "abc";
|
||||
// entity.Title = "abc";
|
||||
@@ -91,12 +95,6 @@ namespace COMCMS.Core
|
||||
//[ScriptIgnore]
|
||||
public DataDictionary DataDictionary => Extends.Get(nameof(DataDictionary), k => DataDictionary.FindById(DataDictionaryId));
|
||||
|
||||
/// <summary>字典ID</summary>
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("字典ID")]
|
||||
[Map(__.DataDictionaryId, typeof(DataDictionary), "Id")]
|
||||
public Int32 DataDictionaryId => DataDictionary != null ? DataDictionary.Id : 0;
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -120,7 +118,7 @@ namespace COMCMS.Core
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From DataDictionaryDetail Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<DataDictionaryDetail> _CategoryCache = new FieldCache<DataDictionaryDetail>(_.Category)
|
||||
//static readonly FieldCache<DataDictionaryDetail> _CategoryCache = new FieldCache<DataDictionaryDetail>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,21 +32,24 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static Article()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.KId);
|
||||
//df.Add(nameof(KId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
}
|
||||
@@ -58,7 +64,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Article[文章]数据……");
|
||||
|
||||
// var entity = new Article();
|
||||
// entity.Id = 0;
|
||||
// entity.KId = 0;
|
||||
// entity.Title = "abc";
|
||||
// entity.SubTitle = "abc";
|
||||
@@ -117,16 +122,14 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Ads Ads { get { return Extends.Get(nameof(Ads), k => Ads.FindById(AdsId)); } }
|
||||
public Ads Ads => Extends.Get(nameof(Ads), k => Ads.FindById(AdsId));
|
||||
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("广告ID")]
|
||||
[Map(__.AdsId, typeof(Ads), "Id")]
|
||||
public String AdsTitle { get { return Ads?.Title; } }
|
||||
[Map(nameof(AdsId), typeof(Ads), "Id")]
|
||||
public String AdsTitle => Ads?.Title;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -148,6 +151,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From Article Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<Article> _CategoryCache = new FieldCache<Article>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static ArticleCategory()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.IsList);
|
||||
//df.Add(nameof(IsList));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化ArticleCategory[文章栏目]数据……");
|
||||
|
||||
// var entity = new ArticleCategory();
|
||||
// entity.Id = 0;
|
||||
// entity.KindName = "abc";
|
||||
// entity.SubTitle = "abc";
|
||||
// entity.KindTitle = "abc";
|
||||
@@ -110,16 +115,14 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Ads Ads { get { return Extends.Get(nameof(Ads), k => Ads.FindById(AdsId)); } }
|
||||
public Ads Ads => Extends.Get(nameof(Ads), k => Ads.FindById(AdsId));
|
||||
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("广告ID")]
|
||||
[Map(__.AdsId, typeof(Ads), "Id")]
|
||||
public String AdsTitle { get { return Ads?.Title; } }
|
||||
[Map(nameof(AdsId), typeof(Ads), "Id")]
|
||||
public String AdsTitle => Ads?.Title;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -141,6 +144,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From ArticleCategory Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<ArticleCategory> _CategoryCache = new FieldCache<ArticleCategory>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static Member()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.RoleId);
|
||||
//df.Add(nameof(RoleId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
Balance = Math.Round(Balance, 6);
|
||||
@@ -67,7 +73,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Member[用户]数据……");
|
||||
|
||||
// var entity = new Member();
|
||||
// entity.Id = 0;
|
||||
// entity.UserName = "abc";
|
||||
// entity.PassWord = "abc";
|
||||
// entity.Salt = "abc";
|
||||
@@ -170,6 +175,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From Member Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<Member> _CategoryCache = new FieldCache<Member>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static MemberCoupon()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.UId);
|
||||
//df.Add(nameof(UId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
DiscuountRates = Math.Round(DiscuountRates, 6);
|
||||
@@ -60,7 +66,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化MemberCoupon[用户优惠券]数据……");
|
||||
|
||||
// var entity = new MemberCoupon();
|
||||
// entity.Id = 0;
|
||||
// entity.UId = 0;
|
||||
// entity.ItemNO = "abc";
|
||||
// entity.CouponId = 0;
|
||||
@@ -98,27 +103,15 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>优惠券ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Coupon Coupon { get { return Extends.Get(nameof(Coupon), k => Coupon.FindById(CouponId)); } }
|
||||
|
||||
/// <summary>优惠券ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("优惠券ID")]
|
||||
[Map(__.CouponId, typeof(Coupon), "Id")]
|
||||
public Int32 CouponId { get { return Coupon != null ? Coupon.Id : 0; } }
|
||||
/// <summary>订单编号</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
public Order Order { get { return Extends.Get(nameof(Order), k => Order.FindById(OrderId)); } }
|
||||
public Coupon Coupon => Extends.Get(nameof(Coupon), k => Coupon.FindById(CouponId));
|
||||
|
||||
/// <summary>订单编号</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("订单编号")]
|
||||
[Map(__.OrderId, typeof(Order), "Id")]
|
||||
public Int32 OrderId { get { return Order != null ? Order.Id : 0; } }
|
||||
public Order Order => Extends.Get(nameof(Order), k => Order.FindById(OrderId));
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -140,6 +133,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From MemberCoupon Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<MemberCoupon> _CategoryCache = new FieldCache<MemberCoupon>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static BalanceChangeLog()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.UId);
|
||||
//df.Add(nameof(UId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
Reward = Math.Round(Reward, 6);
|
||||
@@ -60,7 +66,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化BalanceChangeLog[用户余额变化记录]数据……");
|
||||
|
||||
// var entity = new BalanceChangeLog();
|
||||
// entity.Id = 0;
|
||||
// entity.UId = 0;
|
||||
// entity.AdminId = 0;
|
||||
// entity.UserName = "abc";
|
||||
@@ -96,27 +101,19 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>管理员ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Admin Admin { get { return Extends.Get(nameof(Admin), k => Admin.FindById(AdminId)); } }
|
||||
public Admin Admin => Extends.Get(nameof(Admin), k => Admin.FindById(AdminId));
|
||||
|
||||
/// <summary>管理员ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("管理员ID")]
|
||||
[Map(__.AdminId, typeof(Admin), "Id")]
|
||||
public String AdminUserName { get { return Admin?.UserName; } }
|
||||
/// <summary>订单ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
public Order Order { get { return Extends.Get(nameof(Order), k => Order.FindById(OrderId)); } }
|
||||
[Map(nameof(AdminId), typeof(Admin), "Id")]
|
||||
public String AdminUserName => Admin?.UserName;
|
||||
|
||||
/// <summary>订单ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("订单ID")]
|
||||
[Map(__.OrderId, typeof(Order), "Id")]
|
||||
public Int32 OrderId { get { return Order != null ? Order.Id : 0; } }
|
||||
public Order Order => Extends.Get(nameof(Order), k => Order.FindById(OrderId));
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -138,6 +135,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From BalanceChangeLog Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<BalanceChangeLog> _CategoryCache = new FieldCache<BalanceChangeLog>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,21 +32,24 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static MemberAddress()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.UId);
|
||||
//df.Add(nameof(UId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||
}
|
||||
@@ -58,7 +64,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化MemberAddress[用户地址]数据……");
|
||||
|
||||
// var entity = new MemberAddress();
|
||||
// entity.Id = 0;
|
||||
// entity.UId = 0;
|
||||
// entity.RealName = "abc";
|
||||
// entity.Tel = "abc";
|
||||
@@ -117,6 +122,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From MemberAddress Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<MemberAddress> _CategoryCache = new FieldCache<MemberAddress>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static WithdrawOrder()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.UId);
|
||||
//df.Add(nameof(UId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
Price = Math.Round(Price, 6);
|
||||
@@ -58,7 +64,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化WithdrawOrder[用户提现订单]数据……");
|
||||
|
||||
// var entity = new WithdrawOrder();
|
||||
// entity.Id = 0;
|
||||
// entity.UId = 0;
|
||||
// entity.OrderNum = "abc";
|
||||
// entity.UserName = "abc";
|
||||
@@ -113,6 +118,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From WithdrawOrder Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<WithdrawOrder> _CategoryCache = new FieldCache<WithdrawOrder>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static MemberLog()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.UId);
|
||||
//df.Add(nameof(UId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化MemberLog[用户日志表]数据……");
|
||||
|
||||
// var entity = new MemberLog();
|
||||
// entity.Id = 0;
|
||||
// entity.UId = 0;
|
||||
// entity.Guid = "abc";
|
||||
// entity.UserName = "abc";
|
||||
@@ -108,6 +113,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From MemberLog Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<MemberLog> _CategoryCache = new FieldCache<MemberLog>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static MemberRoles()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.Stars);
|
||||
//df.Add(nameof(Stars));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
CashBack = Math.Round(CashBack, 6);
|
||||
@@ -64,7 +70,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化MemberRoles[用户角色]数据……");
|
||||
|
||||
// var entity = new MemberRoles();
|
||||
// entity.Id = 0;
|
||||
// entity.RoleName = "abc";
|
||||
// entity.RoleDescription = "abc";
|
||||
// entity.Stars = 0;
|
||||
@@ -123,6 +128,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From MemberRoles Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<MemberRoles> _CategoryCache = new FieldCache<MemberRoles>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static RebateChangeLog()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.UId);
|
||||
//df.Add(nameof(UId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
Reward = Math.Round(Reward, 6);
|
||||
@@ -60,7 +66,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化RebateChangeLog[用户返现余额变化记录]数据……");
|
||||
|
||||
// var entity = new RebateChangeLog();
|
||||
// entity.Id = 0;
|
||||
// entity.UId = 0;
|
||||
// entity.AdminId = 0;
|
||||
// entity.UserName = "abc";
|
||||
@@ -97,27 +102,19 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>管理员ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Admin Admin { get { return Extends.Get(nameof(Admin), k => Admin.FindById(AdminId)); } }
|
||||
public Admin Admin => Extends.Get(nameof(Admin), k => Admin.FindById(AdminId));
|
||||
|
||||
/// <summary>管理员ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("管理员ID")]
|
||||
[Map(__.AdminId, typeof(Admin), "Id")]
|
||||
public String AdminUserName { get { return Admin?.UserName; } }
|
||||
/// <summary>订单ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
public Order Order { get { return Extends.Get(nameof(Order), k => Order.FindById(OrderId)); } }
|
||||
[Map(nameof(AdminId), typeof(Admin), "Id")]
|
||||
public String AdminUserName => Admin?.UserName;
|
||||
|
||||
/// <summary>订单ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("订单ID")]
|
||||
[Map(__.OrderId, typeof(Order), "Id")]
|
||||
public Int32 OrderId { get { return Order != null ? Order.Id : 0; } }
|
||||
public Order Order => Extends.Get(nameof(Order), k => Order.FindById(OrderId));
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -139,6 +136,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From RebateChangeLog Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<RebateChangeLog> _CategoryCache = new FieldCache<RebateChangeLog>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static GuestbookCategory()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.IsList);
|
||||
//df.Add(nameof(IsList));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化GuestbookCategory[留言分类]数据……");
|
||||
|
||||
// var entity = new GuestbookCategory();
|
||||
// entity.Id = 0;
|
||||
// entity.KindName = "abc";
|
||||
// entity.SubTitle = "abc";
|
||||
// entity.KindTitle = "abc";
|
||||
@@ -109,16 +114,14 @@ namespace COMCMS.Core
|
||||
|
||||
#region 扩展属性
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
[XmlIgnore, IgnoreDataMember]
|
||||
//[ScriptIgnore]
|
||||
public Ads Ads { get { return Extends.Get(nameof(Ads), k => Ads.FindById(AdsId)); } }
|
||||
public Ads Ads => Extends.Get(nameof(Ads), k => Ads.FindById(AdsId));
|
||||
|
||||
/// <summary>广告ID</summary>
|
||||
[XmlIgnore]
|
||||
//[ScriptIgnore]
|
||||
[DisplayName("广告ID")]
|
||||
[Map(__.AdsId, typeof(Ads), "Id")]
|
||||
public String AdsTitle { get { return Ads?.Title; } }
|
||||
[Map(nameof(AdsId), typeof(Ads), "Id")]
|
||||
public String AdsTitle => Ads?.Title;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
@@ -140,6 +143,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From GuestbookCategory Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<GuestbookCategory> _CategoryCache = new FieldCache<GuestbookCategory>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
@@ -4,9 +4,11 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
@@ -20,6 +22,7 @@ using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
using XCode.Shards;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
@@ -29,20 +32,23 @@ namespace COMCMS.Core
|
||||
#region 对象操作
|
||||
static Guestbook()
|
||||
{
|
||||
// 累加字段
|
||||
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||
//var df = Meta.Factory.AdditionalFields;
|
||||
//df.Add(__.KId);
|
||||
//df.Add(nameof(KId));
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||
base.Valid(isNew);
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
@@ -56,7 +62,6 @@ namespace COMCMS.Core
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Guestbook[留言详情]数据……");
|
||||
|
||||
// var entity = new Guestbook();
|
||||
// entity.Id = 0;
|
||||
// entity.KId = 0;
|
||||
// entity.UId = 0;
|
||||
// entity.Title = "abc";
|
||||
@@ -121,6 +126,16 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
|
||||
// Select Count(Id) as Id,Category From Guestbook Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||
//static readonly FieldCache<Guestbook> _CategoryCache = new FieldCache<Guestbook>(nameof(Category))
|
||||
//{
|
||||
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||
//};
|
||||
|
||||
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||
///// <returns></returns>
|
||||
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user