fix: 阻止按日期授权时剩余次数无限减少

This commit is contained in:
Yanlongli
2024-03-29 14:23:12 +08:00
parent d661d53466
commit 3c476835c9
2 changed files with 9 additions and 3 deletions
+4 -2
View File
@@ -102,7 +102,8 @@ async def get_code_file(code: str, ip: str = Depends(error_ip_limit)):
return APIResponse(code=404, detail=file_code)
# 更新文件的使用次数和过期次数
file_code.used_count += 1
file_code.expired_count -= 1
if file_code.expired_count > 0:
file_code.expired_count -= 1
# 保存文件
await file_code.save()
# 返回文件响应
@@ -122,7 +123,8 @@ async def select_file(data: SelectFileModel, ip: str = Depends(error_ip_limit)):
return APIResponse(code=404, detail=file_code)
# 更新文件的使用次数和过期次数
file_code.used_count += 1
file_code.expired_count -= 1
if file_code.expired_count > 0:
file_code.expired_count -= 1
# 保存文件
await file_code.save()
# 返回API响应