From 282a631b9ceee9a634ee1d93751a5254ed37ccef Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期二, 18 三月 2025 10:10:48 +0800
Subject: [PATCH] 首页知识库对话-rg

---
 app/models/user_model.py |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/app/models/user_model.py b/app/models/user_model.py
index 10b3fed..9a23226 100644
--- a/app/models/user_model.py
+++ b/app/models/user_model.py
@@ -189,7 +189,7 @@
 
 
     def encrypted_password(self, password):
-        return cipher_suite.encrypt(password.encode("utf-8")).decode("utf-8")
+        return cipher_suite.encrypt(str(password).encode("utf-8")).decode("utf-8")
 
     def decrypted_password(self):
         return cipher_suite.decrypt(self.password).decode("utf-8")
@@ -255,10 +255,26 @@
             'access_token': self.access_token,
             'refresh_token': self.refresh_token,
         }
-    @staticmethod
-    def encrypted_password(password):
-        return cipher_suite.encrypt(password.encode("utf-8")).decode("utf-8")
 
-    @staticmethod
-    def decrypted_password(password):
-        return cipher_suite.decrypt(password).decode("utf-8")
\ No newline at end of file
+
+
+class UserApiTokenModel(Base):
+    __tablename__ = "user_api_token"
+    id = Column(Integer, primary_key=True)
+    user_id = Column(Integer)
+    token = Column(String(40), index=True)
+    created_at = Column(DateTime, default=datetime.now())
+    updated_at = Column(DateTime, default=datetime.now())
+    expires_at = Column(DateTime)
+    is_active = Column(Integer, default=1)
+
+    def to_json(self):
+        return {
+            'id': self.id,
+            'account': self.username,
+            'createTime': self.created_at,
+            'updateTime': self.updated_at,
+            'password': self.password,
+            'access_token': self.access_token,
+            'refresh_token': self.refresh_token,
+        }
\ No newline at end of file

--
Gitblit v1.8.0