class PointItemModel(db.Model): __tablename__ = 'point_item' id: int = db.Column(db.Integer(), primary_key=True) reason: str = db.Column(db.String()) point: int = db.Column(db.Integer()) type: bool = db.Column(db.Boolean())
class FacilityReportModel(db.Model): __tablename__ = 'facility_report' id: int = db.Column(db.Integer(), primary_key=True) student_id: str = db.Column( db.String(), db.ForeignKey('student.username', ondelete='CASCADE')) room_number: int = db.Column(db.Integer()) content: str = db.Column(db.String())
class PointHistoryModel(db.Model): __tablename__ = 'point_history' id: int = db.Column(db.Integer(), primary_key=True) student_id: str = db.Column( db.String(), db.ForeignKey('student.username', ondelete='CASCADE')) point_id: int = db.Column( db.Integer(), db.ForeignKey('point_item.id', ondelete='CASCADE')) point_date: datetime = db.Column(db.DateTime())
class PointStatusModel(db.Model): __tablename__ = 'point_status' student_id: str = db.Column(db.String(), db.ForeignKey('student.username', ondelete='CASCADE'), primary_key=True) good_point: int = db.Column(db.Integer()) bad_point: int = db.Column(db.Integer()) penalty_level: int = db.Column(db.Integer()) penalty_status: bool = db.Column(db.Boolean())
class BaseNoticeModel(db.Model): __abstract__ = True id: int = db.Column(db.Integer(), primary_key=True) post_date: datetime = db.Column(db.DateTime(), default=kst_now) title: str = db.Column(db.String()) content: str = db.Column(db.String())
class BaseStudent(db.Model): __abstract__ = True name: str = db.Column(db.String()) number: int = db.Column(db.Integer(), unique=True) email: str = db.Column(db.String(), unique=True) @classmethod async def query_by_number(cls, number: int): return await cls.query.where(cls.number == number).gino.first()
class BaseApplyModel(db.Model): __abstract__ = True id: int = db.Column(db.Integer(), primary_key=True) student_id: str = db.Column(db.String, db.ForeignKey('student.username', ondelete='CASCADE')) apply_date = db.Column(db.DateTime(), default=kst_now) @classmethod async def query_by_id(cls, id: Any): return await cls.query.where(cls.id == id).gino.first() @classmethod async def query_by_student(cls, student_id: str): return await cls.query.where(cls.student_id == student_id).gino.first()
class ExtensionApplyModel(BaseApplyModel): __tablename__ = 'apply_extension' time: int = db.Column(db.Enum(EXTENSION_TIME)) class_: int = db.Column(db.Enum(EXTENSION_CLASS)) seat: int = db.Column(db.Integer())