feat: implement advanced reward management and wheel customization

- Add customizable background color
- Add wheel animations and sound effects
- Add reward description field and winner modal
- Change font to Dana
- Add configurable reward probabilities
- Support reward types (Empty, Discount Code, LiveCoin)
- Replace reward title with reward type selector
- Allow wheel page title customization from admin panel
This commit is contained in:
2026-06-10 14:55:07 +03:30
parent b0ff339525
commit ec86cdc528
26 changed files with 1166 additions and 533 deletions

View File

@@ -1,9 +1,5 @@
from fastapi import APIRouter
from fastapi import Depends
from fastapi import HTTPException
from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session
import schemas
from schemas import ItemResponse
from services import crud
@@ -13,7 +9,6 @@ from core.logger import get_logger
router = APIRouter()
logger = get_logger('admin')
def get_db():
db = SessionLocal()
try:
@@ -21,7 +16,6 @@ def get_db():
finally:
db.close()
# GET ALL ITEMS
@router.get("/items", response_model=list[ItemResponse])
def get_items(db: Session = Depends(get_db)):
@@ -33,28 +27,51 @@ def get_items(db: Session = Depends(get_db)):
logger.critical(f"Unexpected error fetching items: {e}")
raise
# CREATE ITEM
@router.post("/items", response_model=ItemResponse)
def create_item(
item: schemas.ItemCreate,
db: Session = Depends(get_db)
):
def create_item(item: schemas.ItemCreate, db: Session = Depends(get_db)):
try:
result = crud.create_item(db, item.title, item.value) # ✅ value اضافه شد
result = crud.create_item(
db,
item.title,
item.prize,
item.description,
item.prize_type,
item.probability
)
logger.info(f"Item created: {item.title}")
return result
except Exception as e:
logger.critical(f"Unexpected error creating item: {e}")
raise
# UPDATE ITEM
@router.put("/items/{item_id}", response_model=ItemResponse)
def update_item(item_id: int, item: schemas.ItemUpdate, db: Session = Depends(get_db)):
try:
updated = crud.update_item(
db,
item_id,
item.title,
item.prize,
item.description,
item.prize_type,
item.probability
)
if not updated:
logger.warning(f"Item not found: {item_id}")
raise HTTPException(status_code=404, detail="Item not found")
logger.info(f"Item updated: {item_id}")
return updated
except HTTPException:
raise
except Exception as e:
logger.critical(f"Unexpected error updating item: {e}")
raise
# DELETE ITEM
@router.delete("/items/{item_id}")
def delete_item(
item_id: int,
db: Session = Depends(get_db)
):
def delete_item(item_id: int, db: Session = Depends(get_db)):
try:
item = crud.delete_item(db, item_id)
if not item:
@@ -66,28 +83,4 @@ def delete_item(
raise
except Exception as e:
logger.critical(f"Unexpected error deleting item: {e}")
raise
@router.put("/items/{item_id}", response_model=ItemResponse)
def update_item(
item_id: int,
item: schemas.ItemCreate,
db: Session = Depends(get_db)
):
try:
updated = crud.update_item(db, item_id, item.title, item.value)
if not updated:
logger.warning(f"Item not found: {item_id}")
raise HTTPException(status_code=404, detail="Item not found")
logger.info(f"Item updated: {item_id}")
return updated
except HTTPException:
raise
except Exception as e:
logger.critical(f"Unexpected error updating item: {e}")
raise
raise