启动与授权-初步优化

This commit is contained in:
Cheng Zhou
2026-01-15 11:25:13 +08:00
parent 4fc5f0ee9b
commit 05c1f9579a
28 changed files with 1082 additions and 300 deletions
+7 -6
View File
@@ -5,7 +5,7 @@ from typing import Sequence
from sqlalchemy import and_, func, select
from sqlalchemy.ext.asyncio import AsyncSession
from app.models.fee_attachment import FeeAttachment
from app.models.attachment import Attachment
from app.models.special_expense import SpecialExpense
from app.models.site import Site
from app.schemas.special_expense import SpecialExpenseCreate, SpecialExpenseUpdate
@@ -48,7 +48,8 @@ async def list_special_expenses(
date_from: date | None = None,
date_to: date | None = None,
) -> Sequence[tuple[SpecialExpense, str | None, int]]:
attachment_count = func.count(FeeAttachment.id).label("attachments_count")
attachment_count = func.count(Attachment.id).label("attachments_count")
attachment_types = ["special_expense_voucher", "special_expense_invoice", "special_expense_other"]
stmt = (
select(
SpecialExpense,
@@ -57,11 +58,11 @@ async def list_special_expenses(
)
.outerjoin(Site, Site.id == SpecialExpense.center_id)
.outerjoin(
FeeAttachment,
Attachment,
and_(
FeeAttachment.entity_type == "special_expense",
FeeAttachment.entity_id == SpecialExpense.id,
FeeAttachment.is_deleted.is_(False),
Attachment.entity_type.in_(attachment_types),
Attachment.entity_id == SpecialExpense.id,
Attachment.is_deleted.is_(False),
),
)
.where(SpecialExpense.project_id == project_id)
+1 -5
View File
@@ -147,6 +147,7 @@ async def create_kickoff(
) -> KickoffMeeting:
meeting = KickoffMeeting(
study_id=study_id,
site_id=meeting_in.site_id,
kickoff_date=meeting_in.kickoff_date,
attendees=meeting_in.attendees,
created_by=created_by,
@@ -190,11 +191,6 @@ async def update_kickoff(
return meeting
async def delete_kickoff(db: AsyncSession, meeting: KickoffMeeting) -> None:
await db.delete(meeting)
await db.commit()
async def create_training_authorization(
db: AsyncSession,
study_id: uuid.UUID,