已完善个人教学日历订阅。

主要能力:
教师、学生可在“我的课表”启用订阅、复制 URL、唤起日历客户端或下载一次性 ICS。
自动覆盖固定课程、调停课后的最新安排、考试/监考、补考,以及灵活课程提醒。
采用独立随机订阅标识和 HMAC 签名;重置或停用后旧地址立即失效。
支持 ETag 条件请求和一小时刷新提示,减少日历客户端重复同步。
订阅地址按实际前端 API 地址生成,兼容独立部署域名。
已增加窄屏弹窗最大宽度和纵向操作布局。
This commit is contained in:
2026-07-26 17:22:58 +08:00 Unverified
parent ec28eb6c16
commit 40b8cb6e3c
15 changed files with 5631 additions and 9 deletions
@@ -119,6 +119,7 @@ public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
{
entity.Property(x => x.DisplayName).HasMaxLength(50);
entity.Property(x => x.StaffNumber).HasMaxLength(30);
entity.Property(x => x.CalendarSubscriptionStamp).HasMaxLength(64);
entity.HasIndex(x => x.StaffNumber);
});
@@ -50,6 +50,8 @@ public sealed class DevelopmentSqliteMigrator(
"20260726_27_academic_term_archiving";
private const string CourseSelectionWaitlistMigration =
"20260726_28_course_selection_waitlist";
private const string PersonalCalendarSubscriptionMigration =
"20260726_29_personal_calendar_subscription";
public async Task MigrateAsync(CancellationToken cancellationToken = default)
{
@@ -359,6 +361,21 @@ public sealed class DevelopmentSqliteMigrator(
CourseSelectionWaitlistMigration,
courseSelectionWaitlistExists ? [] : CourseSelectionWaitlistStatements,
cancellationToken);
var personalCalendarSubscriptionExists = await db.Database
.SqlQueryRaw<int>(
"""
SELECT COUNT(*) AS "Value"
FROM pragma_table_info('AspNetUsers')
WHERE name = 'CalendarSubscriptionStamp'
""")
.AnyAsync(value => value > 0, cancellationToken);
await ApplyMigrationAsync(
PersonalCalendarSubscriptionMigration,
personalCalendarSubscriptionExists
? []
: PersonalCalendarSubscriptionStatements,
cancellationToken);
}
private async Task ApplyMigrationAsync(
@@ -1616,6 +1633,18 @@ public sealed class DevelopmentSqliteMigrator(
"""
];
private static readonly string[] PersonalCalendarSubscriptionStatements =
[
"""
ALTER TABLE "AspNetUsers"
ADD COLUMN "CalendarSubscriptionStamp" TEXT NULL;
""",
"""
ALTER TABLE "AspNetUsers"
ADD COLUMN "CalendarSubscriptionCreatedAt" TEXT NULL;
"""
];
private static readonly string[] CourseAdjustmentsStatements =
[
"""
@@ -0,0 +1,40 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
{
/// <inheritdoc />
public partial class PersonalCalendarSubscription : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "CalendarSubscriptionCreatedAt",
table: "AspNetUsers",
type: "datetime(6)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CalendarSubscriptionStamp",
table: "AspNetUsers",
type: "varchar(64)",
maxLength: 64,
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CalendarSubscriptionCreatedAt",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "CalendarSubscriptionStamp",
table: "AspNetUsers");
}
}
}
@@ -3016,6 +3016,13 @@ namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<DateTime?>("CalendarSubscriptionCreatedAt")
.HasColumnType("datetime(6)");
b.Property<string>("CalendarSubscriptionStamp")
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<Guid?>("CollegeId")
.HasColumnType("char(36)");