نسخه ۲ بکاند آرامش پلازا — بازنویسی کامل
- API عمومی محتوای سایت (پروژهها، مقالات، خدمات و...) - فرم تماس و خبرنامه با اعتبارسنجی سرور - پنل مدیریت با JWT و CRUD کامل + مدیریت پیامها و مشترکین - اسکریپت seed با دادههای واقعی سایت - تستشده: ۳۶/۳۶ انتهاپوینت
This commit is contained in:
+111
-112
@@ -1,160 +1,159 @@
|
||||
import enum
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from sqlalchemy import String, Integer, Text, DateTime, Boolean, Enum, JSON
|
||||
from sqlalchemy import JSON, Boolean, DateTime, Integer, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.database import Base
|
||||
from .database import Base
|
||||
|
||||
|
||||
class ProjectStatus(str, enum.Enum):
|
||||
done = "done"
|
||||
progress = "progress"
|
||||
def utcnow() -> datetime:
|
||||
return datetime.now(timezone.utc)
|
||||
|
||||
|
||||
class AdminUser(Base):
|
||||
__tablename__ = "admin_users"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
username: Mapped[str] = mapped_column(String(64), unique=True, index=True)
|
||||
hashed_password: Mapped[str] = mapped_column(String(255))
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
password_hash: Mapped[str] = mapped_column(String(255))
|
||||
|
||||
|
||||
class Brand(Base):
|
||||
"""اطلاعات کلی برند - همیشه فقط یک رکورد (id=1) دارد."""
|
||||
__tablename__ = "brand"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(255), default="")
|
||||
logo: Mapped[str] = mapped_column(String(1024), default="")
|
||||
hero: Mapped[str] = mapped_column(String(1024), default="")
|
||||
contact_bg: Mapped[str] = mapped_column(String(1024), default="")
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(128), default="")
|
||||
logo: Mapped[str] = mapped_column(Text, default="")
|
||||
hero: Mapped[str] = mapped_column(Text, default="")
|
||||
contact_bg: Mapped[str] = mapped_column(Text, default="")
|
||||
phone: Mapped[str] = mapped_column(String(64), default="")
|
||||
phone_href: Mapped[str] = mapped_column(String(64), default="")
|
||||
email: Mapped[str] = mapped_column(String(255), default="")
|
||||
address: Mapped[str] = mapped_column(String(1024), default="")
|
||||
phone_href: Mapped[str] = mapped_column(String(128), default="")
|
||||
email: Mapped[str] = mapped_column(String(128), default="")
|
||||
address: Mapped[str] = mapped_column(Text, default="")
|
||||
|
||||
|
||||
class Service(Base):
|
||||
__tablename__ = "services"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
title: Mapped[str] = mapped_column(String(255))
|
||||
desc: Mapped[str] = mapped_column(Text)
|
||||
icon: Mapped[str] = mapped_column(String(64))
|
||||
order: Mapped[int] = mapped_column(Integer, default=0)
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
title: Mapped[str] = mapped_column(String(256))
|
||||
desc: Mapped[str] = mapped_column(Text, default="")
|
||||
icon: Mapped[str] = mapped_column(String(32), default="draft")
|
||||
|
||||
|
||||
class Project(Base):
|
||||
__tablename__ = "projects"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
slug: Mapped[str] = mapped_column(String(255), unique=True, index=True)
|
||||
title: Mapped[str] = mapped_column(String(255))
|
||||
location: Mapped[str] = mapped_column(String(255))
|
||||
year: Mapped[str] = mapped_column(String(64))
|
||||
status: Mapped[ProjectStatus] = mapped_column(Enum(ProjectStatus), default=ProjectStatus.progress)
|
||||
image: Mapped[str] = mapped_column(String(1024))
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
slug: Mapped[str] = mapped_column(String(128), unique=True, index=True)
|
||||
title: Mapped[str] = mapped_column(String(256))
|
||||
location: Mapped[str] = mapped_column(String(128), default="")
|
||||
year: Mapped[str] = mapped_column(String(64), default="")
|
||||
status: Mapped[str] = mapped_column(String(16), default="done") # done | progress
|
||||
image: Mapped[str] = mapped_column(Text, default="")
|
||||
gallery: Mapped[list] = mapped_column(JSON, default=list)
|
||||
area: Mapped[str] = mapped_column(String(128))
|
||||
floors: Mapped[str] = mapped_column(String(128))
|
||||
units: Mapped[str] = mapped_column(String(128))
|
||||
client: Mapped[str] = mapped_column(String(255))
|
||||
summary: Mapped[str] = mapped_column(Text)
|
||||
area: Mapped[str] = mapped_column(String(64), default="")
|
||||
floors: Mapped[str] = mapped_column(String(64), default="")
|
||||
units: Mapped[str] = mapped_column(String(64), default="")
|
||||
client: Mapped[str] = mapped_column(String(128), default="")
|
||||
summary: Mapped[str] = mapped_column(Text, default="")
|
||||
body: Mapped[list] = mapped_column(JSON, default=list)
|
||||
order: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
|
||||
class Stat(Base):
|
||||
__tablename__ = "stats"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
value: Mapped[int] = mapped_column(Integer)
|
||||
suffix: Mapped[str] = mapped_column(String(32), default="")
|
||||
label: Mapped[str] = mapped_column(String(255))
|
||||
order: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
|
||||
class TimelineItem(Base):
|
||||
__tablename__ = "timeline_items"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
year: Mapped[str] = mapped_column(String(64))
|
||||
title: Mapped[str] = mapped_column(String(255))
|
||||
desc: Mapped[str] = mapped_column(Text)
|
||||
image: Mapped[str] = mapped_column(String(1024))
|
||||
order: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
|
||||
class WhyUsItem(Base):
|
||||
__tablename__ = "why_us_items"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
title: Mapped[str] = mapped_column(String(255))
|
||||
desc: Mapped[str] = mapped_column(Text)
|
||||
order: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
|
||||
class Testimonial(Base):
|
||||
__tablename__ = "testimonials"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(255))
|
||||
role: Mapped[str] = mapped_column(String(255))
|
||||
quote: Mapped[str] = mapped_column(Text)
|
||||
order: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
|
||||
class TeamMember(Base):
|
||||
__tablename__ = "team_members"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(255))
|
||||
role: Mapped[str] = mapped_column(String(255))
|
||||
bio: Mapped[str] = mapped_column(Text)
|
||||
photo: Mapped[str] = mapped_column(String(1024), default="")
|
||||
order: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
|
||||
class Article(Base):
|
||||
__tablename__ = "articles"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
slug: Mapped[str] = mapped_column(String(255), unique=True, index=True)
|
||||
title: Mapped[str] = mapped_column(String(255))
|
||||
date: Mapped[str] = mapped_column(String(64))
|
||||
category: Mapped[str] = mapped_column(String(128))
|
||||
image: Mapped[str] = mapped_column(String(1024))
|
||||
read: Mapped[str] = mapped_column(String(32))
|
||||
excerpt: Mapped[str] = mapped_column(Text)
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
slug: Mapped[str] = mapped_column(String(128), unique=True, index=True)
|
||||
title: Mapped[str] = mapped_column(String(256))
|
||||
date: Mapped[str] = mapped_column(String(64), default="")
|
||||
category: Mapped[str] = mapped_column(String(64), default="")
|
||||
image: Mapped[str] = mapped_column(Text, default="")
|
||||
read: Mapped[str] = mapped_column(String(32), default="")
|
||||
excerpt: Mapped[str] = mapped_column(Text, default="")
|
||||
body: Mapped[list] = mapped_column(JSON, default=list)
|
||||
order: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
|
||||
class Testimonial(Base):
|
||||
__tablename__ = "testimonials"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(128))
|
||||
role: Mapped[str] = mapped_column(String(128), default="")
|
||||
quote: Mapped[str] = mapped_column(Text, default="")
|
||||
|
||||
|
||||
class Faq(Base):
|
||||
__tablename__ = "faqs"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
q: Mapped[str] = mapped_column(String(512))
|
||||
a: Mapped[str] = mapped_column(Text)
|
||||
order: Mapped[int] = mapped_column(Integer, default=0)
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
question: Mapped[str] = mapped_column(Text)
|
||||
answer: Mapped[str] = mapped_column(Text, default="")
|
||||
|
||||
|
||||
class ContactLead(Base):
|
||||
__tablename__ = "contact_leads"
|
||||
class TeamMember(Base):
|
||||
__tablename__ = "team"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(255), default="")
|
||||
phone: Mapped[str] = mapped_column(String(64))
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(128))
|
||||
role: Mapped[str] = mapped_column(String(128), default="")
|
||||
bio: Mapped[str] = mapped_column(Text, default="")
|
||||
|
||||
|
||||
class TimelineItem(Base):
|
||||
__tablename__ = "timeline"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
year: Mapped[str] = mapped_column(String(32))
|
||||
title: Mapped[str] = mapped_column(String(256))
|
||||
desc: Mapped[str] = mapped_column(Text, default="")
|
||||
image: Mapped[str] = mapped_column(Text, default="")
|
||||
|
||||
|
||||
class Stat(Base):
|
||||
__tablename__ = "stats"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
value: Mapped[int] = mapped_column(Integer)
|
||||
suffix: Mapped[str] = mapped_column(String(16), default="")
|
||||
label: Mapped[str] = mapped_column(String(128))
|
||||
|
||||
|
||||
class WhyUsItem(Base):
|
||||
__tablename__ = "why_us"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
title: Mapped[str] = mapped_column(String(256))
|
||||
desc: Mapped[str] = mapped_column(Text, default="")
|
||||
|
||||
|
||||
class BeforeAfter(Base):
|
||||
__tablename__ = "before_after"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
title: Mapped[str] = mapped_column(String(256), default="")
|
||||
lead: Mapped[str] = mapped_column(Text, default="")
|
||||
before: Mapped[str] = mapped_column(Text, default="")
|
||||
after: Mapped[str] = mapped_column(Text, default="")
|
||||
before_label: Mapped[str] = mapped_column(String(128), default="")
|
||||
after_label: Mapped[str] = mapped_column(String(128), default="")
|
||||
|
||||
|
||||
class ContactMessage(Base):
|
||||
__tablename__ = "contact_messages"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(128))
|
||||
phone: Mapped[str] = mapped_column(String(32))
|
||||
note: Mapped[str] = mapped_column(Text, default="")
|
||||
is_read: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow)
|
||||
|
||||
|
||||
class NewsletterSubscriber(Base):
|
||||
__tablename__ = "newsletter_subscribers"
|
||||
class Subscriber(Base):
|
||||
__tablename__ = "subscribers"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
email: Mapped[str] = mapped_column(String(255), unique=True, index=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
email: Mapped[str] = mapped_column(String(256), unique=True, index=True)
|
||||
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow)
|
||||
|
||||
Reference in New Issue
Block a user