поправила немного модели на фронте для нормальной десериализации данных
This commit is contained in:
@@ -1,11 +1,23 @@
|
||||
namespace DataModels.Enums
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DataModels.Enums
|
||||
{
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public enum OrderType
|
||||
{
|
||||
AddStudentOrder, // приказ о зачислении
|
||||
ExpulsionOrder, // приказ об отчислении
|
||||
AcademicLeaveOrder, // приказ об академическом отпуске
|
||||
ChangeSpecializationOrder, // приказ о переводе на другое направление
|
||||
NextCourseOrder // приказ о переводе на следующий курс
|
||||
[JsonPropertyName("AddStudentOrder")]
|
||||
AddStudent,
|
||||
|
||||
[JsonPropertyName("ExpulsionOrder")]
|
||||
Expulsion,
|
||||
|
||||
[JsonPropertyName("AcademicLeaveOrder")]
|
||||
AcademicLeave,
|
||||
|
||||
[JsonPropertyName("ChangeSpecializationOrder")]
|
||||
ChangeSpecialization,
|
||||
|
||||
[JsonPropertyName("NextCourseOrder")]
|
||||
NextCourse
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,29 @@
|
||||
namespace DataModels.Enums
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DataModels.Enums
|
||||
{
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public enum Reason
|
||||
{
|
||||
// зачисление
|
||||
ByGeneralContest,
|
||||
ByPrivilege,
|
||||
// отчисление
|
||||
ByChoice,
|
||||
ByLearningFailure,
|
||||
// академ
|
||||
ByMedical,
|
||||
ByFamily,
|
||||
// перевод
|
||||
//ByChoice
|
||||
// Зачисление
|
||||
[JsonPropertyName("ByGeneralContest")]
|
||||
GeneralContest,
|
||||
|
||||
[JsonPropertyName("ByPrivilege")]
|
||||
Privilege,
|
||||
|
||||
// Отчисление
|
||||
[JsonPropertyName("ByChoice")]
|
||||
Choice,
|
||||
|
||||
[JsonPropertyName("ByLearningFailure")]
|
||||
LearningFailure,
|
||||
|
||||
// Академ
|
||||
[JsonPropertyName("ByMedical")]
|
||||
Medical,
|
||||
|
||||
[JsonPropertyName("ByFamily")]
|
||||
Family
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,16 @@ namespace DataModels.Enums
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public enum Status
|
||||
{
|
||||
Обучается = 1,
|
||||
Академ = 2,
|
||||
Отчислен = 3,
|
||||
Выпущен = 4,
|
||||
[JsonPropertyName("Обучается")]
|
||||
Studying = 1,
|
||||
|
||||
[JsonPropertyName("Академ")]
|
||||
AcademicLeave = 2,
|
||||
|
||||
[JsonPropertyName("Отчислен")]
|
||||
Expelled = 3,
|
||||
|
||||
[JsonPropertyName("Выпущен")]
|
||||
Graduated = 4
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,44 @@
|
||||
using DataModels.Enums;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
using Xceed.Words.NET;
|
||||
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public abstract class AbstractOrder : Model
|
||||
{
|
||||
public List<Student?>? Students { get; set; }
|
||||
[JsonPropertyName("students")]
|
||||
[JsonIgnore] // Чтобы избежать циклических ссылок
|
||||
public virtual List<Student> Students { get; set; } = new List<Student>();
|
||||
|
||||
[JsonPropertyName("order_type")]
|
||||
public OrderType? OrderType { get; set; }
|
||||
|
||||
[JsonPropertyName("reason")]
|
||||
public Reason? Reason { get; set; }
|
||||
|
||||
[JsonPropertyName("number")]
|
||||
public int? Number { get; set; }
|
||||
|
||||
[JsonPropertyName("current_dean_id")]
|
||||
[ForeignKey("Dean")]
|
||||
public int? CurrentDeanId { get; set; }
|
||||
|
||||
[JsonPropertyName("date")]
|
||||
public DateTime? Date { get; set; } = DateTime.Now;
|
||||
|
||||
[JsonPropertyName("document")]
|
||||
[Column(TypeName = "bytea")]
|
||||
public byte[]? Document { get; set; }
|
||||
|
||||
// Навигационное свойство
|
||||
[JsonIgnore]
|
||||
public virtual Dean? Dean { get; set; }
|
||||
|
||||
// Абстрактные методы для работы с документами
|
||||
[JsonIgnore]
|
||||
public abstract string TemplatePath { get; }
|
||||
|
||||
public abstract void FillTemplate(DocX doc);
|
||||
public void CreateDocument(string path)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
namespace DataModels.Models
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public class Dean : User
|
||||
{
|
||||
[JsonPropertyName("faculty_id")]
|
||||
[ForeignKey("Facult")]
|
||||
public int? FacultId { get; set; }
|
||||
|
||||
// Навигационное свойство
|
||||
[JsonIgnore] // Исключаем из сериализации по умолчанию
|
||||
public virtual Facult? Facult { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
namespace DataModels.Models
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public class Facult : Model
|
||||
{
|
||||
public List<Specialization?>? Specializations { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
// Навигационное свойство с явным указанием связи
|
||||
[JsonPropertyName("specializations")]
|
||||
[InverseProperty("Faculty")] // Указываем обратное свойство связи
|
||||
public virtual List<Specialization> Specializations { get; set; } = new List<Specialization>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,15 @@
|
||||
namespace DataModels.Models
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public class LearningPlan : Model
|
||||
{
|
||||
public int? SpecializationId { get; set; }
|
||||
[JsonPropertyName("specialization_id")]
|
||||
[ForeignKey("Specialization")]
|
||||
public int SpecializationId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Specialization? Specialization { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,18 @@
|
||||
namespace DataModels.Models
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public class Specialization : Model
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("code")]
|
||||
public string Code { get; set; } = string.Empty;
|
||||
public int FacultyId { get; set; } // Внешний ключ к факультету
|
||||
|
||||
[JsonPropertyName("faculty_id")]
|
||||
[ForeignKey("Faculty")]
|
||||
public int FacultyId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,31 @@
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using DataModels.Enums;
|
||||
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public class Student : User
|
||||
{
|
||||
[JsonPropertyName("specialization_id")]
|
||||
[ForeignKey("Specialization")]
|
||||
public int? SpecializationId { get; set; }
|
||||
|
||||
[JsonPropertyName("group_id")]
|
||||
[ForeignKey("Group")]
|
||||
public int? GroupId { get; set; }
|
||||
|
||||
[JsonPropertyName("status")]
|
||||
public Status? Status { get; set; }
|
||||
|
||||
// Навигационные свойства (не сериализуются по умолчанию)
|
||||
[JsonIgnore]
|
||||
public virtual Specialization? Specialization { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Group? Group { get; set; }
|
||||
|
||||
// Дополнительные вычисляемые свойства, если нужны
|
||||
[JsonPropertyName("status_text")]
|
||||
public string StatusText => Status?.ToString() ?? "Unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,23 @@
|
||||
namespace DataModels.Models
|
||||
using System.Text.Json.Serialization;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DataModels.Models
|
||||
{
|
||||
public class User : Model
|
||||
{
|
||||
[JsonPropertyName("last_name")]
|
||||
public string? LastName { get; set; } = string.Empty;
|
||||
public string? Name { get; set; } = string.Empty;
|
||||
public string? Patronymic { get; set; } = string.Empty;
|
||||
public string? Email { get; set; } = string.Empty;
|
||||
public string? Password { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("first_name")]
|
||||
public string? FirstName { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("patronymic")]
|
||||
public string? Patronymic { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("email")]
|
||||
public string? Email { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("password")]
|
||||
public string? Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
# models/learning_plan.py
|
||||
from sqlalchemy import Column, Integer, ForeignKey, LargeBinary, String
|
||||
from sqlalchemy import Column, Integer, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from .base import Model
|
||||
|
||||
class LearningPlan(Model):
|
||||
__tablename__ = "learning_plans"
|
||||
|
||||
specialization_id = Column(Integer, ForeignKey("specializations.id"))
|
||||
document = Column(LargeBinary) # PDF/docx файл учебного плана
|
||||
file_name = Column(String) # Оригинальное имя файла
|
||||
file_type = Column(String) # MIME-тип (например, "application/pdf")
|
||||
specialization_id = Column(Integer, ForeignKey("specializations.id"), nullable=False)
|
||||
|
||||
specialization = relationship("Specialization", back_populates="learning_plans")
|
||||
Reference in New Issue
Block a user