1
This commit is contained in:
parent
03afe47ca2
commit
dacc437f48
16
main.py
16
main.py
@ -152,9 +152,21 @@ async def getgameinfo(request: Request, oldGameId: int = 0, name: str = ""):
|
||||
|
||||
|
||||
@app.get("/getgameprice")
|
||||
async def getgameprice(request: Request, oldGameId: int):
|
||||
async def getgameprice(request: Request, oldGameId: int, nums: int = 0):
|
||||
db = request.app.state.mongo
|
||||
gameprice = db["gameprice"].find_one({"oldGameId": oldGameId}, {"_id": 0})
|
||||
if nums == 0:
|
||||
gameprice = db["gameprice"].find_one({"oldGameId": oldGameId},
|
||||
{"_id": 0})
|
||||
else:
|
||||
gameprice = db["gameprice"].find_one({"oldGameId": oldGameId},
|
||||
{"_id": 0})
|
||||
price = gameprice.get('prices', [])
|
||||
if price:
|
||||
gameprice['prices'] = price[:nums]
|
||||
else:
|
||||
logger.error(f"get price with {oldGameId} failed\n {gameprice}")
|
||||
gameprice['prices'] = []
|
||||
|
||||
logger.info(f"get gameprice with {oldGameId} !")
|
||||
return JSONResponse(
|
||||
status_code=starlette.status.HTTP_200_OK,
|
||||
|
Loading…
x
Reference in New Issue
Block a user