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
+2
View File
@@ -102,6 +102,7 @@ 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
if file_code.expired_count > 0:
file_code.expired_count -= 1
# 保存文件
await file_code.save()
@@ -122,6 +123,7 @@ async def select_file(data: SelectFileModel, ip: str = Depends(error_ip_limit)):
return APIResponse(code=404, detail=file_code)
# 更新文件的使用次数和过期次数
file_code.used_count += 1
if file_code.expired_count > 0:
file_code.expired_count -= 1
# 保存文件
await file_code.save()
+5 -1
View File
@@ -10,7 +10,11 @@
</template>
</el-table-column>
<el-table-column prop="used_count" :label="t('admin.fileView.used_count')" />
<el-table-column prop="expired_count" :label="t('admin.fileView.expired_count')" />
<el-table-column prop="expired_count" :label="t('admin.fileView.expired_count')">
<template #default="scope">
<span>{{ scope.row.expired_count > -1 ? scope.row.expired_count : '不限次数' }}</span>
</template>
</el-table-column>
<el-table-column prop="size" :label="t('admin.fileView.size')">
<template #default="scope">
<span>{{ Math.round(scope.row.size/1024/1024*100)/100 }}MB</span>