feat(backend): add public pound-qr endpoint by inventory id
Expose a read-only payload for the shared weighbridge QR card without auth. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8994849292
commit
87ed40512c
4 files changed
+108
No files matched your search
@@ -19,6 +19,7 @@ from app.models.db_models import DbInboundOutbound
|
||||
from app.models.pl_models import PlPlan, PlTransportDbLink
|
||||
from app.schemas.db.public_inventory import PublicInventoryFeedback, PublicInventoryPageRead
|
||||
from app.services.db.mappers import inventory_date_to_api
|
||||
from app.services.db.pound_qr_public import build_public_pound_qr_read
|
||||
|
||||
router = APIRouter(prefix="/public/db/inventory", tags=["地磅-出入库现场公共"])
|
||||
|
||||
@@ -97,6 +98,19 @@ def _build_public_page(db: Session, inventory: DbInboundOutbound) -> PublicInven
|
||||
)
|
||||
|
||||
|
||||
@router.get("/{inventory_id}/pound-qr")
|
||||
def get_public_pound_qr(inventory_id: str, db: Session = Depends(get_db)):
|
||||
row = (
|
||||
db.query(DbInboundOutbound)
|
||||
.filter(DbInboundOutbound.id == inventory_id, DbInboundOutbound.del_flag == 0)
|
||||
.first()
|
||||
)
|
||||
if not row:
|
||||
raise HTTPException(status_code=404, detail="链接无效或单据不存在")
|
||||
read = build_public_pound_qr_read(row, quantity_unit="吨")
|
||||
return success_response(read.model_dump(by_alias=True))
|
||||
|
||||
|
||||
@router.get("/{token}")
|
||||
def get_public_inventory(token: str, db: Session = Depends(get_db)):
|
||||
inventory = _get_inventory_by_token(db, token)
|
||||
|
||||
Reference in new issue
Block a user