feat:增加上传博客图片模块
This commit is contained in:
@@ -17,11 +17,12 @@ def sync_all_blog(db: Session) -> bool:
|
||||
if settings.ENVIRONMENT == 'dev':
|
||||
return True
|
||||
|
||||
query = select(
|
||||
stmt = select(
|
||||
Blog.id,
|
||||
Blog.title,
|
||||
BlogCategory.name.label("category"),
|
||||
BlogContent.content.label("content"),
|
||||
Blog.is_approved.label("isApproved"),
|
||||
Blog.create_time.label("createTime"),
|
||||
Blog.update_time.label("updateTime"),
|
||||
).select_from(Blog).outerjoin(
|
||||
@@ -29,7 +30,7 @@ def sync_all_blog(db: Session) -> bool:
|
||||
).outerjoin(
|
||||
BlogContent, Blog.content_id == BlogContent.id
|
||||
)
|
||||
results = db.execute(query).fetchall()
|
||||
results = db.execute(stmt).fetchall()
|
||||
|
||||
actions = [
|
||||
{
|
||||
@@ -40,6 +41,7 @@ def sync_all_blog(db: Session) -> bool:
|
||||
"title": blog.title,
|
||||
"category": blog.category,
|
||||
"content": blog.content.decode("utf-8"),
|
||||
"isApproved": blog.isApproved,
|
||||
"createTime": blog.createTime.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"updateTime": blog.updateTime.strftime("%Y-%m-%d %H:%M:%S")
|
||||
}
|
||||
@@ -106,10 +108,23 @@ def search_blog(keyword: str) -> List[BlogSearch]:
|
||||
# 构造查询请求
|
||||
body = {
|
||||
"query": {
|
||||
"multi_match": {
|
||||
"query": keyword,
|
||||
"fields": ["title^3", "content"],
|
||||
"type": "phrase"
|
||||
"bool": {
|
||||
"must": [
|
||||
{
|
||||
"multi_match": {
|
||||
"query": keyword,
|
||||
"fields": ["title^3", "content"],
|
||||
"type": "phrase"
|
||||
}
|
||||
}
|
||||
],
|
||||
"filter": [
|
||||
{
|
||||
"term": {
|
||||
"isApproved": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"highlight": {
|
||||
|
||||
Reference in New Issue
Block a user