انتقال تمام محتوای متنی سایت به دیتابیس — همه متنهای فرانتاند از GET /api/site خوانده میشوند
This commit is contained in:
@@ -14,17 +14,43 @@ from ..schemas import (
|
||||
BeforeAfterOut,
|
||||
BrandIn,
|
||||
BrandOut,
|
||||
ContactSectionIn,
|
||||
ContactSectionOut,
|
||||
ContactMessageOut,
|
||||
FaqIn,
|
||||
FaqOut,
|
||||
FooterIn,
|
||||
FooterOut,
|
||||
GalleryImageIn,
|
||||
GalleryImageOut,
|
||||
HeroIn,
|
||||
HeroOut,
|
||||
InvestmentModelIn,
|
||||
InvestmentModelOut,
|
||||
LoginIn,
|
||||
MessageReadIn,
|
||||
NavItemIn,
|
||||
NavItemOut,
|
||||
NewsletterSectionIn,
|
||||
NewsletterOut,
|
||||
OfficeIn,
|
||||
OfficeOut,
|
||||
PageHeroIn,
|
||||
PageHeroOut,
|
||||
ProcessStepIn,
|
||||
ProcessStepOut,
|
||||
ProjectIn,
|
||||
ProjectOut,
|
||||
SectionHeadingIn,
|
||||
SectionHeadingOut,
|
||||
ServiceIn,
|
||||
ServiceOut,
|
||||
StatIn,
|
||||
StatOut,
|
||||
StatusLabelIn,
|
||||
StatusLabelOut,
|
||||
StoryIn,
|
||||
StoryOut,
|
||||
SubscriberOut,
|
||||
TeamMemberIn,
|
||||
TeamMemberOut,
|
||||
@@ -107,6 +133,11 @@ def register_crud(path: str, model, out_schema, create_schema) -> None:
|
||||
|
||||
# CRUD محتوا
|
||||
register_crud("brand", models.Brand, BrandOut, BrandIn)
|
||||
register_crud("nav", models.NavItem, NavItemOut, NavItemIn)
|
||||
register_crud("hero", models.Hero, HeroOut, HeroIn)
|
||||
register_crud("story", models.StorySection, StoryOut, StoryIn)
|
||||
register_crud("section-headings", models.SectionHeadingContent, SectionHeadingOut, SectionHeadingIn)
|
||||
register_crud("page-heroes", models.PageHeroContent, PageHeroOut, PageHeroIn)
|
||||
register_crud("services", models.Service, ServiceOut, ServiceIn)
|
||||
register_crud("projects", models.Project, ProjectOut, ProjectIn)
|
||||
register_crud("articles", models.Article, ArticleOut, ArticleIn)
|
||||
@@ -117,6 +148,14 @@ register_crud("timeline", models.TimelineItem, TimelineItemOut, TimelineItemIn)
|
||||
register_crud("stats", models.Stat, StatOut, StatIn)
|
||||
register_crud("why-us", models.WhyUsItem, WhyUsItemOut, WhyUsItemIn)
|
||||
register_crud("before-after", models.BeforeAfter, BeforeAfterOut, BeforeAfterIn)
|
||||
register_crud("investment-models", models.InvestmentModel, InvestmentModelOut, InvestmentModelIn)
|
||||
register_crud("process-steps", models.ProcessStep, ProcessStepOut, ProcessStepIn)
|
||||
register_crud("offices", models.Office, OfficeOut, OfficeIn)
|
||||
register_crud("gallery", models.GalleryImage, GalleryImageOut, GalleryImageIn)
|
||||
register_crud("status-labels", models.StatusLabel, StatusLabelOut, StatusLabelIn)
|
||||
register_crud("contact-section", models.ContactSectionContent, ContactSectionOut, ContactSectionIn)
|
||||
register_crud("newsletter", models.NewsletterSectionContent, NewsletterOut, NewsletterSectionIn)
|
||||
register_crud("footer", models.FooterContent, FooterOut, FooterIn)
|
||||
|
||||
|
||||
# پیامهای تماس
|
||||
|
||||
@@ -109,6 +109,11 @@ def get_site(db: Session = Depends(get_db)):
|
||||
"""همه محتوای سایت در یک درخواست — مناسب برای بارگذاری اولیه فرانتاند."""
|
||||
return {
|
||||
"brand": db.query(models.Brand).first(),
|
||||
"nav": db.query(models.NavItem).order_by(models.NavItem.id).all(),
|
||||
"hero": db.query(models.Hero).first(),
|
||||
"story": db.query(models.StorySection).first(),
|
||||
"section_headings": db.query(models.SectionHeadingContent).order_by(models.SectionHeadingContent.id).all(),
|
||||
"page_heroes": db.query(models.PageHeroContent).order_by(models.PageHeroContent.id).all(),
|
||||
"services": db.query(models.Service).all(),
|
||||
"projects": db.query(models.Project).order_by(models.Project.id).all(),
|
||||
"articles": db.query(models.Article).order_by(models.Article.id).all(),
|
||||
@@ -119,4 +124,12 @@ def get_site(db: Session = Depends(get_db)):
|
||||
"stats": db.query(models.Stat).all(),
|
||||
"why_us": db.query(models.WhyUsItem).all(),
|
||||
"before_after": db.query(models.BeforeAfter).first(),
|
||||
"investment_models": db.query(models.InvestmentModel).order_by(models.InvestmentModel.id).all(),
|
||||
"process_steps": db.query(models.ProcessStep).order_by(models.ProcessStep.id).all(),
|
||||
"offices": db.query(models.Office).order_by(models.Office.id).all(),
|
||||
"gallery": db.query(models.GalleryImage).order_by(models.GalleryImage.id).all(),
|
||||
"status_labels": db.query(models.StatusLabel).order_by(models.StatusLabel.id).all(),
|
||||
"contact_section": db.query(models.ContactSectionContent).first(),
|
||||
"newsletter": db.query(models.NewsletterSectionContent).first(),
|
||||
"footer": db.query(models.FooterContent).first(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user