feat(server): add PATCH/DELETE /attachment/box mirroring product box ops

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-08-12 14:15:51 +08:00
parent 0ef4f0e990
commit 4d55420958
4 changed files with 235 additions and 0 deletions

View File

@@ -4,8 +4,11 @@ from sqlalchemy.orm import Session
from app.core.database import get_db
from app.models.attachment import AttachmentCategory
from app.schemas.attachment import (
AttachmentBoxDeleteResponse,
AttachmentBoxSaveRequest,
AttachmentBoxSaveResponse,
AttachmentBoxUpdateRequest,
AttachmentBoxUpdateResponse,
AttachmentConfigRequest,
AttachmentLocationRequest,
AttachmentLocationResponse,
@@ -15,9 +18,11 @@ from app.schemas.attachment import (
from app.schemas.common import ErrorResponse
from app.services.attachment_service import (
configure_attachment,
delete_attachment_box,
get_attachment_status,
register_attachment_location,
save_attachment_box,
update_attachment_box,
)
router = APIRouter(tags=["attachment"])
@@ -82,3 +87,29 @@ def post_attachment_box(
req: AttachmentBoxSaveRequest, db: Session = Depends(get_db)
):
return save_attachment_box(db, req)
@router.patch(
"/attachment/box/{item_id}",
response_model=AttachmentBoxUpdateResponse,
responses={
400: {"description": "参数非法或超量", "model": ErrorResponse},
404: {"description": "明细不存在", "model": ErrorResponse},
409: {"description": "同箱同类型重复", "model": ErrorResponse},
},
)
def patch_attachment_box(
item_id: int, req: AttachmentBoxUpdateRequest, db: Session = Depends(get_db)
):
return update_attachment_box(db, item_id, req)
@router.delete(
"/attachment/box/{item_id}",
response_model=AttachmentBoxDeleteResponse,
responses={404: {"description": "明细不存在", "model": ErrorResponse}},
)
def delete_attachment_box_endpoint(
item_id: int, db: Session = Depends(get_db)
):
return delete_attachment_box(db, item_id)