瀏覽代碼

feat: 完善注释,查询合同列表添加合同签署状态过滤

天空之城 4 天之前
父節點
當前提交
8e22dc617b

+ 40 - 40
alembic/versions/a7d4b3e21c10_create_contract_center_tables.py

@@ -23,20 +23,20 @@ def upgrade() -> None:
     op.execute("DROP TABLE IF EXISTS contract_bundle")
     op.create_table(
         "contract_bundle",
-        sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
-        sa.Column("subject_type", sa.String(length=20), nullable=False),
-        sa.Column("subject_id", sa.BigInteger(), nullable=False),
-        sa.Column("subject_name", sa.String(length=120), nullable=False),
-        sa.Column("business_segment", sa.String(length=100), nullable=False),
-        sa.Column("contact_name", sa.String(length=100), nullable=False),
-        sa.Column("contact_phone", sa.String(length=20), nullable=False),
-        sa.Column("ord_id", sa.String(length=40), nullable=False),
-        sa.Column("bundle_type", sa.String(length=50), nullable=False),
-        sa.Column("status", sa.String(length=20), nullable=False, server_default="未签署"),
-        sa.Column("primary_document_id", sa.BigInteger(), nullable=True),
-        sa.Column("created_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False),
-        sa.Column("updated_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False),
-        sa.Column("delete_flag", sa.Integer(), server_default="0", nullable=False),
+        sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False, comment="合同包唯一标识"),
+        sa.Column("subject_type", sa.String(length=20), nullable=False, comment="签约主体类型(store/lawyer)"),
+        sa.Column("subject_id", sa.BigInteger(), nullable=False, comment="签约主体ID,关联门店/律师业务主键"),
+        sa.Column("subject_name", sa.String(length=120), nullable=False, comment="签约主体名称"),
+        sa.Column("business_segment", sa.String(length=100), nullable=False, comment="业务板块"),
+        sa.Column("contact_name", sa.String(length=100), nullable=False, comment="联系人姓名"),
+        sa.Column("contact_phone", sa.String(length=20), nullable=False, comment="联系人手机号"),
+        sa.Column("ord_id", sa.String(length=40), nullable=False, comment="组织标识(统一社会信用代码)"),
+        sa.Column("bundle_type", sa.String(length=50), nullable=False, comment="合同包类型(STORE_STANDARD/LAWYER_STANDARD)"),
+        sa.Column("status", sa.String(length=20), nullable=False, server_default="未签署", comment="整体状态: 未签署/审核中/已签署"),
+        sa.Column("primary_document_id", sa.BigInteger(), nullable=True, comment="主合同文档ID"),
+        sa.Column("created_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False, comment="创建时间"),
+        sa.Column("updated_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False, comment="更新时间"),
+        sa.Column("delete_flag", sa.Integer(), server_default="0", nullable=False, comment="逻辑删除(0未删/1已删)"),
         sa.PrimaryKeyConstraint("id"),
     )
     op.create_index("idx_contract_bundle_subject", "contract_bundle", ["subject_type", "subject_id"], unique=False)
@@ -44,23 +44,23 @@ def upgrade() -> None:
 
     op.create_table(
         "contract_document",
-        sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
-        sa.Column("bundle_id", sa.BigInteger(), nullable=False),
-        sa.Column("contract_type", sa.String(length=50), nullable=False),
-        sa.Column("contract_name", sa.String(length=100), nullable=False),
-        sa.Column("is_primary", sa.Integer(), nullable=False, server_default="0"),
-        sa.Column("status", sa.Integer(), nullable=False, server_default="0"),
-        sa.Column("sign_flow_id", sa.String(length=64), nullable=False),
-        sa.Column("file_id", sa.String(length=64), nullable=False),
-        sa.Column("template_url", mysql.LONGTEXT(), nullable=False),
-        sa.Column("sign_url", mysql.LONGTEXT(), nullable=False),
-        sa.Column("download_url", mysql.LONGTEXT(), nullable=False),
-        sa.Column("signing_time", sa.DateTime(), nullable=True),
-        sa.Column("effective_time", sa.DateTime(), nullable=True),
-        sa.Column("expiry_time", sa.DateTime(), nullable=True),
-        sa.Column("created_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False),
-        sa.Column("updated_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False),
-        sa.Column("delete_flag", sa.Integer(), server_default="0", nullable=False),
+        sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False, comment="合同文档唯一标识"),
+        sa.Column("bundle_id", sa.BigInteger(), nullable=False, comment="所属合同包ID"),
+        sa.Column("contract_type", sa.String(length=50), nullable=False, comment="合同类型编码(store_agreement/alipay_auth等)"),
+        sa.Column("contract_name", sa.String(length=100), nullable=False, comment="合同展示名称"),
+        sa.Column("is_primary", sa.Integer(), nullable=False, server_default="0", comment="是否主合同(1是/0否)"),
+        sa.Column("status", sa.Integer(), nullable=False, server_default="0", comment="签署状态(0未签署/1已签署)"),
+        sa.Column("sign_flow_id", sa.String(length=64), nullable=False, comment="e签宝签署流程ID"),
+        sa.Column("file_id", sa.String(length=64), nullable=False, comment="e签宝文件ID"),
+        sa.Column("template_url", mysql.LONGTEXT(), nullable=False, comment="合同模板预览URL"),
+        sa.Column("sign_url", mysql.LONGTEXT(), nullable=False, comment="签署链接URL"),
+        sa.Column("download_url", mysql.LONGTEXT(), nullable=False, comment="签署完成后的下载URL"),
+        sa.Column("signing_time", sa.DateTime(), nullable=True, comment="签署时间"),
+        sa.Column("effective_time", sa.DateTime(), nullable=True, comment="合同生效时间"),
+        sa.Column("expiry_time", sa.DateTime(), nullable=True, comment="合同到期时间"),
+        sa.Column("created_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False, comment="创建时间"),
+        sa.Column("updated_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False, comment="更新时间"),
+        sa.Column("delete_flag", sa.Integer(), server_default="0", nullable=False, comment="逻辑删除(0未删/1已删)"),
         sa.ForeignKeyConstraint(["bundle_id"], ["contract_bundle.id"]),
         sa.PrimaryKeyConstraint("id"),
     )
@@ -70,15 +70,15 @@ def upgrade() -> None:
 
     op.create_table(
         "contract_event",
-        sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
-        sa.Column("bundle_id", sa.BigInteger(), nullable=True),
-        sa.Column("document_id", sa.BigInteger(), nullable=True),
-        sa.Column("sign_flow_id", sa.String(length=64), nullable=False),
-        sa.Column("event_type", sa.String(length=50), nullable=False),
-        sa.Column("payload_json", mysql.LONGTEXT(), nullable=False),
-        sa.Column("created_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False),
-        sa.Column("updated_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False),
-        sa.Column("delete_flag", sa.Integer(), server_default="0", nullable=False),
+        sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False, comment="事件唯一标识"),
+        sa.Column("bundle_id", sa.BigInteger(), nullable=True, comment="关联合同包ID"),
+        sa.Column("document_id", sa.BigInteger(), nullable=True, comment="关联合同文档ID"),
+        sa.Column("sign_flow_id", sa.String(length=64), nullable=False, comment="e签宝签署流程ID"),
+        sa.Column("event_type", sa.String(length=50), nullable=False, comment="事件类型(esign_callback:{action})"),
+        sa.Column("payload_json", mysql.LONGTEXT(), nullable=False, comment="e签宝回调原始JSON报文"),
+        sa.Column("created_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False, comment="创建时间"),
+        sa.Column("updated_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False, comment="更新时间"),
+        sa.Column("delete_flag", sa.Integer(), server_default="0", nullable=False, comment="逻辑删除(0未删/1已删)"),
         sa.PrimaryKeyConstraint("id"),
     )
     op.create_index("idx_contract_event_sign_flow_id", "contract_event", ["sign_flow_id"], unique=False)

+ 86 - 0
alembic/versions/d8a7a6a4581c_add_column_comments_to_contract_tables.py

@@ -0,0 +1,86 @@
+"""add column comments to contract tables
+
+Revision ID: d8a7a6a4581c
+Revises: a7d4b3e21c10
+Create Date: 2026-04-13 00:00:00.000000
+
+"""
+from typing import Sequence, Union
+
+from alembic import op
+
+revision: str = "d8a7a6a4581c"
+down_revision: Union[str, Sequence[str], None] = "a7d4b3e21c10"
+branch_labels: Union[str, Sequence[str], None] = None
+depends_on: Union[str, Sequence[str], None] = None
+
+BUNDLE_COLUMNS = [
+    ("id",                   "BIGINT NOT NULL AUTO_INCREMENT", "合同包唯一标识"),
+    ("subject_type",         "VARCHAR(20) NOT NULL",           "签约主体类型(store/lawyer)"),
+    ("subject_id",           "BIGINT NOT NULL",                "签约主体ID,关联门店/律师业务主键"),
+    ("subject_name",         "VARCHAR(120) NOT NULL",          "签约主体名称"),
+    ("business_segment",     "VARCHAR(100) NOT NULL",          "业务板块"),
+    ("contact_name",         "VARCHAR(100) NOT NULL",          "联系人姓名"),
+    ("contact_phone",        "VARCHAR(20) NOT NULL",           "联系人手机号"),
+    ("ord_id",               "VARCHAR(40) NOT NULL",           "组织标识(统一社会信用代码)"),
+    ("bundle_type",          "VARCHAR(50) NOT NULL",           "合同包类型(STORE_STANDARD/LAWYER_STANDARD)"),
+    ("status",               "VARCHAR(20) NOT NULL DEFAULT '未签署'", "整体状态: 未签署/审核中/已签署"),
+    ("primary_document_id",  "BIGINT NULL",                    "主合同文档ID"),
+    ("created_time",         "DATETIME NOT NULL DEFAULT NOW()", "创建时间"),
+    ("updated_time",         "DATETIME NOT NULL DEFAULT NOW()", "更新时间"),
+    ("delete_flag",          "INT NOT NULL DEFAULT 0",         "逻辑删除(0未删/1已删)"),
+]
+
+DOCUMENT_COLUMNS = [
+    ("id",              "BIGINT NOT NULL AUTO_INCREMENT",  "合同文档唯一标识"),
+    ("bundle_id",       "BIGINT NOT NULL",                 "所属合同包ID"),
+    ("contract_type",   "VARCHAR(50) NOT NULL",            "合同类型编码(store_agreement/alipay_auth等)"),
+    ("contract_name",   "VARCHAR(100) NOT NULL",           "合同展示名称"),
+    ("is_primary",      "INT NOT NULL DEFAULT 0",          "是否主合同(1是/0否)"),
+    ("status",          "INT NOT NULL DEFAULT 0",          "签署状态(0未签署/1已签署)"),
+    ("sign_flow_id",    "VARCHAR(64) NOT NULL",            "e签宝签署流程ID"),
+    ("file_id",         "VARCHAR(64) NOT NULL",            "e签宝文件ID"),
+    ("template_url",    "LONGTEXT NOT NULL",               "合同模板预览URL"),
+    ("sign_url",        "LONGTEXT NOT NULL",               "签署链接URL"),
+    ("download_url",    "LONGTEXT NOT NULL",               "签署完成后的下载URL"),
+    ("signing_time",    "DATETIME NULL",                   "签署时间"),
+    ("effective_time",  "DATETIME NULL",                   "合同生效时间"),
+    ("expiry_time",     "DATETIME NULL",                   "合同到期时间"),
+    ("created_time",    "DATETIME NOT NULL DEFAULT NOW()", "创建时间"),
+    ("updated_time",    "DATETIME NOT NULL DEFAULT NOW()", "更新时间"),
+    ("delete_flag",     "INT NOT NULL DEFAULT 0",          "逻辑删除(0未删/1已删)"),
+]
+
+EVENT_COLUMNS = [
+    ("id",            "BIGINT NOT NULL AUTO_INCREMENT",  "事件唯一标识"),
+    ("bundle_id",     "BIGINT NULL",                     "关联合同包ID"),
+    ("document_id",   "BIGINT NULL",                     "关联合同文档ID"),
+    ("sign_flow_id",  "VARCHAR(64) NOT NULL",            "e签宝签署流程ID"),
+    ("event_type",    "VARCHAR(50) NOT NULL",            "事件类型(esign_callback:{action})"),
+    ("payload_json",  "LONGTEXT NOT NULL",               "e签宝回调原始JSON报文"),
+    ("created_time",  "DATETIME NOT NULL DEFAULT NOW()", "创建时间"),
+    ("updated_time",  "DATETIME NOT NULL DEFAULT NOW()", "更新时间"),
+    ("delete_flag",   "INT NOT NULL DEFAULT 0",          "逻辑删除(0未删/1已删)"),
+]
+
+
+def _alter_comments(table: str, columns: list[tuple[str, str, str]]) -> None:
+    for col, definition, comment in columns:
+        op.execute(f"ALTER TABLE `{table}` MODIFY COLUMN `{col}` {definition} COMMENT '{comment}'")
+
+
+def _remove_comments(table: str, columns: list[tuple[str, str, str]]) -> None:
+    for col, definition, _ in columns:
+        op.execute(f"ALTER TABLE `{table}` MODIFY COLUMN `{col}` {definition}")
+
+
+def upgrade() -> None:
+    _alter_comments("contract_bundle", BUNDLE_COLUMNS)
+    _alter_comments("contract_document", DOCUMENT_COLUMNS)
+    _alter_comments("contract_event", EVENT_COLUMNS)
+
+
+def downgrade() -> None:
+    _remove_comments("contract_event", EVENT_COLUMNS)
+    _remove_comments("contract_document", DOCUMENT_COLUMNS)
+    _remove_comments("contract_bundle", BUNDLE_COLUMNS)

+ 7 - 2
alien_contract/api/router.py

@@ -1,4 +1,4 @@
-from typing import Union, Literal
+from typing import Optional, Union, Literal
 
 from fastapi import APIRouter, Depends, Query
 
@@ -26,6 +26,7 @@ async def create_bundle(
     request: BundleCreateRequest,
     service: ContractCenterService = Depends(get_contract_service),
 ) -> Union[BundleCreateResponse, ErrorResponse]:
+    """创建合同包"""
     result = await service.create_bundle(request)
     if not result.get("success"):
         return ErrorResponse(**result)
@@ -36,11 +37,13 @@ async def create_bundle(
 async def list_bundles(
     subject_type: Literal["store", "lawyer"] = Query(...),
     subject_id: int = Query(..., gt=0),
+    status: Optional[Literal[0, 1]] = Query(None, description="文档签署状态过滤: 0=未签署, 1=已签署"),
     page: int = Query(1, ge=1),
     page_size: int = Query(10, ge=1, le=100),
     service: ContractCenterService = Depends(get_contract_service),
 ) -> PaginatedBundleResponse:
-    result = await service.list_bundles(subject_type, subject_id, page, page_size)
+    """"查询合同列表"""
+    result = await service.list_bundles(subject_type, subject_id, page, page_size, doc_status=status)
     return PaginatedBundleResponse(**result)
 
 
@@ -49,6 +52,7 @@ async def get_document_detail(
     sign_flow_id: str,
     service: ContractCenterService = Depends(get_contract_service),
 ) -> Union[dict, ErrorResponse]:
+    """查询合同详情"""
     result = await service.get_document_detail(sign_flow_id)
     if not result.get("success", True):
         return ErrorResponse(**result)
@@ -60,6 +64,7 @@ async def esign_callback(
     payload: dict,
     service: ContractCenterService = Depends(get_contract_service),
 ) -> Union[SuccessResponse, ErrorResponse]:
+    """e签宝回调"""
     result = await service.process_esign_callback(payload)
     if not result.get("success"):
         return ErrorResponse(**result)

+ 12 - 11
alien_contract/db/models/bundle.py

@@ -5,16 +5,17 @@ from alien_database.base import Base, AuditMixin
 
 
 class ContractBundle(Base, AuditMixin):
+    """合同包"""
     __tablename__ = "contract_bundle"
 
-    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
-    subject_type: Mapped[str] = mapped_column(String(20))
-    subject_id: Mapped[int] = mapped_column(BigInteger)
-    subject_name: Mapped[str] = mapped_column(String(120))
-    business_segment: Mapped[str] = mapped_column(String(100))
-    contact_name: Mapped[str] = mapped_column(String(100))
-    contact_phone: Mapped[str] = mapped_column(String(20))
-    ord_id: Mapped[str] = mapped_column(String(40))
-    bundle_type: Mapped[str] = mapped_column(String(50))
-    status: Mapped[str] = mapped_column(String(20), default="未签署")
-    primary_document_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
+    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True, comment="合同包唯一标识")
+    subject_type: Mapped[str] = mapped_column(String(20), comment="签约主体类型(store/lawyer)")
+    subject_id: Mapped[int] = mapped_column(BigInteger, comment="签约主体ID,关联门店/律师业务主键")
+    subject_name: Mapped[str] = mapped_column(String(120), comment="签约主体名称")
+    business_segment: Mapped[str] = mapped_column(String(100), comment="业务板块")
+    contact_name: Mapped[str] = mapped_column(String(100), comment="联系人姓名")
+    contact_phone: Mapped[str] = mapped_column(String(20), comment="联系人手机号")
+    ord_id: Mapped[str] = mapped_column(String(40), comment="组织标识(统一社会信用代码)")
+    bundle_type: Mapped[str] = mapped_column(String(50), comment="合同包类型(STORE_STANDARD/LAWYER_STANDARD)")
+    status: Mapped[str] = mapped_column(String(20), default="未签署", comment="整体状态: 未签署/审核中/已签署")
+    primary_document_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True, comment="主合同文档ID")

+ 15 - 14
alien_contract/db/models/document.py

@@ -8,19 +8,20 @@ from alien_database.base import Base, AuditMixin
 
 
 class ContractDocument(Base, AuditMixin):
+    """合同文档"""
     __tablename__ = "contract_document"
 
-    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
-    bundle_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("contract_bundle.id"), index=True)
-    contract_type: Mapped[str] = mapped_column(String(50))
-    contract_name: Mapped[str] = mapped_column(String(100))
-    is_primary: Mapped[int] = mapped_column(Integer, default=0)
-    status: Mapped[int] = mapped_column(Integer, default=0)
-    sign_flow_id: Mapped[str] = mapped_column(String(64), unique=True)
-    file_id: Mapped[str] = mapped_column(String(64))
-    template_url: Mapped[str] = mapped_column(LONGTEXT)
-    sign_url: Mapped[str] = mapped_column(LONGTEXT)
-    download_url: Mapped[str] = mapped_column(LONGTEXT)
-    signing_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
-    effective_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
-    expiry_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
+    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True, comment="合同文档唯一标识")
+    bundle_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("contract_bundle.id"), index=True, comment="所属合同包ID")
+    contract_type: Mapped[str] = mapped_column(String(50), comment="合同类型编码(store_agreement/alipay_auth等)")
+    contract_name: Mapped[str] = mapped_column(String(100), comment="合同展示名称")
+    is_primary: Mapped[int] = mapped_column(Integer, default=0, comment="是否主合同(1是/0否)")
+    status: Mapped[int] = mapped_column(Integer, default=0, comment="签署状态(0未签署/1已签署)")
+    sign_flow_id: Mapped[str] = mapped_column(String(64), unique=True, comment="e签宝签署流程ID")
+    file_id: Mapped[str] = mapped_column(String(64), comment="e签宝文件ID")
+    template_url: Mapped[str] = mapped_column(LONGTEXT, comment="合同模板预览URL")
+    sign_url: Mapped[str] = mapped_column(LONGTEXT, comment="签署链接URL")
+    download_url: Mapped[str] = mapped_column(LONGTEXT, comment="签署完成后的下载URL")
+    signing_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, comment="签署时间")
+    effective_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, comment="合同生效时间")
+    expiry_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, comment="合同到期时间")

+ 7 - 6
alien_contract/db/models/event.py

@@ -6,11 +6,12 @@ from alien_database.base import Base, AuditMixin
 
 
 class ContractEvent(Base, AuditMixin):
+    """合同事件"""
     __tablename__ = "contract_event"
 
-    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
-    bundle_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
-    document_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
-    sign_flow_id: Mapped[str] = mapped_column(String(64), index=True)
-    event_type: Mapped[str] = mapped_column(String(50))
-    payload_json: Mapped[str] = mapped_column(LONGTEXT)
+    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True, comment="事件唯一标识")
+    bundle_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True, comment="关联合同包ID")
+    document_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True, comment="关联合同文档ID")
+    sign_flow_id: Mapped[str] = mapped_column(String(64), index=True, comment="e签宝签署流程ID")
+    event_type: Mapped[str] = mapped_column(String(50), comment="事件类型(esign_callback:{action})")
+    payload_json: Mapped[str] = mapped_column(LONGTEXT, comment="e签宝回调原始JSON报文")

+ 5 - 2
alien_contract/repositories/contract_repo.py

@@ -68,10 +68,13 @@ class ContractRepository:
         bundles = result.scalars().all()
         return bundles, total
 
-    async def list_documents_by_bundle_ids(self, bundle_ids: list[int]) -> dict[int, list[ContractDocument]]:
+    async def list_documents_by_bundle_ids(self, bundle_ids: list[int], *, doc_status: int | None = None) -> dict[int, list[ContractDocument]]:
         if not bundle_ids:
             return {}
-        stmt = select(ContractDocument).where(ContractDocument.bundle_id.in_(bundle_ids), ContractDocument.delete_flag == 0)
+        conditions = [ContractDocument.bundle_id.in_(bundle_ids), ContractDocument.delete_flag == 0]
+        if doc_status is not None:
+            conditions.append(ContractDocument.status == doc_status)
+        stmt = select(ContractDocument).where(*conditions)
         result = await self.db.execute(stmt)
         documents = result.scalars().all()
         grouped: dict[int, list[ContractDocument]] = {}

+ 2 - 2
alien_contract/services/contract_server.py

@@ -142,10 +142,10 @@ class ContractCenterService:
             ],
         }
 
-    async def list_bundles(self, subject_type: str, subject_id: int, page: int, page_size: int) -> dict:
+    async def list_bundles(self, subject_type: str, subject_id: int, page: int, page_size: int, *, doc_status: int | None = None) -> dict:
         bundles, total = await self.repo.list_bundles(subject_type, subject_id, page, page_size)
         ids = [b.id for b in bundles]
-        docs_map = await self.repo.list_documents_by_bundle_ids(ids)
+        docs_map = await self.repo.list_documents_by_bundle_ids(ids, doc_status=doc_status)
         items = []
         for b in bundles:
             docs = docs_map.get(b.id, [])