first commit

This commit is contained in:
2025-07-24 20:13:47 +03:00
commit 94b7585f8b
175 changed files with 85264 additions and 0 deletions

View File

@ -0,0 +1,57 @@
from time import time
from fastapi import APIRouter
from app import mongo
from app.utils.response_util import response
router = APIRouter()
@router.get("/get-all", tags=[""])
async def get_all_pay_rates():
start_time = time()
pay_rates = await mongo.pay_rates_collection.find(
{}, {"_id": False}
).sort("id", mongo.asc).to_list()
return response({
"payRates": pay_rates
}, start_time=start_time)
@router.post("/create", tags=[""])
async def create_pay_rate(params: dict):
start_time = time()
data = params["data"]
data["id"] = await mongo.get_next_id(mongo.pay_rates_collection)
await mongo.pay_rates_collection.insert_one(data)
return response({
"message": "Тариф успешно создан",
"ok": True
}, start_time=start_time)
@router.post("/update", tags=[""])
async def update_pay_rate(params: dict):
start_time = time()
data = params["data"]
await mongo.pay_rates_collection.update_one({"id": data["id"]}, {"$set": data})
return response({
"message": "Тариф успешно обновлен",
"ok": True
}, start_time=start_time)
@router.post("/delete", tags=[""])
async def delete_pay_rate(params: dict):
start_time = time()
await mongo.pay_rates_collection.delete_one({"id": params["payRateId"]})
return response({
"message": "Тариф успешно удален",
"ok": True
}, start_time=start_time)