1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import datetime
- from sqlalchemy import Column, Integer, String, BOOLEAN, DateTime, UniqueConstraint
- from db import BaseORMModel
- class Teacher(BaseORMModel):
- __tablename__ = "teachers"
- id = Column(Integer, primary_key=True, autoincrement=True)
- username = Column(String(20), nullable=False, comment="用户名")
- password = Column(String(64), nullable=False, comment="密码")
- name = Column(String(20), nullable=False, comment="姓名")
- sex = Column(Integer, default=0, comment="性别,0:女,1:男")
- age = Column(Integer, default=0, comment="年龄")
- phone = Column(String(11), nullable=False, comment="手机号")
- school_id = Column(Integer, nullable=False, comment="所在学校ID")
- school_name = Column(String(100), nullable=False, comment="学校名称")
- grade_id = Column(Integer, nullable=False, comment="所在年级ID")
- grade_name = Column(String(20), nullable=False, comment="年级名称")
- class_id = Column(String(50), nullable=False, comment="所在班级ID列表")
- class_name = Column(String(50), nullable=False, comment="班级名称列表")
- role_id = Column(Integer, nullable=False, comment="角色ID")
- role_name = Column(String(20), nullable=False, comment="角色名称")
- period = Column(Integer, nullable=False, comment="学段,0:小学,1:初中,2:高中")
- subject = Column(String(10), default="", comment="任教学科")
- is_first_login = Column(BOOLEAN, default=True, comment="是否第一次登录,用于强制修改密码")
- creator_id = Column(Integer, nullable=False, comment="创建人ID")
- creator_name = Column(String(32), nullable=False, comment="创建人名称")
- created_at = Column(DateTime, default=datetime.datetime.now)
- editor_id = Column(Integer, nullable=False, comment="最后编辑人ID")
- editor_name = Column(String(32), nullable=False, comment="最后编辑人名称")
- updated_at = Column(DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now)
- __table_args__ = (UniqueConstraint("phone", name="uix_teacher_phone"),)
- class Student(BaseORMModel):
- __tablename__ = "students"
- id = Column(Integer, primary_key=True, autoincrement=True)
- sno = Column(String(20), nullable=False, comment="学号")
- username = Column(String(20), nullable=False, comment="用户名")
- password = Column(String(64), nullable=False, comment="密码")
- name = Column(String(20), nullable=False, comment="姓名")
- sex = Column(Integer, default=0, comment="性别,0:女,1:男")
- age = Column(Integer, default=0, comment="年龄")
- phone = Column(String(11), nullable=False, comment="手机号")
- period = Column(Integer, nullable=False, comment="学段,0:小学,1:初中,2:高中")
- school_id = Column(Integer, nullable=False, comment="所在学校ID")
- school_name = Column(String(100), nullable=False, comment="学校名称")
- grade_id = Column(Integer, nullable=False, comment="所在年级ID")
- grade_name = Column(String(20), nullable=False, comment="年级名称")
- class_id = Column(Integer, nullable=False, comment="所在班级ID")
- class_name = Column(String(20), nullable=False, comment="班级名称")
- is_first_login = Column(BOOLEAN, default=True, comment="是否第一次登录,用于强制修改密码")
- creator_id = Column(Integer, nullable=False, comment="创建人ID")
- creator_name = Column(String(32), nullable=False, comment="创建人名称")
- created_at = Column(DateTime, default=datetime.datetime.now)
- editor_id = Column(Integer, nullable=False, comment="最后编辑人ID")
- editor_name = Column(String(32), nullable=False, comment="最后编辑人名称")
- updated_at = Column(DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now)
- __table_args__ = (
- UniqueConstraint("sno", "school_id", name="uix_student_sno_school"),
- UniqueConstraint("phone", name="uix_student_phone"),
- )
- class Admin(BaseORMModel):
- __tablename__ = "admins"
- id = Column(Integer, primary_key=True, autoincrement=True)
- username = Column(String(64), nullable=False)
- password = Column(String(64), nullable=False)
- name = Column(String(32), default="")
- phone = Column(String(32), nullable=False, comment="手机号")
- role_id = Column(Integer, nullable=False, comment="角色ID")
- is_active = Column(BOOLEAN(), default=True, comment="是否激活")
- last_login_time = Column(DateTime, onupdate=datetime.datetime.now, comment="最后登录时间")
- last_login_ip = Column(String(15), default="", comment="最后登录IP")
- creator_id = Column(Integer, nullable=False, comment="创建人ID")
- creator_name = Column(String(32), nullable=False, comment="创建人名称")
- created_at = Column(DateTime, default=datetime.datetime.now)
- editor_id = Column(Integer, nullable=False, comment="最后编辑人ID")
- editor_name = Column(String(32), nullable=False, comment="最后编辑人名称")
- updated_at = Column(DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now)
- __table_args__ = (UniqueConstraint("phone", name="uix_sysuser_phone"),
- UniqueConstraint("username", name="uix_sysuser_username"))
|