迁移合同费用通用附件
1、删除旧费用附件 API、CRUD、模型和专用前端面板,统一改用通用附件能力。 2、调整合同费用接口为 study_id 语义,并补充合同、凭证、发票等附件类型的权限映射。 3、将合同费用新建和编辑改为抽屉流程,详情页与列表页复用同一编辑组件。 4、补充数据库迁移、附件列表、合同费用抽屉和权限场景测试,覆盖旧权限移除与新流程。
This commit is contained in:
@@ -323,9 +323,14 @@ def require_study_not_locked():
|
||||
from app.crud import study as study_crud
|
||||
from app.crud import faq_category as faq_category_crud
|
||||
from app.crud import faq_item as faq_item_crud
|
||||
from app.crud import contract_fee as contract_fee_crud
|
||||
from app.crud import contract_fee_payment as contract_fee_payment_crud
|
||||
|
||||
async def resolve_study_id(request: Request, db: AsyncSession) -> uuid.UUID:
|
||||
raw_study_id = request.path_params.get("study_id") or request.query_params.get("study_id")
|
||||
raw_study_id = (
|
||||
request.path_params.get("study_id")
|
||||
or request.query_params.get("study_id")
|
||||
)
|
||||
if raw_study_id:
|
||||
try:
|
||||
return uuid.UUID(str(raw_study_id))
|
||||
@@ -376,6 +381,37 @@ def require_study_not_locked():
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="FAQ 不存在")
|
||||
return item.study_id
|
||||
|
||||
raw_contract_id = request.path_params.get("contract_id")
|
||||
if raw_contract_id:
|
||||
try:
|
||||
contract_id = uuid.UUID(str(raw_contract_id))
|
||||
except ValueError as exc:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="合同费用 ID 格式错误",
|
||||
) from exc
|
||||
contract = await contract_fee_crud.get_contract_fee(db, contract_id)
|
||||
if not contract or not contract.study_id:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="合同费用不存在")
|
||||
return contract.study_id
|
||||
|
||||
raw_payment_id = request.path_params.get("payment_id")
|
||||
if raw_payment_id:
|
||||
try:
|
||||
payment_id = uuid.UUID(str(raw_payment_id))
|
||||
except ValueError as exc:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="分期记录 ID 格式错误",
|
||||
) from exc
|
||||
payment = await contract_fee_payment_crud.get_payment(db, payment_id)
|
||||
if not payment:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="分期记录不存在")
|
||||
contract = await contract_fee_crud.get_contract_fee(db, payment.contract_fee_id)
|
||||
if not contract or not contract.study_id:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="合同费用不存在")
|
||||
return contract.study_id
|
||||
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="缺少项目 ID",
|
||||
|
||||
Reference in New Issue
Block a user