Esempio n. 1
0
class Course(db.Model):
    __tablename__ = 'course'
    Id = db.Column(db.VARCHAR(10), primary_key=True)
    Name = db.Column(db.VARCHAR(255))
    Modules = db.Column(db.VARCHAR(255))
    start_date = db.Column(db.DATETIME)
    end_date = db.Column(db.DATETIME)
Esempio n. 2
0
class telegramGroup(db.Model):
    __tablename__ = 'telegramGroup'
    __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8mb4'}
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.VARCHAR(255))
    photo = db.Column(db.VARCHAR(255))
    username = db.Column(db.VARCHAR(255))
    date = db.Column(db.DateTime(6))

    def __init__(self, id, title, photo, username, date):
        self.id = id
        self.title = title
        self.photo = photo
        self.username = username
        self.date = date

    def __repr__(self):
        return "<teleGramGroup %r>" % self.username

    def to_json(self):
        item = self.__dict__
        if "_sa_instance_state" in item:
            del item["_sa_instance_state"]
        item['photo'] = 'http://localhost:5000/download?filepath=' + item[
            'photo']
        item['date'] = item['date'].strftime("%Y-%m-%d-%H")
        return item
Esempio n. 3
0
class Module(db.Model):
    __tablename__ = 'module'
    Id = db.Column(db.VARCHAR(10), primary_key=True)
    Name = db.Column(db.VARCHAR(255))
    start_date = db.Column(db.DATETIME)
    end_date = db.Column(db.DATETIME)
    teacher_id = db.Column(db.Integer)
Esempio n. 4
0
class User(db.Model):
    __tablename__ = 'user'  # 指定对应数据库表user
    userName = db.Column(db.VARCHAR(20))
    password = db.Column(db.VARCHAR(20))
    phoneNumber = db.Column(db.VARCHAR(20), primary_key=True)
    headPortrait = db.Column(db.VARCHAR(100))

    # userID=db.Column(db.Integer)
    # TODO 添加邮箱、手机号属性
    def __init__(self, userName, password, phoneNumber, headPortrait):
        self.userName = userName
        self.password = password
        self.phoneNumber = phoneNumber
        self.headPortrait = headPortrait

    def __repr__(self):
        return '<User %r>' % self.userName

    def to_json(self):
        """将实例对象转化为json"""
        item = self.__dict__
        if "_sa_instance_state" in item:
            del item["_sa_instance_state"]
        item[
            'headPortrait'] = 'http://localhost:5000/download?filepath=' + item[
                'headPortrait']
        return item
Esempio n. 5
0
class Message(db.Model):
    __table_name__ = 'message'
    msgId = db.Column(db.Integer, primary_key=True)
    isSend = db.Column(db.Integer)
    senderId = db.Column(db.Integer)
    content = db.Column(db.VARCHAR(1000))
    createTime = db.Column(db.DateTime(6))
    intent = db.Column(db.VARCHAR(255))

    def __init__(self, msgId, isSend, senderId, content, createTime, intent):
        self.senderId = senderId
        self.msgId = msgId
        self.isSend = isSend
        self.content = content
        self.intent = intent
        self.createTime = createTime

    def __repr__(self):
        return "<Message %r>" % self.msgId

    def to_json(self):
        item = self.__dict__
        if "_sa_instance_state" in item:
            del item["_sa_instance_state"]
        item['createTime'] = item['createTime'].strftime("%Y-%m-%d-%H")
        return item
Esempio n. 6
0
class User(Base):
    __tablename__ = 'user'

    Id = Column(db.Integer, primary_key=True)
    email = db.Column(db.VARCHAR(255))
    password = db.Column(db.VARCHAR(255))
    role = db.Column(db.Integer)
    student_id = db.Column(db.Integer)
    teacher_id = db.Column(db.Integer)
Esempio n. 7
0
class Students(db.Model):
    __tablename__ = 'students'
    Id = db.Column(db.Integer, primary_key=True, default=0)
    course_id = db.Column(db.VARCHAR(10), default='cor001')
    full_name = db.Column(db.VARCHAR(35))
    home_address = db.Column(db.VARCHAR(40))
    term_address = db.Column(db.VARCHAR(40))

    def __init__(self, id, course_id, full_name, home_address, term_address):
        self.id = id
        self.course_id = course_id
        self.full_name = full_name
        self.home_address = home_address
        self.term_address = term_address
Esempio n. 8
0
class User(db.Model):
    __tablename__ = 'user'
    Id = db.Column(db.Integer, primary_key=True, default=0)
    email = db.Column(db.VARCHAR(255))
    password = db.Column(db.VARCHAR(255))
    role = db.Column(db.Integer)
    student_id = db.Column(db.Integer)
    teacher_id = db.Column(db.Integer, default=None)

    def __init__(self, id, email, password, role, student_id, teacher_id):
        self.id = id
        self.email = email
        self.password = password
        self.role = role
        self.student_id = student_id
        self.teacher_id = teacher_id
Esempio n. 9
0
class User(db.Model):
    user_id = db.Column("user_id",
                        db.INT,
                        primary_key=True,
                        nullable=False,
                        autoincrement=True)
    username = db.Column("username",
                         db.VARCHAR(length=45),
                         nullable=False,
                         unique=True)
    first_name = db.Column("first_name", db.VARCHAR(length=45), nullable=True)
    last_name = db.Column("last_name", db.VARCHAR(length=45), nullable=True)
    email = db.Column("email", db.VARCHAR(length=255), nullable=False)
    password = db.Column("password", db.VARCHAR(length=255), nullable=False)
    is_admin = db.Column("is_admin", db.BOOLEAN, default=False)
    major = db.Column("major", db.VARCHAR(length=45), nullable=True)
    token = db.Column("token",
                      db.VARCHAR(length=255),
                      nullable=False,
                      autoincrement=True)

    @property
    def serialize(self):
        return {
            "user_id": self.user_id,
            "username": self.username,
            "first_name": self.first_name,
            "last_name": self.last_name,
            "email": self.email,
            "password": self.password,
            "is_admin": self.is_admin,
            "major": self.major
        }
Esempio n. 10
0
class Room(db.Model):
    __tablename__ = 'room'
    id = db.Column(db.Integer, primary_key=True, default=0)
    name = db.Column(db.VARCHAR(255))
    date = db.Column(db.DATETIME)

    def __init__(self, id, name, date):
        self.id = id
        self.name = name
        self.date = date
Esempio n. 11
0
class Listing(db.Model):
    created_by = db.Column("created_by",
                           db.INT,
                           db.ForeignKey("user.user_id"),
                           nullable=False)
    created_on = db.Column("created_on", db.DATETIME, nullable=False)
    description = db.Column("description",
                            db.VARCHAR(length=255),
                            nullable=True)
    last_edited_on = db.Column("last_edited_on", db.DATETIME, nullable=False)
    listing_id = db.Column("listing_id",
                           db.INT,
                           primary_key=True,
                           nullable=False,
                           autoincrement=True)
    price = db.Column("price",
                      db.DECIMAL(asdecimal=False),
                      default=0.00,
                      nullable=False)
    thumbnail = db.Column("thumbnail", db.VARCHAR(length=255), nullable=True)
    title = db.Column("title", db.VARCHAR(length=45), nullable=False)
    type = db.Column("type", db.VARCHAR(length=45), nullable=True)
    approved = db.Column("approved", db.BOOLEAN, nullable=True)
    approved_by = db.Column("approved_by",
                            db.INT,
                            db.ForeignKey("user.user_id"),
                            nullable=True)

    @property
    def serialize(self):
        return {
            "listing_id": self.listing_id,
            "title": self.title,
            "description": self.description,
            "type": self.type,
            "price": self.price,
            "thumbnail": self.thumbnail,
            "created_on": self.created_on,
            "last_edited_on": self.last_edited_on,
            "created_by": self.created_by,
            "approved": self.approved,
            "approved_by": self.approved_by,
        }
Esempio n. 12
0
class Message(db.Model):
    __tablename__ = 'message'
    id = db.Column(db.Integer, primary_key=True, default=0)
    room_id = db.Column(db.Integer)
    user_id = db.Column(db.Integer)
    text = db.Column(db.VARCHAR(255))
    date = db.Column(db.DATETIME)

    def __init__(self, id, room_id, user_id, text, date):
        self.id = id
        self.room_id = room_id
        self.user_id = user_id
        self.text = text
        self.date = date
Esempio n. 13
0
class Message(db.Model):
    message_id = db.Column("message_id", db.INT, primary_key=True, nullable=False, autoincrement=True)
    sent_by = db.Column("sent_by", db.INT, db.ForeignKey("user.user_id"), nullable=False)
    sent_to = db.Column("sent_to", db.INT, db.ForeignKey("user.user_id"), nullable=False)
    message_body = db.Column("message_body", db.VARCHAR(length=1000), nullable=False)
    timestamp = db.Column("timestamp", db.DATETIME, nullable=False)
    from_admin = db.Column("from_admin", db.BOOLEAN, nullable=False)
    listing_id = db.Column("listing_id", db.INT, db.ForeignKey("listing.listing_id"), nullable=True)

    @property
    def serialize(self):
        return {
            "message_id": self.message_id,
            "sent_by": self.sent_by,
            "sent_to": self.sent_to,
            "message_body": self.message_body,
            "timestamp": self.timestamp,
            "from_admin": self.from_admin,
            "listing_id": self.listing_id
        }
Esempio n. 14
0
class telegramUser(db.Model):
    __tablename__ = 'telegramUser'
    __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8mb4'}
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.VARCHAR(255))
    last_name = db.Column(db.VARCHAR(255))
    photo = db.Column(db.VARCHAR(255))
    username = db.Column(db.VARCHAR(255))
    phone = db.Column(db.VARCHAR(255))
    label = db.Column(db.VARCHAR(255))

    def __init__(self,
                 id,
                 first_name,
                 last_name,
                 photo,
                 username,
                 phone,
                 label=None):
        self.id = id
        self.first_name = first_name
        self.last_name = last_name
        self.photo = photo
        self.username = username
        self.phone = phone
        self.label = label

    def __repr__(self):
        return "<telegramUser %r>" % self.id

    def to_json(self):
        item = self.__dict__
        if "_sa_instance_state" in item:
            del item["_sa_instance_state"]
        item['photo'] = 'http://localhost:5000/download?filepath=' + item[
            'photo']
        return item
Esempio n. 15
0
class Teacher(db.Model):
    __tablename__ = 'teacher'
    Id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.VARCHAR(255))
Esempio n. 16
0
class Course_Module(db.Model):
    __tablename__ = 'course'
    course_id = db.Column(db.VARCHAR(10), primary_key=True)
    module_id = db.Column(db.VARCHAR(10), primary_key=True)