C7/C8: employees.last_login_ip 列补全(ALTER TABLE 迁移)+ redis decode 兼容修复 7 处(wecom_service×2/employee_directory×3/auth_wecom_sso×2,统一 isinstance 保护模式)
This commit is contained in:
@@ -62,7 +62,9 @@ async def get_org_directory(
|
||||
raw = await redis.get(ORG_DIRECTORY_CACHE_KEY)
|
||||
if raw:
|
||||
logger.debug("命中组织目录缓存")
|
||||
return json.loads(raw.decode("utf-8")), True
|
||||
# v4.0 C8 修复:兼容 str/bytes
|
||||
raw = raw if isinstance(raw, str) else raw.decode("utf-8")
|
||||
return json.loads(raw), True
|
||||
except Exception as e:
|
||||
logger.warning(f"读取组织目录缓存失败(降级): {e}")
|
||||
|
||||
@@ -306,7 +308,9 @@ async def get_cached_dept_list(
|
||||
try:
|
||||
raw = await redis.get(DEPT_LIST_CACHE_KEY)
|
||||
if raw:
|
||||
return json.loads(raw.decode("utf-8"))
|
||||
# v4.0 C8 修复:兼容 str/bytes
|
||||
raw = raw if isinstance(raw, str) else raw.decode("utf-8")
|
||||
return json.loads(raw)
|
||||
except Exception as e:
|
||||
logger.warning(f"读取部门列表缓存失败: {e}")
|
||||
|
||||
@@ -607,7 +611,9 @@ async def get_org_tree_cached(
|
||||
try:
|
||||
raw = await redis.get(cache_key)
|
||||
if raw:
|
||||
tree = json.loads(raw.decode("utf-8"))
|
||||
# v4.0 C8 修复:兼容 str/bytes
|
||||
raw = raw if isinstance(raw, str) else raw.decode("utf-8")
|
||||
tree = json.loads(raw)
|
||||
logger.debug(f"命中组织架构树缓存: {endpoint}")
|
||||
except Exception as e:
|
||||
logger.warning(f"读取组织架构树缓存失败: {e}")
|
||||
|
||||
@@ -78,7 +78,8 @@ class WecomService:
|
||||
cached_token = await self.redis.get(cache_key)
|
||||
if cached_token:
|
||||
logger.debug("从缓存获取 access_token")
|
||||
return cached_token.decode("utf-8")
|
||||
# v4.0 C8 修复:decode_responses=True 时返回 str,兼容 bytes
|
||||
return cached_token if isinstance(cached_token, str) else cached_token.decode("utf-8")
|
||||
except Exception as e:
|
||||
logger.warning(f"Redis 读取失败(降级): {e}")
|
||||
|
||||
@@ -1134,7 +1135,8 @@ class WecomService:
|
||||
cached = await self.redis.get(cache_key)
|
||||
if cached:
|
||||
logger.debug("从缓存获取 jsapi_ticket")
|
||||
return cached.decode("utf-8")
|
||||
# v4.0 C8 修复:兼容 str/bytes
|
||||
return cached if isinstance(cached, str) else cached.decode("utf-8")
|
||||
except Exception as e:
|
||||
logger.warning(f"Redis 读取 jsapi_ticket 失败(降级): {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user