using Jiaowu.Api.Domain.Academic; namespace Jiaowu.Api.Infrastructure.Teaching; public static class TeachingTaskHours { public static int Calculate(int startWeek, int endWeek, int weeklyHours) => endWeek < startWeek ? 0 : (endWeek - startWeek + 1) * weeklyHours; public static string? Validate( Course course, int startWeek, int endWeek, int weeklyHours) { var plannedHours = Calculate(startWeek, endWeek, weeklyHours); return plannedHours == course.TotalHours ? null : $"课程“{course.Name}”总学时为 {course.TotalHours};当前第 {startWeek}—{endWeek} 周、每周 {weeklyHours} 学时,共 {plannedHours} 学时。请调整授课周次或周学时。"; } }