feat:更新elastic模块

This commit is contained in:
2025-09-25 00:08:28 +08:00
parent ef938e6d97
commit 734cd6e82a
6 changed files with 70 additions and 10 deletions

View File

@@ -4,10 +4,10 @@ from config.elastic import es, BLOG_INDEX
from schemas.blog_elastic import BlogElastic
def create_blog(blog: BlogElastic) -> bool:
def add_blog_elastic(blog: BlogElastic) -> bool:
now = datetime.now()
blog.createTime = now
blog.updateTime = now
blog.createTime = now.strftime("%Y-%m-%d %H:%M:%S")
blog.updateTime = now.strftime("%Y-%m-%d %H:%M:%S")
es.index(
index=BLOG_INDEX,
@@ -18,8 +18,9 @@ def create_blog(blog: BlogElastic) -> bool:
return True
def update_blog(blog: BlogElastic) -> bool:
blog.updateTime = datetime.now()
def update_blog_elastic(blog: BlogElastic) -> bool:
now = datetime.now()
blog.updateTime = now.strftime("%Y-%m-%d %H:%M:%S")
es.index(
index=BLOG_INDEX,