Skip to content

Commit

Permalink
Added school calendar year API
Browse files Browse the repository at this point in the history
  • Loading branch information
84634E1A607A committed Oct 7, 2024
1 parent 5caa1e9 commit 643c747
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ThuInfoWeb/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,10 @@ public async Task<IActionResult> CardIVersion()
{
return Ok(new { Version = (await data.GetMiscAsync())?.CardIVersion ?? -1 });
}

[Route("SchoolCalendarYear")]
public async Task<IActionResult> SchoolCalendarYear()
{
return Ok(new { Year = (await data.GetMiscAsync())?.SchoolCalendarYear ?? -1 });
}
}
10 changes: 8 additions & 2 deletions ThuInfoWeb/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ public async Task<IActionResult> Misc()
var misc = await data.GetMiscAsync() ?? new Misc();
return View(new MiscViewModel
{
ApkUrl = misc.ApkUrl, QrCodeContent = misc.QrCodeContent, CardIVersion = misc.CardIVersion
ApkUrl = misc.ApkUrl,
QrCodeContent = misc.QrCodeContent,
CardIVersion = misc.CardIVersion,
SchoolCalendarYear = misc.SchoolCalendarYear
});
}

Expand All @@ -264,7 +267,10 @@ public async Task<IActionResult> Misc(MiscViewModel vm)
return View(vm);
var misc = new Misc
{
ApkUrl = vm.ApkUrl ?? "", QrCodeContent = vm.QrCodeContent ?? "", CardIVersion = vm.CardIVersion
ApkUrl = vm.ApkUrl ?? "",
QrCodeContent = vm.QrCodeContent ?? "",
CardIVersion = vm.CardIVersion,
SchoolCalendarYear = vm.SchoolCalendarYear
};
var result = await data.UpdateMiscAsync(misc);
if (result != 1)
Expand Down
9 changes: 9 additions & 0 deletions ThuInfoWeb/DBModels/Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ public class Misc
/// </summary>
[Column(IsNullable = false)]
public int CardIVersion { get; init; }

/// <summary>
/// Updated school calendar year.
/// </summary>
/// <remarks>
/// To update, download school calendar from info and manually upload it to the server.
/// </remarks>
[Column(IsNullable = false)]
public int SchoolCalendarYear { get; init; }
}
3 changes: 3 additions & 0 deletions ThuInfoWeb/Models/MiscViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ public class MiscViewModel

[Required]
public int CardIVersion { get; init; }

[Required]
public int SchoolCalendarYear { get; init; }
}
11 changes: 11 additions & 0 deletions ThuInfoWeb/Views/Home/Misc.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
@Model.CardIVersion
</div>
</li>
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">最新校历学年</div>
@Model.SchoolCalendarYear
</div>
</li>
</ol>

<form asp-action="Misc" method="post">
Expand All @@ -40,5 +46,10 @@
<input asp-for="CardIVersion" class="form-control" value="@Model.CardIVersion">
<span asp-validation-for="CardIVersion" class="text-danger"></span>
</div>
<div class="mb-3">
<label class="form-label">最新校历学年</label>
<input asp-for="SchoolCalendarYear" class="form-control" value="@Model.SchoolCalendarYear">
<span asp-validation-for="SchoolCalendarYear" class="text-danger"></span>
</div>
<button type="submit" class="btn btn-primary">提交修改</button>
</form>
Empty file.

0 comments on commit 643c747

Please sign in to comment.