|
@@ -22,13 +22,22 @@ class SaveConfigRequest(BaseModel): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@config_router.post("/getconfig",response_model=None) |
|
|
@config_router.post("/getconfig",response_model=None) |
|
|
@validate_wxid |
|
|
|
|
|
|
|
|
#@validate_wxid |
|
|
async def get_config(request: Request, body: GetConfigRequest): |
|
|
async def get_config(request: Request, body: GetConfigRequest): |
|
|
wxid = body.wxid |
|
|
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) |
|
|
config=await request.app.state.gewe_service.get_wxchat_config_from_cache_async(wxid) |
|
|
|
|
|
|
|
|
return config |
|
|
return config |
|
@@ -36,13 +45,27 @@ async def get_config(request: Request, body: GetConfigRequest): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@config_router.post("/saveconfig",response_model=None) |
|
|
@config_router.post("/saveconfig",response_model=None) |
|
|
@validate_wxid |
|
|
|
|
|
|
|
|
#@validate_wxid |
|
|
async def save_config(request: Request, body: SaveConfigRequest): |
|
|
async def save_config(request: Request, body: SaveConfigRequest): |
|
|
wxid = body.wxid |
|
|
wxid = body.wxid |
|
|
data = body.data |
|
|
data = body.data |
|
|
# k,loginfo=await request.app.state.gewe_service.get_login_info_by_wxid_async(wxid) |
|
|
# k,loginfo=await request.app.state.gewe_service.get_login_info_by_wxid_async(wxid) |
|
|
# if not k: |
|
|
# if not k: |
|
|
# return {"code":404,"message":f"{wxid} 没有对应的登录信息"} |
|
|
# 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: |
|
|
try: |
|
|
# 使用 Pydantic 严格校验数据类型和结构 |
|
|
# 使用 Pydantic 严格校验数据类型和结构 |
|
|
validated_config = AgentConfig.model_validate(data) |
|
|
validated_config = AgentConfig.model_validate(data) |
|
|