class Post(db.Model): __tablename__ = "user_post" id = db.Column(db.Integer(), primary_key=True, autoincrement=True) title = db.Column(db.String(100)) text = db.Column(db.Text()) publish_date = db.Column(db.DateTime()) user_id = db.Column(db.Integer(), db.ForeignKey('user.id'))
class bbs_user(db.Model): __tablename__ = "bbs_user" uid = db.Column(db.Integer(11), primary_key=True, autoincrement=True) # 自增id username = db.Column(db.String(16), nullable=False) # 帐号 password = db.Column(db.String(256), nullable=False) # 密码(md5加密) email = db.Column(db.String(32), nullable=False) # 邮箱 udertype = db.Column(db.Boolean(), nullable=False, default=False) # 帐号类型 regtime = db.Column(db.DateTime, nullable=False, default=datetime.datetime.now()) # 注册时间 lasttime = db.Column(db.DateTime, nullable=False, default=datetime.datetime.now()) # 最后登录时间 regip = db.Column(db.Integer(12), nullable=False) # 注册IP picture = db.Column(db.String(256), nullable=False, default='/static/img/timg.jpeg') # 头像 grade = db.Column(db.Integer(10), nullable=True, default=0) # 积分 problem = db.Column(db.String(256), nullable=True) # 找回密码 result = db.Column(db.String(256), nullable=True) # 答案 realname = db.Column(db.String(50), nullable=True) # 真实姓名 sex = db.Column(db.Boolean(), nullable=True, default=False) # 性别 birthday = db.Column(db.String(32), nullable=True) # 生日 place = db.Column(db.String(64), nullable=True) # 所在地 qq = db.Column(db.String(16), nullable=True) # qq号 autograph = db.Column(db.String(512), nullable=True) # 个人签名 allowlogin = db.Column(db.Boolean(), nullable=False, default=False) # 是否允许登录
class Students(BaseModel, db.Model): __tablename__ = 'Students' student_id = db.Column(db.Integer(), primary_key=True) student_name = db.Column(db.String(50)) student_password = db.Column(db.String(128)) lab_id = db.Column(db.Integer(), db.ForeignKey('Labs.lab_id')) admin = db.Column(db.Boolean, default=False) is_delete = db.Column(db.Boolean, default=False) #is_login = db.Column(db.Boolean, default=False) @property def stu_password(self): return self.student_password @stu_password.setter def stu_password(self, password): self.student_password = generate_password_hash(password) # 验证密码 def verify_password(self, password): return check_password_hash(self.student_password, password) # 权限判定 def check_permission(self, permission): return self.stu_permission & permission == permission def __repr__(self): return '<Students %r>' % self.student_name
class bbs_closeip(db.Model): __tablename__ = "bbs_closeip" id = db.Column(db.Integer(10), primary_key=True, nullable=False, autoincrement=True) # 自增id ip = db.Column(db.Integer(10), nullable=False) # IP地址 addtime = db.Column(db.Integer(10), nullable=False) # 记录添加时间 overtime = db.Column(db.Integer(10), nullable=True) # IP限制结束时间
class bbs_order(db.Model): __tablename__ = "bbs_order" oid = db.Column(db.Integer(10), primary_key=True, nullable=False, autoincrement=True) # 自增id uid = db.Column(db.Integer(11), nullable=False) # 用户id(外键) tid = db.Column(db.Integer(11), nullable=False) # 帖子id(外键) rate = db.Column(db.Integer(11), nullable=False) # 价格 addtime = db.Column(db.Integer(11), nullable=False) # 创建时间 ispay = db.Column(db.Boolean(), nullable=False, default=False) # 是否支付
class bbs_link(db.Model): __tablename__ = "bbs_link" lid = db.Column(db.Integer(6), primary_key=True, nullable=False, autoincrement=True) # 自增id displayorder = db.Column(db.Integer(2), nullable=False, default=0) # 排序 name = db.Column(db.String(32), nullable=False) # 名称 url = db.Column(db.String(256), nullable=False) # 链接跳转地址 description = db.Column(db.text(), nullable=True) # 描述 logo = db.Column(db.String(256), nullable=True) # logo的路由地址 addtime = db.Column(db.Integer(12), nullable=False) # 添加时间
class MediasPag_themes(db.Model): p_t_id = db.Column(db.Integer, primary_key=True, autoincrement=True) p_id = db.Column(db.Integer()) t_id = db.Column(db.Integer()) p_t_week = db.Column(db.Integer(), default=0) def model_to_dict(self): return { 'p_t_id': self.p_t_id, 'p_id': self.p_id, 't_id': self.t_id, 'p_t_week': self.p_t_week, }
class Medias(db.Model): m_id = db.Column(db.Integer, primary_key=True, autoincrement=True) m_name = db.Column(db.String(32)) m_type = db.Column(db.Integer) m_size = db.Column(db.String(32)) m_format = db.Column(db.String(16)) m_url = db.Column(db.String(256)) m_memory = db.Column(db.String(32)) u_id = db.Column(db.Integer) t_id = db.Column(db.Integer()) m_upload_time = db.Column(db.DateTime(), default=datetime.datetime.now()) def model_to_dict(self): try: m_upload_time = self.m_upload_time.strftime('%Y-%m-%d') except: m_upload_time = None return { 'm_id': self.m_id, 'm_name': self.m_name, 'm_type': self.m_type, 'm_size': self.m_size, 'm_format': self.m_format, 'm_url': self.m_url, 'm_memory': self.m_memory, 'u_id': self.u_id, 't_id': self.t_id, 'm_upload_time': self.m_upload_time, }
class Themes(db.Model): t_id = db.Column(db.Integer, primary_key=True, autoincrement=True) t_name = db.Column(db.String(32), unique=True) u_id = db.Column(db.Integer()) t_url = db.Column(db.String(256)) t_pic_loop = db.Column(db.Integer(), default=5) t_vedio_loop = db.Column(db.Integer(), default=15) t_type = db.Column(db.Integer(), default=0) def model_to_dict(self): return { 't_id': self.t_id, 't_name': self.t_name, 'u_id': self.u_id, 't_url': self.t_url, 't_pic_loop': self.t_pic_loop, 't_vedio_loop': self.t_vedio_loop, 't_type': self.t_type, }
class MediasPags(db.Model): p_id = db.Column(db.Integer, primary_key=True, autoincrement=True) p_code = db.Column(db.String(64), unique=True) p_type = db.Column(db.Integer(), default=0) def model_to_dict(self): return { 'p_id': self.p_id, 'p_code': self.p_code, 'p_type': self.p_type, }
class Labs(BaseModel, db.Model): __tablename__ = 'Labs' lab_id = db.Column(db.Integer(), primary_key=True) lab_name = db.Column(db.String(50)) lab_info = db.Column(db.String(1000)) lab_time = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) is_delete = db.Column(db.Boolean, default=False) def __repr__(self): return '<Labs %r>' % self.lab_name
class Students(BaseModel, db.Model): __tablename__ = 'Students' student_id = db.Column(db.Integer(), primary_key=True) student_name = db.Column(db.String(50)) student_password = db.Column(db.String(128)) lab_id = db.Column(db.Integer(), db.ForeignKey('Labs.lab_id')) admin = db.Column(db.Boolean, default=False) is_delete = db.Column(db.Boolean, default=False) is_login = db.Column(db.Boolean, default=False) # 密码hash加密 def stu_password(self, password): self.student_password = generate_password_hash(password) return self.student_password # 验证密码 def verify_password(self, password): return check_password_hash(self.student_password, password) # 生成token def generate_auth_token(self, expires_in=600): return token_serializer.dumps({'id': self.student_id}).decode('utf-8') # 验证token @auths.verify_token def verify_auth_token(token): try: data = token_serializer.loads(token) # data = jwt.decode(token, secret_key, algorithms=['HS256']) except: return False if 'id' in data: return Students.query.get(data['id']) # 权限判定 def check_permission(self, permission): return self.student_password & permission == permission def __repr__(self): return '<students %r>' % self.student_name
class Goods(db.Model): productid = db.Column(db.Integer(16)) productimg = db.Column(db.String(200)) productname = db.Column(db.String(100)) productlongname = db.Column(db.String(200)) isxf = db.Column(db.Integer, default=1) pmdesc = db.Column(db.String(100)) specifics = db.Column(db.String(100)) price = db.Column(db.Float, default=0) marketprice = db.Column(db.String(16)) categoryid = db.Column(db.String(16)) childcid = db.Column(db.String(16)) childcidname = db.Column(db.String(100)) dealerid = db.Column(db.String(16)) storenums = db.Column(db.Integerg, default=1) productnum = db.Column(db.Integer, default=1) class Meta: db_table = "axf_goods"
class bbs_categroy(db.Model): __tablename__ = "bbs_categroy" cid = db.Column(db.Integer(10), primary_key=True, nullable=False, autoincrement=True) # 自增id classname = db.Column(db.String(64), nullable=False) # 版块名称 parentid = db.Column(db.Integer(10), nullable=False) # 父级ID classpath = db.Column(db.String(32), nullable=True) # 关系 replycount = db.Column(db.Integer(10), nullable=False, default=0) # 回帖数量 motifcount = db.Column(db.Integer(10), nullable=False, default=0) # 帖子数量 compers = db.Column(db.String(16), nullable=True) # 版主 classpic = db.Column(db.String(256), nullable=False, default='/static/img/timg.jpeg') # 版块ICON description = db.Column(db.text(), nullable=True) # 版块描述 orderby = db.Column(db.Integer(2), nullable=False, default=0) # 排序 lastpost = db.Column(db.String(256), nullable=True) # 最后发表 namestyle = db.Column(db.String(16), nullable=True) # ispass = db.Column(db.Integer(2), nullable=False, default=1) # 审核状态
class User(db.Model): __tablename__ = "user_table" id = db.Column(db.Integer(), primary_key=True, autoincrement=True) username = db.Column(db.String(50)) password = db.Column(db.String(50))
class Animal(db.Model): __abstract__ = True id = db.Column(db.Integer(), primary_key=True, autoincrement=True) a_name = db.Column(db.String(32))