Skip to content

Commit f99cf57

Browse files
committed
feat: Add calendar module
1 parent 7ff722a commit f99cf57

14 files changed

Lines changed: 375 additions & 0 deletions

aspnet-core/LINGYUN.MicroService.Aspire.slnx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@
9090
<Folder Name="/framework/authorization/">
9191
<Project Path="framework/authorization/LINGYUN.Abp.Authorization.OrganizationUnits/LINGYUN.Abp.Authorization.OrganizationUnits.csproj" />
9292
</Folder>
93+
<Folder Name="/framework/calendars/">
94+
<Project Path="framework/calendars/LINGYUN.Abp.Calendar/LINGYUN.Abp.Calendar.csproj" Id="2fee90a2-01aa-4417-9529-79bb10b8850c" />
95+
</Folder>
9396
<Folder Name="/framework/cli/">
9497
<Project Path="framework/cli/LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj" />
9598
</Folder>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
2+
<ConfigureAwait ContinueOnCapturedContext="false" />
3+
</Weavers>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<Import Project="..\..\..\..\configureawait.props" />
4+
<Import Project="..\..\..\..\common.props" />
5+
6+
<PropertyGroup>
7+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
8+
<AssemblyName>LINGYUN.Abp.WorkdayCalendar</AssemblyName>
9+
<PackageId>LINGYUN.Abp.WorkdayCalendar</PackageId>
10+
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
11+
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
12+
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
13+
<Nullable>enable</Nullable>
14+
<RootNamespace />
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<PackageReference Include="Volo.Abp.Timing" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Volo.Abp.Modularity;
2+
using Volo.Abp.Timing;
3+
4+
namespace LINGYUN.Abp.Calendar;
5+
6+
[DependsOn(typeof(AbpTimingModule))]
7+
public class AbpCalendarModule : AbpModule
8+
{
9+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
3+
namespace LINGYUN.Abp.Calendar;
4+
5+
public class AbpCalendarOptions
6+
{
7+
/// <summary>
8+
/// 默认工作日范围
9+
/// 默认: 周一到周五
10+
/// </summary>
11+
public DayOfWeek[] DefaultWorkdays { get; set; }
12+
/// <summary>
13+
/// 是否启用工作时间限制
14+
/// 默认: true
15+
/// </summary>
16+
public bool EnableWorkTimeRestriction { get; set; }
17+
/// <summary>
18+
/// 默认工作时间范围
19+
/// 默认: 09:00-12:00、13:00-18:00
20+
/// </summary>
21+
public WorkTimeRange[] DefaultWorkTimes { get; set; }
22+
23+
public AbpCalendarOptions()
24+
{
25+
DefaultWorkdays = new[]
26+
{
27+
DayOfWeek.Monday,
28+
DayOfWeek.Tuesday,
29+
DayOfWeek.Wednesday,
30+
DayOfWeek.Thursday,
31+
DayOfWeek.Friday
32+
};
33+
EnableWorkTimeRestriction = true;
34+
DefaultWorkTimes = new[]
35+
{
36+
new WorkTimeRange(new TimeSpan(9, 0, 0), new TimeSpan(12, 0, 0)),
37+
new WorkTimeRange(new TimeSpan(13, 0, 0), new TimeSpan(18, 0, 0)),
38+
};
39+
}
40+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
4+
namespace LINGYUN.Abp.Calendar;
5+
6+
public interface IWorkdayCalendarService
7+
{
8+
/// <summary>
9+
/// 检查指定时间是否在工作日
10+
/// </summary>
11+
Task<bool> IsWorkdayAsync(DateOnly date);
12+
/// <summary>
13+
/// 检查指定时间是否在工作时间
14+
/// </summary>
15+
/// <param name="dateTime"></param>
16+
/// <returns></returns>
17+
Task<bool> IsInWorkTimeAsync(DateTime dateTime);
18+
/// <summary>
19+
/// 获取下一个工作日
20+
/// </summary>
21+
/// <param name="date"></param>
22+
/// <returns></returns>
23+
Task<DateOnly> GetNextWorkdayAsync(DateOnly date);
24+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
4+
namespace LINGYUN.Abp.Calendar;
5+
6+
public interface IWorkdayCalendarStore
7+
{
8+
/// <summary>
9+
/// 获取特殊日期
10+
/// </summary>
11+
/// <param name="date">日期</param>
12+
/// <returns></returns>
13+
Task<SpecialDateInfo?> FindSpecialDateAsync(DateOnly date);
14+
/// <summary>
15+
/// 获取默认工作日历
16+
/// </summary>
17+
Task<WorkdayCalendarInfo?> FindDefaultCalendarAsync();
18+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Volo.Abp.DependencyInjection;
4+
5+
namespace LINGYUN.Abp.Calendar;
6+
7+
[Dependency(TryRegister = true)]
8+
public class NullWorkdayCalendarStore : IWorkdayCalendarStore, ISingletonDependency
9+
{
10+
public Task<WorkdayCalendarInfo?> FindDefaultCalendarAsync()
11+
{
12+
return Task.FromResult<WorkdayCalendarInfo?>(null);
13+
}
14+
15+
public Task<SpecialDateInfo?> FindSpecialDateAsync(DateOnly date)
16+
{
17+
return Task.FromResult<SpecialDateInfo?>(null);
18+
}
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
3+
namespace LINGYUN.Abp.Calendar;
4+
/// <summary>
5+
/// 特殊日期
6+
/// </summary>
7+
public class SpecialDateInfo
8+
{
9+
/// <summary>
10+
/// 日期
11+
/// </summary>
12+
public DateOnly Date { get; set; }
13+
/// <summary>
14+
/// 特殊日期类型
15+
/// </summary>
16+
public SpecialDateType Type { get; set; }
17+
/// <summary>
18+
/// 特殊日期描述
19+
/// </summary>
20+
public string? Description { get; set; }
21+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.ComponentModel;
2+
3+
namespace LINGYUN.Abp.Calendar;
4+
/// <summary>
5+
/// 特殊日期类型
6+
/// </summary>
7+
public enum SpecialDateType
8+
{
9+
/// <summary>
10+
/// 法定节假日
11+
/// </summary>
12+
[Description("法定节假日")]
13+
Holiday = 0,
14+
/// <summary>
15+
/// 特殊工作日
16+
/// </summary>
17+
[Description("特殊工作日")]
18+
SpecialWorkday = 1,
19+
/// <summary>
20+
/// 自定义假期
21+
/// </summary>
22+
[Description("自定义假期")]
23+
CustomHoliday = 2
24+
}

0 commit comments

Comments
 (0)