Skip to content

Commit 1896f37

Browse files
committed
升级XCode拦截器架构
1 parent 1e9062f commit 1896f37

22 files changed

+712
-49
lines changed

.github/instructions/xcode.instructions.md

Lines changed: 506 additions & 0 deletions
Large diffs are not rendered by default.

AntJob.Data/AntJob.Data.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<None Remove="Build.tt" />
3838
</ItemGroup>
3939
<ItemGroup>
40-
<PackageReference Include="NewLife.XCode" Version="11.23.2026.113-beta1334" />
40+
<PackageReference Include="NewLife.XCode" Version="11.24.2026.201" />
4141
</ItemGroup>
4242
<ItemGroup>
4343
<None Update="Build.log">

AntJob.Data/Entity/作业.Biz.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using NewLife;
44
using NewLife.Data;
@@ -22,10 +22,10 @@ static Job()
2222
df.Add(__.Times);
2323
//df.Add(__.MessageCount);
2424

25-
// 过滤器 UserModule、TimeModule、IPModule
26-
Meta.Modules.Add<UserModule>();
27-
Meta.Modules.Add<TimeModule>();
28-
Meta.Modules.Add<IPModule>();
25+
// 过滤器 UserInterceptor、TimeInterceptor、IPInterceptor
26+
Meta.Interceptors.Add<UserInterceptor>();
27+
Meta.Interceptors.Add<TimeInterceptor>();
28+
Meta.Interceptors.Add<IPInterceptor>();
2929
}
3030

3131
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>

AntJob.Data/Entity/作业.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,32 @@ public override Object this[String name]
501501
#region 扩展查询
502502
#endregion
503503

504+
#region 高级查询
505+
/// <summary>高级查询</summary>
506+
/// <param name="appId">应用</param>
507+
/// <param name="mode">调度模式。定时调度只要达到时间片开头就可以跑,数据调度要求达到时间片末尾才可以跑</param>
508+
/// <param name="lastStatus">最后状态。最后一次状态</param>
509+
/// <param name="enable">启用</param>
510+
/// <param name="start">更新时间开始</param>
511+
/// <param name="end">更新时间结束</param>
512+
/// <param name="key">关键字</param>
513+
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
514+
/// <returns>实体列表</returns>
515+
public static IList<Job> Search(Int32 appId, JobModes mode, JobStatus lastStatus, Boolean? enable, DateTime start, DateTime end, String key, PageParameter page)
516+
{
517+
var exp = new WhereExpression();
518+
519+
if (appId >= 0) exp &= _.AppID == appId;
520+
if (mode >= 0) exp &= _.Mode == mode;
521+
if (lastStatus >= 0) exp &= _.LastStatus == lastStatus;
522+
if (enable != null) exp &= _.Enable == enable;
523+
exp &= _.UpdateTime.Between(start, end);
524+
if (!key.IsNullOrEmpty()) exp &= SearchWhereByKeys(key);
525+
526+
return FindAll(exp, page);
527+
}
528+
#endregion
529+
504530
#region 字段名
505531
/// <summary>取得作业字段信息的快捷方式</summary>
506532
public partial class _

AntJob.Data/Entity/作业任务.Biz.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using NewLife;
@@ -19,9 +19,9 @@ static JobTask()
1919
df.Add(__.Error);
2020
df.Add(__.Times);
2121

22-
Meta.Modules.Add<IPModule>();
23-
Meta.Modules.Add<TimeModule>();
24-
Meta.Modules.Add<TraceModule>();
22+
Meta.Interceptors.Add<IPInterceptor>();
23+
Meta.Interceptors.Add<TimeInterceptor>();
24+
Meta.Interceptors.Add<TraceInterceptor>();
2525
}
2626

2727
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>

AntJob.Data/Entity/作业任务.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,45 @@ public static IList<JobTask> FindAllByDataTime(DateTime dataTime)
363363
}
364364
#endregion
365365

366+
#region 高级查询
367+
/// <summary>高级查询</summary>
368+
/// <param name="appId">应用</param>
369+
/// <param name="jobId">作业</param>
370+
/// <param name="client">客户端。IP加进程</param>
371+
/// <param name="status">状态</param>
372+
/// <param name="createTime">创建时间</param>
373+
/// <param name="updateTime">更新时间</param>
374+
/// <param name="start">数据时间开始</param>
375+
/// <param name="end">数据时间结束</param>
376+
/// <param name="key">关键字</param>
377+
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
378+
/// <returns>实体列表</returns>
379+
public static IList<JobTask> Search(Int32 appId, Int32 jobId, String client, JobStatus status, DateTime createTime, DateTime updateTime, DateTime start, DateTime end, String key, PageParameter page)
380+
{
381+
var exp = new WhereExpression();
382+
383+
if (appId >= 0) exp &= _.AppID == appId;
384+
if (jobId >= 0) exp &= _.JobID == jobId;
385+
if (!client.IsNullOrEmpty()) exp &= _.Client == client;
386+
if (status >= 0) exp &= _.Status == status;
387+
exp &= _.DataTime.Between(start, end);
388+
if (!key.IsNullOrEmpty()) exp &= SearchWhereByKeys(key);
389+
390+
return FindAll(exp, page);
391+
}
392+
#endregion
393+
366394
#region 数据清理
367395
/// <summary>清理指定时间段内的数据</summary>
368396
/// <param name="start">开始时间。未指定时清理小于指定时间的所有数据</param>
369397
/// <param name="end">结束时间</param>
398+
/// <param name="maximumRows">最大删除行数。清理历史数据时,避免一次性删除过多导致数据库IO跟不上,0表示所有</param>
370399
/// <returns>清理行数</returns>
371-
public static Int32 DeleteWith(DateTime start, DateTime end)
400+
public static Int32 DeleteWith(DateTime start, DateTime end, Int32 maximumRows = 0)
372401
{
373402
if (start == end) return Delete(_.DataTime == start);
374403

375-
return Delete(_.DataTime.Between(start, end));
404+
return Delete(_.DataTime.Between(start, end), maximumRows);
376405
}
377406
#endregion
378407

AntJob.Data/Entity/作业错误.Biz.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using NewLife;
44
using NewLife.Data;
@@ -12,10 +12,10 @@ public partial class JobError : EntityBase<JobError>
1212
#region 对象操作
1313
static JobError()
1414
{
15-
// 过滤器 UserModule、TimeModule、IPModule
16-
Meta.Modules.Add<IPModule>();
17-
Meta.Modules.Add<TimeModule>();
18-
Meta.Modules.Add<TraceModule>();
15+
// 过滤器 UserInterceptor、TimeInterceptor、IPInterceptor
16+
Meta.Interceptors.Add<IPInterceptor>();
17+
Meta.Interceptors.Add<TimeInterceptor>();
18+
Meta.Interceptors.Add<TraceInterceptor>();
1919
}
2020

2121
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>

AntJob.Data/Entity/作业错误.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,30 @@ public override Object this[String name]
240240
#region 扩展查询
241241
#endregion
242242

243+
#region 高级查询
244+
/// <summary>高级查询</summary>
245+
/// <param name="appId">应用</param>
246+
/// <param name="jobId">作业</param>
247+
/// <param name="taskId">作业项</param>
248+
/// <param name="start">更新时间开始</param>
249+
/// <param name="end">更新时间结束</param>
250+
/// <param name="key">关键字</param>
251+
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
252+
/// <returns>实体列表</returns>
253+
public static IList<JobError> Search(Int32 appId, Int32 jobId, Int32 taskId, DateTime start, DateTime end, String key, PageParameter page)
254+
{
255+
var exp = new WhereExpression();
256+
257+
if (appId >= 0) exp &= _.AppID == appId;
258+
if (jobId >= 0) exp &= _.JobID == jobId;
259+
if (taskId >= 0) exp &= _.TaskID == taskId;
260+
exp &= _.UpdateTime.Between(start, end);
261+
if (!key.IsNullOrEmpty()) exp &= SearchWhereByKeys(key);
262+
263+
return FindAll(exp, page);
264+
}
265+
#endregion
266+
243267
#region 字段名
244268
/// <summary>取得作业错误字段信息的快捷方式</summary>
245269
public partial class _

AntJob.Data/Entity/应用历史.Biz.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using NewLife;
44
using NewLife.Data;
@@ -19,10 +19,10 @@ static AppHistory()
1919
//var df = Meta.Factory.AdditionalFields;
2020
//df.Add(__.AppID);
2121

22-
// 过滤器 UserModule、TimeModule、IPModule
23-
Meta.Modules.Add<TimeModule>();
24-
Meta.Modules.Add<IPModule>();
25-
Meta.Modules.Add<TraceModule>();
22+
// 过滤器 UserInterceptor、TimeInterceptor、IPInterceptor
23+
Meta.Interceptors.Add<TimeInterceptor>();
24+
Meta.Interceptors.Add<IPInterceptor>();
25+
Meta.Interceptors.Add<TraceInterceptor>();
2626
}
2727

2828
/// <summary>验证数据</summary>

AntJob.Data/Entity/应用历史.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,11 @@ public override Object this[String name]
185185
/// <summary>清理指定时间段内的数据</summary>
186186
/// <param name="start">开始时间。未指定时清理小于指定时间的所有数据</param>
187187
/// <param name="end">结束时间</param>
188+
/// <param name="maximumRows">最大删除行数。清理历史数据时,避免一次性删除过多导致数据库IO跟不上,0表示所有</param>
188189
/// <returns>清理行数</returns>
189-
public static Int32 DeleteWith(DateTime start, DateTime end)
190+
public static Int32 DeleteWith(DateTime start, DateTime end, Int32 maximumRows = 0)
190191
{
191-
return Delete(_.Id.Between(start, end, Meta.Factory.Snow));
192+
return Delete(_.Id.Between(start, end, Meta.Factory.Snow), maximumRows);
192193
}
193194
#endregion
194195

0 commit comments

Comments
 (0)