@@ -76,7 +76,7 @@ async def admin():
7676async def admin_post (s : AsyncSession = Depends (get_session )):
7777 query = select (Codes )
7878 codes = (await s .execute (query )).scalars ().all ()
79- return {'msg ' : '查询成功' , 'data' : codes }
79+ return {'detail ' : '查询成功' , 'data' : codes }
8080
8181
8282@app .delete (f'/{ settings .ADMIN_ADDRESS } ' , dependencies = [Depends (admin_required )])
@@ -86,7 +86,7 @@ async def admin_delete(code: str, s: AsyncSession = Depends(get_session)):
8686 await storage .delete_file ({'type' : file .type , 'text' : file .text })
8787 await s .delete (file )
8888 await s .commit ()
89- return {'msg ' : '删除成功' }
89+ return {'detail ' : '删除成功' }
9090
9191
9292@app .get ('/' )
@@ -101,7 +101,7 @@ async def get_file(code: str, s: AsyncSession = Depends(get_session)):
101101 if not info :
102102 raise HTTPException (status_code = 404 , detail = "口令不存在" )
103103 if info .type == 'text' :
104- return {'msg ' : '查询成功' , 'data' : info .text }
104+ return {'detail ' : '查询成功' , 'data' : info .text }
105105 else :
106106 filepath = await storage .get_filepath (info .text )
107107 return FileResponse (filepath , filename = info .name )
@@ -112,21 +112,19 @@ async def index(code: str, ip: str = Depends(ip_limit), s: AsyncSession = Depend
112112 query = select (Codes ).where (Codes .code == code )
113113 info = (await s .execute (query )).scalars ().first ()
114114 if not info :
115- error_count = ip_limit .add_ip (ip )
116- raise HTTPException (status_code = 404 , detail = f"取件码错误,错误{ settings . ERROR_COUNT - error_count } 次将被禁止10分钟" )
115+ error_count = settings . ERROR_COUNT - ip_limit .add_ip (ip )
116+ raise HTTPException (status_code = 404 , detail = f"取件码错误,错误{ error_count } 次将被禁止10分钟" )
117117 if info .exp_time < datetime .datetime .now () or info .count == 0 :
118118 await storage .delete_file ({'type' : info .type , 'text' : info .text })
119119 await s .delete (info )
120120 await s .commit ()
121121 raise HTTPException (status_code = 404 , detail = "取件码已过期,请联系寄件人" )
122- count = info .count - 1
123- query = update (Codes ).where (Codes .id == info .id ).values (count = count )
124- await s .execute (query )
122+ await s .execute (update (Codes ).where (Codes .id == info .id ).values (count = info .count - 1 ))
125123 await s .commit ()
126124 if info .type != 'text' :
127125 info .text = f'/select?code={ code } '
128126 return {
129- 'msg ' : '取件成功,请点击"取"查看' ,
127+ 'detail ' : '取件成功,请点击"取"查看' ,
130128 'data' : {'type' : info .type , 'text' : info .text , 'name' : info .name , 'code' : info .code }
131129 }
132130
@@ -170,7 +168,7 @@ async def share(text: str = Form(default=None), style: str = Form(default='2'),
170168 s .add (info )
171169 await s .commit ()
172170 return {
173- 'msg ' : '分享成功,请点击文件箱查看取件码' ,
171+ 'detail ' : '分享成功,请点击文件箱查看取件码' ,
174172 'data' : {'code' : code , 'key' : key , 'name' : name , 'text' : _text }
175173 }
176174
0 commit comments