管理后台前后端逻辑、UI美化
This commit is contained in:
@@ -18,6 +18,8 @@ async def _validate_site(db: AsyncSession, study_id: uuid.UUID, site_id: uuid.UU
|
||||
site = result.scalar_one_or_none()
|
||||
if not site or site.study_id != study_id:
|
||||
raise ValueError("分中心不属于当前项目")
|
||||
if not site.is_active:
|
||||
raise ValueError("中心已停用")
|
||||
|
||||
|
||||
async def create_subject(db: AsyncSession, study_id: uuid.UUID, subject_in: SubjectCreate) -> Subject:
|
||||
@@ -58,16 +60,10 @@ async def list_subjects(
|
||||
db: AsyncSession,
|
||||
study_id: uuid.UUID,
|
||||
site_id: uuid.UUID | None = None,
|
||||
status: str | None = None,
|
||||
subject_no: str | None = None,
|
||||
) -> Sequence[Subject]:
|
||||
stmt = select(Subject).where(Subject.study_id == study_id)
|
||||
if site_id:
|
||||
stmt = stmt.where(Subject.site_id == site_id)
|
||||
if status:
|
||||
stmt = stmt.where(Subject.status == status)
|
||||
if subject_no:
|
||||
stmt = stmt.where(Subject.subject_no.ilike(f"%{subject_no}%"))
|
||||
result = await db.execute(stmt)
|
||||
return result.scalars().all()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user