بکاند: ویرایش جزئی (PATCH) و ترتیببندی مجموعهها برای ویرایش زنده
- PATCH /api/admin/{resource}/{id} — ویرایش جزئی؛ فقط فیلدهای ارسالشده
بهروزرسانی میشوند (PUT قبلاً کل رکورد را جایگزین میکرد و برای
ویرایش زنده قابل استفاده نبود). اسکیماهای Patch بهصورت خودکار از
اسکیماهای In با create_model ساخته میشوند (هر ۲۴ منبع).
- ستون position برای ۱۴ جدول مجموعهای (خدمات، پروژهها، مقالات، نظرات،
سوالات، تیم، تایملاین، آمار، چرا آرامش، مدلهای سرمایهگذاری، مراحل کار،
دفاتر، گالری، منو) — مهاجرت سبک idempotent در startup و seed
(ALTER TABLE ADD COLUMN IF NOT EXISTS) تا دیتابیسهای موجود هم ارتقا یابند
- POST /api/admin/{resource}/reorder — ذخیره ترتیب جدید بر اساس لیست id
- خواندن عمومی بر اساس (position, id) مرتب میشود؛ رکورد جدید در انتهای لیست
- seed فقط جدولهای خالی را با position صحیح پر میکند
This commit is contained in:
@@ -35,6 +35,8 @@ class Brand(Base):
|
||||
class Service(Base):
|
||||
__tablename__ = "services"
|
||||
|
||||
position: 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="")
|
||||
@@ -44,6 +46,8 @@ class Service(Base):
|
||||
class Project(Base):
|
||||
__tablename__ = "projects"
|
||||
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
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))
|
||||
@@ -63,6 +67,8 @@ class Project(Base):
|
||||
class Article(Base):
|
||||
__tablename__ = "articles"
|
||||
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
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))
|
||||
@@ -77,6 +83,8 @@ class Article(Base):
|
||||
class Testimonial(Base):
|
||||
__tablename__ = "testimonials"
|
||||
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(128))
|
||||
role: Mapped[str] = mapped_column(String(128), default="")
|
||||
@@ -86,6 +94,8 @@ class Testimonial(Base):
|
||||
class Faq(Base):
|
||||
__tablename__ = "faqs"
|
||||
|
||||
position: 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="")
|
||||
@@ -94,6 +104,8 @@ class Faq(Base):
|
||||
class TeamMember(Base):
|
||||
__tablename__ = "team"
|
||||
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(128))
|
||||
role: Mapped[str] = mapped_column(String(128), default="")
|
||||
@@ -103,6 +115,8 @@ class TeamMember(Base):
|
||||
class TimelineItem(Base):
|
||||
__tablename__ = "timeline"
|
||||
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
year: Mapped[str] = mapped_column(String(32))
|
||||
title: Mapped[str] = mapped_column(String(256))
|
||||
@@ -113,6 +127,8 @@ class TimelineItem(Base):
|
||||
class Stat(Base):
|
||||
__tablename__ = "stats"
|
||||
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
value: Mapped[int] = mapped_column(Integer)
|
||||
suffix: Mapped[str] = mapped_column(String(16), default="")
|
||||
@@ -122,6 +138,8 @@ class Stat(Base):
|
||||
class WhyUsItem(Base):
|
||||
__tablename__ = "why_us"
|
||||
|
||||
position: 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="")
|
||||
@@ -142,6 +160,8 @@ class BeforeAfter(Base):
|
||||
class NavItem(Base):
|
||||
__tablename__ = "nav_items"
|
||||
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
label: Mapped[str] = mapped_column(String(64))
|
||||
href: Mapped[str] = mapped_column(String(128))
|
||||
@@ -215,6 +235,8 @@ class PageHeroContent(Base):
|
||||
class InvestmentModel(Base):
|
||||
__tablename__ = "investment_models"
|
||||
|
||||
position: 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="")
|
||||
@@ -224,6 +246,8 @@ class InvestmentModel(Base):
|
||||
class ProcessStep(Base):
|
||||
__tablename__ = "process_steps"
|
||||
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
step: Mapped[str] = mapped_column(String(16), default="")
|
||||
title: Mapped[str] = mapped_column(String(256))
|
||||
@@ -233,6 +257,8 @@ class ProcessStep(Base):
|
||||
class Office(Base):
|
||||
__tablename__ = "offices"
|
||||
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
city: Mapped[str] = mapped_column(String(64))
|
||||
address: Mapped[str] = mapped_column(Text, default="")
|
||||
@@ -242,6 +268,8 @@ class Office(Base):
|
||||
class GalleryImage(Base):
|
||||
__tablename__ = "gallery_images"
|
||||
|
||||
position: Mapped[int] = mapped_column(Integer, default=0)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
src: Mapped[str] = mapped_column(Text, default="")
|
||||
alt: Mapped[str] = mapped_column(Text, default="")
|
||||
|
||||
Reference in New Issue
Block a user