瀏覽代碼

调整

d1
H Vs 3 週之前
父節點
當前提交
9a95d3884f
共有 1 個文件被更改,包括 28 次插入5 次删除
  1. +28
    -5
      app/endpoints/config_endpoint.py

+ 28
- 5
app/endpoints/config_endpoint.py 查看文件

@@ -22,13 +22,22 @@ class SaveConfigRequest(BaseModel):


@config_router.post("/getconfig",response_model=None)
@validate_wxid
#@validate_wxid
async def get_config(request: Request, body: GetConfigRequest):
wxid = body.wxid
if not wxid:
return {"code": 400, "message": "wxid 不能为空"}
k,loginfo=await request.app.state.gewe_service.get_login_info_by_wxid_async(wxid)

if not k:
return {"code":404,"message":f"{wxid} 没有对应的登录信息"}
login_status=loginfo.get('status','0')
# k,loginfo=await request.app.state.gewe_service.get_login_info_by_wxid_async(wxid)
# if not k:
# return {"code":404,"message":f"{wxid} 没有对应的登录信息"}
if login_status != '1':
return {"code": 401, "message": f"{wxid} 已经离线"}
config=await request.app.state.gewe_service.get_wxchat_config_from_cache_async(wxid)

return config
@@ -36,13 +45,27 @@ async def get_config(request: Request, body: GetConfigRequest):


@config_router.post("/saveconfig",response_model=None)
@validate_wxid
#@validate_wxid
async def save_config(request: Request, body: SaveConfigRequest):
wxid = body.wxid
data = body.data
# k,loginfo=await request.app.state.gewe_service.get_login_info_by_wxid_async(wxid)
# if not k:
# return {"code":404,"message":f"{wxid} 没有对应的登录信息"}

if not wxid:
return {"code": 400, "message": "wxid 不能为空"}
k,loginfo=await request.app.state.gewe_service.get_login_info_by_wxid_async(wxid)

if not k:
return {"code":404,"message":f"{wxid} 没有对应的登录信息"}
login_status=loginfo.get('status','0')
if login_status != '1':
return {"code": 401, "message": f"{wxid} 已经离线"}
try:
# 使用 Pydantic 严格校验数据类型和结构
validated_config = AgentConfig.model_validate(data)


Loading…
取消
儲存