| 1234567891011121314151617181920212223242526 |
- # app/services/payment_qr_service.py
- from sqlalchemy.orm import Session
- from app.core.biz_exception import NotFoundError, PermissionDeniedError, BizLogicError
- from app.models.payment_qr import VasPaymentQR
- from app.schemas.payment_qr import VasPaymentQrCreate
- class PaymentQrService:
- def create(db: Session, data: VasPaymentQrCreate):
- rec = VasPaymentQR(**data.dict())
- db.add(rec)
- db.commit()
- db.refresh(rec)
- return rec
-
- def get_by_id(db: Session, id: int):
- obj = db.query(VasPaymentQR).filter(id == id).first()
- if not obj:
- raise NotFoundError("QR not exist")
- return obj
-
- def get_by_devid(db: Session, devid: str):
- return db.query(VasPaymentQR).filter(VasPaymentQR.devid == devid).all()
- def get_by_provider(db: Session, provider: str):
- return db.query(VasPaymentQR).filter(VasPaymentQR.provider == provider).all()
|