全局中文化

This commit is contained in:
Cheng Zhou
2026-01-12 11:14:04 +08:00
parent 9021c7fe2b
commit 1338fa7e2b
103 changed files with 2443 additions and 1533 deletions
+8 -8
View File
@@ -15,7 +15,7 @@ router = APIRouter()
async def _ensure_study_exists(db: AsyncSession, study_id: uuid.UUID):
study = await study_crud.get(db, study_id)
if not study:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Study not found")
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="项目不存在")
return study
@@ -42,7 +42,7 @@ async def create_subject(
entity_type="subject",
entity_id=subject.id,
action="CREATE_SUBJECT",
detail=f"Subject {subject.subject_no} created",
detail=f"受试者 {subject.subject_no} 已创建",
operator_id=current_user.id,
operator_role=current_user.role,
)
@@ -81,7 +81,7 @@ async def get_subject(
await _ensure_study_exists(db, study_id)
subject = await subject_crud.get_subject(db, subject_id)
if not subject or subject.study_id != study_id:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Subject not found")
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="受试者不存在")
return subject
@@ -100,7 +100,7 @@ async def update_subject(
await _ensure_study_exists(db, study_id)
subject = await subject_crud.get_subject(db, subject_id)
if not subject or subject.study_id != study_id:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Subject not found")
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="受试者不存在")
old_status = subject.status
updated = await subject_crud.update_subject(db, subject, subject_in)
# auto-generate visits when enrolled
@@ -108,14 +108,14 @@ async def update_subject(
await subject_crud.generate_default_visits(db, updated)
detail = None
if subject_in.status and subject_in.status != old_status:
detail = f"subject {updated.subject_no} status {old_status} -> {subject_in.status}"
detail = f"受试者 {updated.subject_no} 状态 {old_status} -> {subject_in.status}"
await audit_crud.log_action(
db,
study_id=study_id,
entity_type="subject",
entity_id=subject_id,
action="SUBJECT_STATUS_CHANGE" if detail else "UPDATE_SUBJECT",
detail=detail or "Subject updated",
detail=detail or "受试者已更新",
operator_id=current_user.id,
operator_role=current_user.role,
)
@@ -136,7 +136,7 @@ async def delete_subject(
await _ensure_study_exists(db, study_id)
subject = await subject_crud.get_subject(db, subject_id)
if not subject or subject.study_id != study_id:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Subject not found")
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="受试者不存在")
await subject_crud.delete_subject(db, subject)
await audit_crud.log_action(
db,
@@ -144,7 +144,7 @@ async def delete_subject(
entity_type="subject",
entity_id=subject_id,
action="DELETE_SUBJECT",
detail=f"Subject {subject_id} deleted",
detail=f"受试者 {subject_id} 已删除",
operator_id=current_user.id,
operator_role=current_user.role,
)