feat: 完善代码,应该可以进行签到了,就差测试了

This commit is contained in:
2025-12-16 22:39:42 +08:00
parent 366ab0b2e8
commit 66199c8130
16 changed files with 353 additions and 90 deletions

View File

@@ -1,5 +1,7 @@
import base64
from typing import List
from uuid import uuid4
from fastapi import UploadFile
import httpx
import config
from services.student_cache import get_student_by_token, save_student
@@ -136,25 +138,35 @@ class XBXS:
pass
return result
async def update_student_know(self, knowingID: str):
files = {
"file0": (
str(uuid4()),
open("./image.jpg", "rb"),
"image/jpeg",
async def update_student_know(
self,
knowingID: str,
remark: str,
address: str,
location: str,
images: List[UploadFile],
):
files = {}
for i, image in enumerate(images):
# 为每个图片生成一个唯一的 UUID 文件名
files[f"file{i}"] = (
str(uuid4()), # 这里使用 UUID 作为文件名
await image.read(),
"image/jpeg", # 假设是 jpeg 格式,按需修改
)
}
resp = await self.client.post(
"/xiaobei-api/student/know/updateStudentKnow",
data={
"address": "1388号",
"remark": "",
"knowingId": knowingID,
"location": "106.5346788194445:29.343291015625",
"size": "1",
},
)
resp.raise_for_status()
# resp = await self.client.post(
# "/xiaobei-api/student/know/updateStudentKnow",
# data={
# "address": address,
# "remark": remark,
# "knowingId": knowingID,
# "location": location,
# # "location": "106.5346788194445:29.343291015625",
# "size": len(images),
# },
# files=files,
# )
# resp.raise_for_status()
async def get_student_info_cached(self):
cached = get_student_by_token(str(self.token))