mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: products crud
This commit is contained in:
parent
7d81afc396
commit
4c8cb42978
12 changed files with 677 additions and 39 deletions
|
|
@ -10,6 +10,9 @@ from src.services.payments.payments import (
|
|||
update_payments_config,
|
||||
delete_payments_config,
|
||||
)
|
||||
from src.db.payments.payments_products import PaymentsProduct, PaymentsProductCreate, PaymentsProductRead, PaymentsProductUpdate
|
||||
from src.services.payments.payments_products import create_payments_product, delete_payments_product, get_payments_product, list_payments_products, update_payments_product
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
|
@ -51,3 +54,54 @@ async def api_delete_payments_config(
|
|||
):
|
||||
await delete_payments_config(request, org_id, current_user, db_session)
|
||||
return {"message": "Payments config deleted successfully"}
|
||||
|
||||
@router.post("/{org_id}/products")
|
||||
async def api_create_payments_product(
|
||||
request: Request,
|
||||
org_id: int,
|
||||
payments_product: PaymentsProductCreate,
|
||||
current_user: PublicUser = Depends(get_current_user),
|
||||
db_session: Session = Depends(get_db_session),
|
||||
) -> PaymentsProductRead:
|
||||
return await create_payments_product(request, org_id, payments_product, current_user, db_session)
|
||||
|
||||
@router.get("/{org_id}/products")
|
||||
async def api_get_payments_products(
|
||||
request: Request,
|
||||
org_id: int,
|
||||
current_user: PublicUser = Depends(get_current_user),
|
||||
db_session: Session = Depends(get_db_session),
|
||||
) -> list[PaymentsProductRead]:
|
||||
return await list_payments_products(request, org_id, current_user, db_session)
|
||||
|
||||
@router.get("/{org_id}/products/{product_id}")
|
||||
async def api_get_payments_product(
|
||||
request: Request,
|
||||
org_id: int,
|
||||
product_id: int,
|
||||
current_user: PublicUser = Depends(get_current_user),
|
||||
db_session: Session = Depends(get_db_session),
|
||||
) -> PaymentsProductRead:
|
||||
return await get_payments_product(request, org_id, product_id, current_user, db_session)
|
||||
|
||||
@router.put("/{org_id}/products/{product_id}")
|
||||
async def api_update_payments_product(
|
||||
request: Request,
|
||||
org_id: int,
|
||||
product_id: int,
|
||||
payments_product: PaymentsProductUpdate,
|
||||
current_user: PublicUser = Depends(get_current_user),
|
||||
db_session: Session = Depends(get_db_session),
|
||||
) -> PaymentsProductRead:
|
||||
return await update_payments_product(request, org_id, product_id, payments_product, current_user, db_session)
|
||||
|
||||
@router.delete("/{org_id}/products/{product_id}")
|
||||
async def api_delete_payments_product(
|
||||
request: Request,
|
||||
org_id: int,
|
||||
product_id: int,
|
||||
current_user: PublicUser = Depends(get_current_user),
|
||||
db_session: Session = Depends(get_db_session),
|
||||
):
|
||||
await delete_payments_product(request, org_id, product_id, current_user, db_session)
|
||||
return {"message": "Payments product deleted successfully"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue