feat:更新elastic模块
This commit is contained in:
@@ -7,9 +7,11 @@ from sqlalchemy.orm import Session
|
||||
from models.blog import Blog, BlogCategory, BlogVisit, BlogContent, BlogComment
|
||||
from schemas.blog import BlogResponse, BlogQuery, BlogCategoryResponse, BlogStatsResponse, \
|
||||
BlogLatestResponse, BlogCommentCreate, BlogCommentResponse, BlogVisitResponse, BlogCreate, BlogUpdate
|
||||
from schemas.blog_elastic import BlogElastic
|
||||
from schemas.pagination import PageResult
|
||||
from schemas.paginate_query import paginate_query
|
||||
from middleware.exceptions import AppException
|
||||
from service.blog_elastic_service import add_blog_elastic
|
||||
from utils.blog_utils import get_blog_summary, get_word_count, get_read_duration
|
||||
|
||||
|
||||
@@ -126,6 +128,14 @@ def add_blog(db: Session, blog: BlogCreate) -> bool:
|
||||
db.commit()
|
||||
db.refresh(db_blog)
|
||||
|
||||
blog_elastic = BlogElastic(
|
||||
id=db_blog.id,
|
||||
title=db_blog.title,
|
||||
content=blog.content,
|
||||
category=blog.category
|
||||
)
|
||||
add_blog_elastic(blog_elastic)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user