Рефактор
Some checks failed
Create and publish a Docker image / Publish image (push) Failing after 9s

This commit is contained in:
2025-11-14 23:53:02 +03:00
parent a86ffdf5e7
commit eb89b98326
25 changed files with 1101 additions and 1202 deletions

View File

@@ -0,0 +1,51 @@
using System.Text.Json;
using System.Text.Json.Serialization;
#pragma warning disable CS8618
#pragma warning disable CS8601
#pragma warning disable CS8603
namespace ModeusSchedule.Abstractions.DTO;
public partial class Attendees
{
public static List<Attendees> FromJson(string json)
{
return JsonSerializer.Deserialize<List<Attendees>>(json);
}
}
public partial class Attendees
{
[JsonPropertyName("id")] public Guid Id { get; set; }
[JsonPropertyName("roleId")] public string RoleId { get; set; }
[JsonPropertyName("roleName")] public string RoleName { get; set; }
[JsonPropertyName("roleNamePlural")] public string RoleNamePlural { get; set; }
[JsonPropertyName("roleDisplayOrder")] public long RoleDisplayOrder { get; set; }
[JsonPropertyName("personId")] public Guid PersonId { get; set; }
[JsonPropertyName("lastName")] public string LastName { get; set; }
[JsonPropertyName("firstName")] public string FirstName { get; set; }
[JsonPropertyName("middleName")] public string MiddleName { get; set; }
[JsonPropertyName("fullName")] public string FullName { get; set; }
[JsonPropertyName("studentId")] public Guid? StudentId { get; set; }
[JsonPropertyName("specialtyCode")] public string SpecialtyCode { get; set; }
[JsonPropertyName("specialtyName")] public string SpecialtyName { get; set; }
[JsonPropertyName("specialtyProfile")] public string SpecialtyProfile { get; set; }
}
#pragma warning restore CS8618
#pragma warning restore CS8601
#pragma warning restore CS8603

View File

@@ -0,0 +1,115 @@
using System.ComponentModel;
namespace ModeusSchedule.Abstractions.DTO;
/// <summary>
/// DTO для запроса расписания в Modeus.
/// </summary>
public class ModeusScheduleRequest(
int size,
DateTime timeMin,
DateTime timeMax,
List<Guid>? roomId,
List<Guid>? attendeePersonId,
List<Guid>? courseUnitRealizationId,
List<Guid>? cycleRealizationId,
List<string>? specialtyCode,
List<int>? learningStartYear,
List<string>? profileName,
List<Guid>? curriculumId,
List<string>? typeId)
{
/// <summary>
/// Количество элементов в ответе.
/// </summary>
[DefaultValue(10)]
public int Size { get; set; } = size;
/// <summary>
/// Начальная дата и время.
/// </summary>
public DateTime TimeMin { get; set; } = timeMin;
/// <summary>
/// Конечная дата и время.
/// </summary>
public DateTime TimeMax { get; set; } = timeMax;
/// <summary>
/// Список идентификаторов аудиторий. (Guid)
/// </summary>
public List<Guid>? RoomId { get; set; } = roomId;
/// <summary>
/// Список идентификаторов участников.
/// </summary>
public List<Guid>? AttendeePersonId { get; set; } = attendeePersonId;
public List<Guid>? CourseUnitRealizationId { get; set; } = courseUnitRealizationId;
public List<Guid>? CycleRealizationId { get; set; } = cycleRealizationId;
/// <summary>
/// Список кодов специальностей.
/// </summary>
[DefaultValue(new[] { "09.03.04" })]
public List<string>? SpecialtyCode { get; set; } = specialtyCode;
/// <summary>
/// Список годов начала обучения.
/// </summary>
[DefaultValue(new[] { 2022, 2023, 2024, 2025 })]
public List<int>? LearningStartYear { get; set; } = learningStartYear;
/// <summary>
/// Список названий профилей подготовки.
/// </summary>
[DefaultValue(new[] { "Методы и средства разработки программного обеспечения" })]
public List<string>? ProfileName { get; set; } = profileName;
/// <summary>
/// Список идентификаторов учебных планов.
/// </summary>
public List<Guid>? CurriculumId { get; set; } = curriculumId;
/// <summary>
/// Список типов мероприятий.
/// </summary>
[DefaultValue(new[] { "MID_CHECK", "CONS", "LAB", "LECT", "SEMI", "EVENT_OTHER", "SELF", "CUR_CHECK" })]
public List<string>? TypeId { get; set; } = typeId;
}
/// <summary>
/// DTO для поиска аудиторий.
/// </summary>
public class RoomSearchRequest
{
/// <summary>
/// Название аудитории.
/// </summary>
[DefaultValue("")]
public string Name { get; set; } = "";
/// <summary>
/// Сортировка.
/// </summary>
[DefaultValue("+building.name,+name")]
public string Sort { get; set; } = "+building.name,+name";
/// <summary>
/// Количество элементов в ответе.
/// </summary>
[DefaultValue(10)]
public int Size { get; set; } = 10;
/// <summary>
/// Номер страницы. (пагинация)
/// </summary>
[DefaultValue(0)]
public int Page { get; set; } = 0;
/// <summary>
/// Исключать архивные аудитории. false = да, true = нет
/// </summary>
[DefaultValue(false)]
public bool Deleted { get; set; } = false;
}

View File

@@ -0,0 +1,591 @@
// <auto-generated />
// Вот этим сайтом https://app.quicktype.io/?l=csharp
// Не является точной копией ответа, могут быть отличия
#nullable enable
#pragma warning disable CS8618
#pragma warning disable CS8601
#pragma warning disable CS8603
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Globalization;
namespace SfeduSchedule;
public partial class Schedule
{
[JsonPropertyName("_embedded")] public Embedded Embedded { get; set; }
[JsonPropertyName("page")] public Page Page { get; set; }
}
public partial class Embedded
{
[JsonPropertyName("events")] public Event[] Events { get; set; }
[JsonPropertyName("course-unit-realizations")]
public CourseUnitRealization[] CourseUnitRealizations { get; set; }
[JsonPropertyName("cycle-realizations")]
public CycleRealization[] CycleRealizations { get; set; }
[JsonPropertyName("lesson-realization-teams")]
public LessonRealizationTeam[] LessonRealizationTeams { get; set; }
[JsonPropertyName("lesson-realizations")]
public LessonRealization[] LessonRealizations { get; set; }
[JsonPropertyName("event-locations")] public EventLocation[] EventLocations { get; set; }
[JsonPropertyName("durations")] public Duration[] Durations { get; set; }
[JsonPropertyName("event-rooms")] public EventRoom[] EventRooms { get; set; }
[JsonPropertyName("rooms")] public Room[] Rooms { get; set; }
[JsonPropertyName("buildings")] public BuildingElement[] Buildings { get; set; }
[JsonPropertyName("event-teams")] public EventTeam[] EventTeams { get; set; }
[JsonPropertyName("event-organizers")] public EventOrganizer[] EventOrganizers { get; set; }
[JsonPropertyName("event-attendees")] public EventAttendee[] EventAttendees { get; set; }
[JsonPropertyName("persons")] public Person[] Persons { get; set; }
}
public partial class BuildingElement
{
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("nameShort")] public string NameShort { get; set; }
[JsonPropertyName("address")] public string Address { get; set; }
[JsonPropertyName("searchableAddress")]
public string SearchableAddress { get; set; }
[JsonPropertyName("displayOrder")] public long DisplayOrder { get; set; }
[JsonPropertyName("_links")] public BuildingLinks Links { get; set; }
[JsonPropertyName("id")] public Guid Id { get; set; }
}
public partial class BuildingLinks
{
[JsonPropertyName("self")] public Self Self { get; set; }
}
public partial class Self
{
[JsonPropertyName("href")] public string Href { get; set; }
}
public partial class CourseUnitRealization
{
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("nameShort")] public string NameShort { get; set; }
[JsonPropertyName("prototypeId")] public Guid PrototypeId { get; set; }
[JsonPropertyName("_links")] public CourseUnitRealizationLinks Links { get; set; }
[JsonPropertyName("id")] public Guid Id { get; set; }
}
public partial class CourseUnitRealizationLinks
{
[JsonPropertyName("self")] public Self Self { get; set; }
[JsonPropertyName("planning-period")] public Self PlanningPeriod { get; set; }
}
public partial class CycleRealization
{
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("nameShort")] public string NameShort { get; set; }
[JsonPropertyName("code")] public string Code { get; set; }
[JsonPropertyName("courseUnitRealizationNameShort")]
public string CourseUnitRealizationNameShort { get; set; }
[JsonPropertyName("_links")] public CycleRealizationLinks Links { get; set; }
[JsonPropertyName("id")] public Guid Id { get; set; }
}
public partial class CycleRealizationLinks
{
[JsonPropertyName("self")] public Self Self { get; set; }
[JsonPropertyName("course-unit-realization")]
public Self CourseUnitRealization { get; set; }
}
public partial class Duration
{
[JsonPropertyName("eventId")] public Guid EventId { get; set; }
[JsonPropertyName("value")] public long Value { get; set; }
[JsonPropertyName("timeUnitId")] public string TimeUnitId { get; set; }
[JsonPropertyName("minutes")] public long Minutes { get; set; }
[JsonPropertyName("_links")] public DurationLinks Links { get; set; }
}
public partial class DurationLinks
{
[JsonPropertyName("self")] public Self[] Self { get; set; }
[JsonPropertyName("time-unit")] public Self TimeUnit { get; set; }
}
public partial class EventAttendee
{
[JsonPropertyName("roleId")] public string RoleId { get; set; }
[JsonPropertyName("roleName")] public string RoleName { get; set; }
[JsonPropertyName("roleNamePlural")] public string RoleNamePlural { get; set; }
[JsonPropertyName("roleDisplayOrder")] public long RoleDisplayOrder { get; set; }
[JsonPropertyName("_links")] public EventAttendeeLinks Links { get; set; }
[JsonPropertyName("id")] public Guid Id { get; set; }
}
public partial class EventAttendeeLinks
{
[JsonPropertyName("self")] public Self Self { get; set; }
[JsonPropertyName("event")] public Self Event { get; set; }
[JsonPropertyName("person")] public Self Person { get; set; }
}
public partial class EventLocation
{
[JsonPropertyName("eventId")] public Guid EventId { get; set; }
[JsonPropertyName("customLocation")] public string CustomLocation { get; set; }
[JsonPropertyName("_links")] public EventLocationLinks Links { get; set; }
}
public partial class EventLocationLinks
{
[JsonPropertyName("self")] public Self[] Self { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("event-rooms")]
public Self EventRooms { get; set; }
}
public partial class EventOrganizer
{
[JsonPropertyName("eventId")] public Guid EventId { get; set; }
[JsonPropertyName("_links")] public EventOrganizerLinks Links { get; set; }
}
public partial class EventOrganizerLinks
{
[JsonPropertyName("self")] public Self Self { get; set; }
[JsonPropertyName("event")] public Self Event { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("event-attendees")]
public EventAttendees? EventAttendees { get; set; }
}
public partial class EventRoom
{
[JsonPropertyName("_links")] public EventRoomLinks Links { get; set; }
[JsonPropertyName("id")] public Guid Id { get; set; }
}
public partial class EventRoomLinks
{
[JsonPropertyName("self")] public Self Self { get; set; }
[JsonPropertyName("event")] public Self Event { get; set; }
[JsonPropertyName("room")] public Self Room { get; set; }
}
public partial class EventTeam
{
[JsonPropertyName("eventId")] public Guid EventId { get; set; }
[JsonPropertyName("size")] public long Size { get; set; }
[JsonPropertyName("_links")] public EventTeamLinks Links { get; set; }
}
public partial class EventTeamLinks
{
[JsonPropertyName("self")] public Self Self { get; set; }
[JsonPropertyName("event")] public Self Event { get; set; }
}
public partial class Event
{
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("nameShort")] public string NameShort { get; set; }
[JsonPropertyName("description")] public object Description { get; set; }
[JsonPropertyName("typeId")] public string TypeId { get; set; }
[JsonPropertyName("formatId")] public string FormatId { get; set; }
[JsonPropertyName("start")] public DateTime Start { get; set; }
[JsonPropertyName("end")] public DateTime End { get; set; }
[JsonPropertyName("startsAtLocal")] public DateTime StartsAtLocal { get; set; }
[JsonPropertyName("endsAtLocal")] public DateTime EndsAtLocal { get; set; }
[JsonPropertyName("startsAt")] public DateTime StartsAt { get; set; }
[JsonPropertyName("endsAt")] public DateTime EndsAt { get; set; }
[JsonPropertyName("holdingStatus")] public HoldingStatus HoldingStatus { get; set; }
[JsonPropertyName("repeatedLessonRealization")]
public RepeatedLessonRealization RepeatedLessonRealization { get; set; }
[JsonPropertyName("userRoleIds")] public string[] UserRoleIds { get; set; }
[JsonPropertyName("lessonTemplateId")] public Guid? LessonTemplateId { get; set; }
[JsonPropertyName("__version")] public long Version { get; set; }
[JsonPropertyName("_links")] public Dictionary<string, Self> Links { get; set; }
[JsonPropertyName("id")] public Guid Id { get; set; }
}
public partial class HoldingStatus
{
[JsonPropertyName("id")] public string Id { get; set; }
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("audModifiedAt")] public DateTimeOffset? AudModifiedAt { get; set; }
[JsonPropertyName("audModifiedBy")] public Guid? AudModifiedBy { get; set; }
[JsonPropertyName("audModifiedBySystem")]
public bool? AudModifiedBySystem { get; set; }
}
public partial class RepeatedLessonRealization
{
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("lessonTeamName")] public string LessonTeamName { get; set; }
}
public partial class LessonRealizationTeam
{
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("cycleRealizationId")]
public Guid CycleRealizationId { get; set; }
[JsonPropertyName("_links")] public BuildingLinks Links { get; set; }
[JsonPropertyName("id")] public Guid Id { get; set; }
}
public partial class LessonRealization
{
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("nameShort")] public string NameShort { get; set; }
[JsonPropertyName("prototypeId")] public Guid PrototypeId { get; set; }
[JsonPropertyName("ordinal")] public long Ordinal { get; set; }
[JsonPropertyName("_links")] public BuildingLinks Links { get; set; }
[JsonPropertyName("id")] public Guid Id { get; set; }
}
public partial class Person
{
[JsonPropertyName("lastName")] public string LastName { get; set; }
[JsonPropertyName("firstName")] public string FirstName { get; set; }
[JsonPropertyName("middleName")] public string MiddleName { get; set; }
[JsonPropertyName("fullName")] public string FullName { get; set; }
[JsonPropertyName("_links")] public BuildingLinks Links { get; set; }
[JsonPropertyName("id")] public Guid Id { get; set; }
}
public partial class Room
{
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("nameShort")] public string NameShort { get; set; }
[JsonPropertyName("building")] public RoomBuilding Building { get; set; }
[JsonPropertyName("projectorAvailable")]
public bool ProjectorAvailable { get; set; }
[JsonPropertyName("totalCapacity")] public long TotalCapacity { get; set; }
[JsonPropertyName("workingCapacity")] public long WorkingCapacity { get; set; }
[JsonPropertyName("deletedAtUtc")] public object DeletedAtUtc { get; set; }
[JsonPropertyName("_links")] public RoomLinks Links { get; set; }
[JsonPropertyName("id")] public Guid Id { get; set; }
}
public partial class RoomBuilding
{
[JsonPropertyName("id")] public Guid Id { get; set; }
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("nameShort")] public string NameShort { get; set; }
[JsonPropertyName("address")] public string Address { get; set; }
[JsonPropertyName("displayOrder")] public long DisplayOrder { get; set; }
}
public partial class RoomLinks
{
[JsonPropertyName("self")] public Self Self { get; set; }
[JsonPropertyName("type")] public Self Type { get; set; }
[JsonPropertyName("building")] public Self Building { get; set; }
}
public partial class Page
{
[JsonPropertyName("size")] public long Size { get; set; }
[JsonPropertyName("totalElements")] public long TotalElements { get; set; }
[JsonPropertyName("totalPages")] public long TotalPages { get; set; }
[JsonPropertyName("number")] public long Number { get; set; }
}
public partial struct EventAttendees
{
public Self Self;
public Self[] SelfArray;
public static implicit operator EventAttendees(Self Self) => new EventAttendees { Self = Self };
public static implicit operator EventAttendees(Self[] SelfArray) => new EventAttendees { SelfArray = SelfArray };
}
public partial class Schedule
{
public static Schedule FromJson(string json) =>
JsonSerializer.Deserialize<Schedule>(json, SfeduSchedule.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this Schedule self) => JsonSerializer.Serialize(self, SfeduSchedule.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
{
Converters =
{
EventAttendeesConverter.Singleton,
new DateOnlyConverter(),
new TimeOnlyConverter(),
IsoDateTimeOffsetConverter.Singleton
},
};
}
internal class EventAttendeesConverter : JsonConverter<EventAttendees>
{
public override bool CanConvert(Type t) => t == typeof(EventAttendees);
public override EventAttendees Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case JsonTokenType.StartObject:
var objectValue = JsonSerializer.Deserialize<Self>(ref reader, options);
return new EventAttendees { Self = objectValue };
case JsonTokenType.StartArray:
var arrayValue = JsonSerializer.Deserialize<Self[]>(ref reader, options);
return new EventAttendees { SelfArray = arrayValue };
}
throw new Exception("Cannot unmarshal type EventAttendees");
}
public override void Write(Utf8JsonWriter writer, EventAttendees value, JsonSerializerOptions options)
{
if (value.SelfArray != null)
{
JsonSerializer.Serialize(writer, value.SelfArray, options);
return;
}
if (value.Self != null)
{
JsonSerializer.Serialize(writer, value.Self, options);
return;
}
throw new Exception("Cannot marshal type EventAttendees");
}
public static readonly EventAttendeesConverter Singleton = new EventAttendeesConverter();
}
public class DateOnlyConverter : JsonConverter<DateOnly>
{
private readonly string serializationFormat;
public DateOnlyConverter() : this(null)
{
}
public DateOnlyConverter(string? serializationFormat)
{
this.serializationFormat = serializationFormat ?? "yyyy-MM-dd";
}
public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetString();
return DateOnly.Parse(value!);
}
public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToString(serializationFormat));
}
public class TimeOnlyConverter : JsonConverter<TimeOnly>
{
private readonly string serializationFormat;
public TimeOnlyConverter() : this(null)
{
}
public TimeOnlyConverter(string? serializationFormat)
{
this.serializationFormat = serializationFormat ?? "HH:mm:ss.fff";
}
public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetString();
return TimeOnly.Parse(value!);
}
public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToString(serializationFormat));
}
internal class IsoDateTimeOffsetConverter : JsonConverter<DateTimeOffset>
{
public override bool CanConvert(Type t) => t == typeof(DateTimeOffset);
private const string DefaultDateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind;
private string? _dateTimeFormat;
private CultureInfo? _culture;
public DateTimeStyles DateTimeStyles
{
get => _dateTimeStyles;
set => _dateTimeStyles = value;
}
public string? DateTimeFormat
{
get => _dateTimeFormat ?? string.Empty;
set => _dateTimeFormat = (string.IsNullOrEmpty(value)) ? null : value;
}
public CultureInfo Culture
{
get => _culture ?? CultureInfo.CurrentCulture;
set => _culture = value;
}
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
{
string text;
if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
|| (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
{
value = value.ToUniversalTime();
}
text = value.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
writer.WriteStringValue(text);
}
public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
string? dateText = reader.GetString();
if (string.IsNullOrEmpty(dateText) == false)
{
if (!string.IsNullOrEmpty(_dateTimeFormat))
{
return DateTimeOffset.ParseExact(dateText, _dateTimeFormat, Culture, _dateTimeStyles);
}
else
{
return DateTimeOffset.Parse(dateText, Culture, _dateTimeStyles);
}
}
else
{
return default(DateTimeOffset);
}
}
public static readonly IsoDateTimeOffsetConverter Singleton = new IsoDateTimeOffsetConverter();
}
#pragma warning restore CS8618
#pragma warning restore CS8601
#pragma warning restore CS8603

View File

@@ -0,0 +1,12 @@
using System.Text.Encodings.Web;
using System.Text.Json;
namespace ModeusSchedule.Abstractions;
public static class GlobalConsts
{
public static readonly JsonSerializerOptions JsonSerializerOptions = new()
{ PropertyNamingPolicy = JsonNamingPolicy.CamelCase, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
public static string JwtFilePath { get; set; } = "data/jwt.txt";
}

View File

@@ -0,0 +1,13 @@
namespace ModeusSchedule.Abstractions;
// Базовый контракт плагина (общий для хоста и плагинов)
public interface IPlugin
{
string Name { get; }
// Регистрация сервисов плагина в DI (выполняется до Build())
void ConfigureServices(IServiceCollection services);
// Регистрация маршрутов (Minimal API) плагина после Build()
void MapEndpoints(IEndpointRouteBuilder endpoints);
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Library</OutputType>
<RootNamespace>ModeusSchedule.Abstractions</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591;CS1573</NoWarn>
</PropertyGroup>
</Project>