class ItemCommentModel(db.Model): __tablename__ = 'items_comments' id = db.Column(db.Integer, primary_key=True) content = db.Column(db.String(200)) created_at = db.Column(db.DateTime, server_default=db.func.current_timestamp()) item_id = db.Column(db.Integer, index=True, nullable=False) user_id = db.Column(db.Integer, index=True, nullable=False)
class TradeModel(db.Model): __tablename__ = "application" id = db.Column(db.Integer, primary_key=True) reasion = db.Column(db.String(1024), nullable=False) contact = db.Column(db.String(128), nullable=False) item_id = db.Column(db.Integer, nullable=False, index=True) user_id = db.Column(db.Integer, nullable=False, index=True) is_closed = db.Column(db.Boolean, default=False) closed_at = db.Column(db.DateTime) created_at = db.Column(db.DateTime, default=db.func.current_timestamp())
class ReportModel(db.Model): __tablename__ = "report" id = db.Column(db.Integer, primary_key=True) plaintiff_id = db.Column(db.Integer, nullable=False) accused_id = db.Column(db.Integer, nullable=False, index=True) reasion = db.Column(db.String(128), nullable=False) description = db.Column(db.String(1024), nullable=False) is_valid = db.Column(db.Boolean, nullable=False, default=0) valid_at = db.Column(db.DateTime) created_at = db.Column(db.DateTime, server_default=db.func.current_timestamp())
class CategoryModel(db.Model): __tablename__ = 'category' id = db.Column(db.Integer, primary_key=True) slug = db.Column(db.String(20), unique=True, nullable=False, index=True) name = db.Column(db.String(20), unique=True, nullable=False) order = db.Column(db.Integer, index=True, default=0) status = db.Column(db.Integer, default=False, index=True) description = db.Column(db.String(100))
class ItemModel(db.Model): __tablename__ = 'item' id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(20)) description = db.Column(db.String(512)) images = db.Column(db.String(1024), default='') location = db.Column(db.String(128)) user_id = db.Column(db.Integer, index=True, nullable=False) category_id = db.Column(db.Integer, index=True) trade_user_id = db.Column(db.Integer, index=True) is_trade = db.Column(db.Boolean, nullable=False, default=0) traded_at = db.Column(db.DateTime) created_at = db.Column(db.DateTime, server_default=db.func.current_timestamp()) updated_at = db.Column(db.DateTime, server_default=db.func.current_timestamp()) @property def images_url(self): return [qiniu.public_url(image) for image in self.images.split(',')]
class CollectionModel(db.Model): __tablename__ = "collection" id = db.Column(db.Integer, primary_key=True) item_id = db.Column(db.Integer, nullable=False) user_id = db.Column(db.Integer, nullable=False)
class RoleModel(db.Model): __tablename__ = 'role' id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(80), unique=True) description = db.Column(db.String(255))
from eorzea.extensions import db class RoleModel(db.Model): __tablename__ = 'role' id = db.Column(db.Integer(), primary_key=True) name = db.Column(db.String(80), unique=True) description = db.Column(db.String(255)) roles_users = db.Table( 'roles_users', db.Column('user_id', db.Integer(), db.ForeignKey('user.id')), db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))
class UserModel(db.Model, UserMixin): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False, index=True) password_hash = db.Column(db.String(128)) email = db.Column(db.String(128), unique=True, index=True) real_name = db.Column(db.String(128)) telephone = db.Column(db.String(11), nullable=False) sex = db.Column(db.SmallInteger, default=SexMapping.SEX_UNKNOW) address = db.Column(db.String(256)) avatar_url = db.Column(db.String(128)) active = db.Column(db.Boolean, default=True, nullable=False) # 账号状态 created_at = db.Column(db.DateTime, server_default=db.func.current_timestamp()) updated_at = db.Column(db.DateTime, server_default=db.func.current_timestamp()) @property def is_active(self): return self.active @property def user_sex(self): return get_sex(self.sex) @property def user_avatar(self): return qiniu.public_url(self.avatar_url) or ''