first commit

This commit is contained in:
2026-04-07 16:05:05 +08:00
commit 9d9bdbb1ce
136 changed files with 5103 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
from datetime import datetime
from . import db
class BaseModel(db.Model):
__abstract__ = True
id = db.Column(db.BigInteger, primary_key=True, autoincrement=True, comment="ID")
created_at = db.Column(
db.DateTime, default=datetime.utcnow, nullable=False, comment="创建时间"
)
updated_at = db.Column(
db.DateTime,
default=datetime.utcnow,
onupdate=datetime.utcnow,
nullable=False,
comment="更新时间",
)
def to_dict(self):
return {c.name: getattr(self, c.name) for c in self.__table__.columns}
def save(self):
db.session.add(self)
db.session.commit()
return self
def delete(self):
db.session.delete(self)
db.session.commit()