model.py 1.6 KB
Newer Older
梦想橡皮擦's avatar
梦想橡皮擦 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
from app import db


class EntityBase(object):
    def to_json(self):
        fields = self.__dict__
        if "_sa_instance_state" in fields:
            del fields["_sa_instance_state"]

        return fields


class School(db.Model, EntityBase):
    """
    表名,字段名
    """
    __tablename__ = "school_list"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255))
    province = db.Column(db.String(255))
    city = db.Column(db.String(255))
    feature = db.Column(db.String(255))
    hotValue = db.Column(db.String(255))
    pic = db.Column(db.String(255))
    category = db.Column(db.String(255))
    batchTimes = db.Column(db.String(255))
梦想橡皮擦's avatar
梦想橡皮擦 已提交
27

梦想橡皮擦's avatar
梦想橡皮擦 已提交
28 29 30 31 32 33 34 35 36 37 38
    def to_dict(self):
        return {
            'name': self.name,
            'province': self.province,
            'city': self.city,
            'feature': self.feature,
            'hotValue': self.hotValue,
            'pic': self.pic,
            'category': self.category,
            'batchTimes': self.batchTimes
        }
梦想橡皮擦's avatar
梦想橡皮擦 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51


class Csdn(db.Model, EntityBase):
    """
    表名,字段名
    """
    __tablename__ = "score"
    id = db.Column(db.Integer, primary_key=True)
    nickname = db.Column(db.String(255))
    username = db.Column(db.String(255))
    cateName = db.Column(db.String(255))
    totalScore = db.Column(db.Float)

梦想橡皮擦's avatar
梦想橡皮擦 已提交
52 53 54 55 56 57 58 59 60
    regtime = db.Column(db.String(255))
    yuanli = db.Column(db.Integer)

    fangwen = db.Column(db.Integer)
    yuanchuang = db.Column(db.Integer)
    zongbang = db.Column(db.Integer)
    fensi = db.Column(db.Integer)
    tie = db.Column(db.Integer)
    ip = db.Column(db.String(255))
梦想橡皮擦's avatar
梦想橡皮擦 已提交
61 62

    url = db.Column(db.String(255))