|
|
@@ -29,6 +29,9 @@ class GetWxQRCodeRequest(BaseModel): |
|
|
|
class LogincCaptchCode(BaseModel): |
|
|
|
tel: str |
|
|
|
captchCode:str |
|
|
|
|
|
|
|
class DeleteAgentRequest(BaseModel): |
|
|
|
tel: str |
|
|
|
|
|
|
|
@agent_router.post("/getlogin", response_model=None) |
|
|
|
async def get_login(request: Request, body: GetAgentLoginRequest, ): |
|
|
@@ -210,4 +213,27 @@ async def login_captch_code(request: Request, body: LogincCaptchCode, ): |
|
|
|
tel = body.tel |
|
|
|
captch_code=body.captchCode |
|
|
|
res=await request.app.state.gewe_service.save_login_wx_captch_code_to_cache_async(tel,captch_code) |
|
|
|
return {'message': '操作成功'} |
|
|
|
|
|
|
|
@agent_router.post("/delete", response_model=None) |
|
|
|
async def delete_agent(request: Request, body: DeleteAgentRequest): |
|
|
|
tel = body.tel |
|
|
|
loginfo = await request.app.state.gewe_service.get_login_info_from_cache_async(tel) |
|
|
|
wxid = loginfo.get('wxid', '') |
|
|
|
|
|
|
|
# 获取所有匹配的 Redis 键 |
|
|
|
ai_ops_wx_keys = [key async for key in await request.app.state.redis_service.client.scan_iter(match='__AI_OPS_WX__:*')] |
|
|
|
|
|
|
|
# 定义正则表达式模式 |
|
|
|
pattern = re.compile(rf'^__AI_OPS_WX__.*{wxid}.*') |
|
|
|
|
|
|
|
# 过滤掉符合模式的键 |
|
|
|
filtered_keys = [key for key in ai_ops_wx_keys if not pattern.match(key)] |
|
|
|
|
|
|
|
# 并发删除过滤后的键 |
|
|
|
await asyncio.gather(*[request.app.state.redis_service.delete_hash(key) for key in filtered_keys]) |
|
|
|
|
|
|
|
# 删除登录信息 |
|
|
|
await request.app.state.gewe_service.delete_hash(f'__AI_OPS_WX__:LOGININFO:{tel}') |
|
|
|
|
|
|
|
return {'message': '操作成功'} |