完成基本审核功能
Change-Id: Ib93823f864d5340b034a37af4e4cb3fb2cd5491a
diff --git a/TRM/back/app/models/__pycache__/__init__.cpython-310.pyc b/TRM/back/app/models/__pycache__/__init__.cpython-310.pyc
index f30dbeb..015de51 100644
--- a/TRM/back/app/models/__pycache__/__init__.cpython-310.pyc
+++ b/TRM/back/app/models/__pycache__/__init__.cpython-310.pyc
Binary files differ
diff --git a/TRM/back/app/models/__pycache__/post.cpython-310.pyc b/TRM/back/app/models/__pycache__/post.cpython-310.pyc
index 263b592..8d33351 100644
--- a/TRM/back/app/models/__pycache__/post.cpython-310.pyc
+++ b/TRM/back/app/models/__pycache__/post.cpython-310.pyc
Binary files differ
diff --git a/TRM/back/app/models/__pycache__/topics.cpython-310.pyc b/TRM/back/app/models/__pycache__/topics.cpython-310.pyc
index e291b93..fba569b 100644
--- a/TRM/back/app/models/__pycache__/topics.cpython-310.pyc
+++ b/TRM/back/app/models/__pycache__/topics.cpython-310.pyc
Binary files differ
diff --git a/TRM/back/app/models/__pycache__/users.cpython-310.pyc b/TRM/back/app/models/__pycache__/users.cpython-310.pyc
index e6286c3..155a86c 100644
--- a/TRM/back/app/models/__pycache__/users.cpython-310.pyc
+++ b/TRM/back/app/models/__pycache__/users.cpython-310.pyc
Binary files differ
diff --git a/TRM/back/app/models/token.py b/TRM/back/app/models/token.py
new file mode 100644
index 0000000..cbe864b
--- /dev/null
+++ b/TRM/back/app/models/token.py
@@ -0,0 +1,27 @@
+from sqlalchemy import Column, Integer, String, DateTime, TIMESTAMP, Index
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.sql import func
+from datetime import datetime
+
+Base = declarative_base()
+
+class Token(Base):
+ __tablename__ = 'tokens'
+
+ id = Column(Integer, primary_key=True, autoincrement=True)
+ token = Column(String(255), nullable=False, unique=True)
+ expires_at = Column(DateTime, nullable=False)
+ created_at = Column(TIMESTAMP, default=func.current_timestamp())
+ updated_at = Column(TIMESTAMP, default=func.current_timestamp(), onupdate=func.current_timestamp())
+
+ __table_args__ = (
+ Index('idx_token', 'token'),
+ Index('idx_expires_at', 'expires_at'),
+ )
+
+ def __repr__(self):
+ return f"<Token(id={self.id}, token='{self.token[:10]}...', expires_at={self.expires_at})>"
+
+ def is_expired(self):
+ """检查token是否已过期"""
+ return datetime.now() > self.expires_at
\ No newline at end of file