diff --git a/db.sqlite3 b/db.sqlite3 index e9b53cf..bc4f13b 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/elastic/es_connect.py b/elastic/es_connect.py index 2b7dacc..e1629b5 100644 --- a/elastic/es_connect.py +++ b/elastic/es_connect.py @@ -232,7 +232,7 @@ def update_by_id(doc_id, updated_data): try: # 获取文档 achievement = AchievementDocument.get(id=doc_id) - + print(doc_id) # 更新字段 if 'writer_id' in updated_data: achievement.writer_id = updated_data['writer_id'] @@ -391,6 +391,26 @@ def write_user_data(user_data): print(f"用户数据写入失败: {str(e)}") return False +def get_user_by_id(user_id): + try: + search = UserDocument.search() + search = search.query("term", user_id=user_id) + response = search.execute() + + if response.hits: + hit = response.hits[0] + return { + "user_id": hit.user_id, + "username": hit.username, + "password": hit.password, + "permission": hit.permission + } + return None + + except Exception as e: + print(f"获取用户数据失败: {str(e)}") + return None + def get_user_by_username(username): """ 根据用户名获取用户数据 diff --git a/elastic/indexes.py b/elastic/indexes.py index 8deb548..13b4ba0 100644 --- a/elastic/indexes.py +++ b/elastic/indexes.py @@ -1,5 +1,5 @@ -INDEX_NAME = "wordsearch266666789" -USER_NAME = "users_123" +INDEX_NAME = "wordsearch266666" +USER_NAME = "users" ACHIEVEMENT_INDEX_NAME = INDEX_NAME USER_INDEX_NAME = USER_NAME GLOBAL_INDEX_NAME = "global11111" diff --git a/elastic/templates/elastic/manage.html b/elastic/templates/elastic/manage.html index b8f4a89..90b090e 100644 --- a/elastic/templates/elastic/manage.html +++ b/elastic/templates/elastic/manage.html @@ -4,27 +4,191 @@
仅管理员可见。可查看、编辑、删除所有记录。
-| ID | @@ -34,32 +198,15 @@操作 | |||
|---|---|---|---|---|
| {{ it.id }} | -
- {% if it.image %}
- /media/{{ it.image }}
- {% endif %}
- |
-
- {{ it.data|safe }}
- |
- {{ it.writer_id }} | -- - - | -