diff --git a/libs/sync_user_verift_v4.py b/libs/sync_user_verift_v4.py index 00e796d..67361ac 100644 --- a/libs/sync_user_verift_v4.py +++ b/libs/sync_user_verift_v4.py @@ -273,12 +273,12 @@ def sync_biz_to_gw(self): with DBContext('r') as session: business_info = session.query(BizModel).all() - business_dict = { - info.biz_id: {user: "y" for user in info.users_info} - for info in business_info - } - self.etcd_client.ttl(ttl_id=ttl_id, ttl=720000) # TTL set to 200 hours - self.etcd_client.put(self.biz_acl_prefix, json.dumps(business_dict), lease=ttl_id) + for info in business_info: + acl_prefix = f"{self.biz_acl_prefix}{info.biz_id}" + users_info = {user: "y" for user in info.users_info} if isinstance(info.users_info, + (list, dict)) else {} + self.etcd_client.ttl(ttl_id=ttl_id, ttl=720000) # TTL set to 200 hours + self.etcd_client.put(acl_prefix, json.dumps(users_info), lease=ttl_id) except Exception as err: logging.error(f"推送业务信息出错 {err}") diff --git a/services/biz_service.py b/services/biz_service.py index cd64178..17804e7 100644 --- a/services/biz_service.py +++ b/services/biz_service.py @@ -9,13 +9,15 @@ """ import json + from sqlalchemy import or_ +from websdk2.cache_context import cache_conn from websdk2.db_context import DBContextV2 as DBContext from websdk2.sqlalchemy_pagination import paginate from websdk2.tools import convert -from websdk2.cache_context import cache_conn -from models.paas_model import BizModel + from libs.feature_model_utils import CommonOptView +from models.paas_model import BizModel ROLE_USER_INFO_STR = "ROLE_USER_INFO_STR" opt_obj = CommonOptView(BizModel) @@ -73,6 +75,8 @@ def add_init_default(): BizModel(**dict(biz_cn_name='公共项目', biz_en_name='public', biz_id=str(501), life_cycle='已上线'))) session.add( BizModel(**dict(biz_cn_name='默认项目', biz_en_name='default', biz_id=str(502), life_cycle='已上线'))) + session.add( + BizModel(**dict(biz_cn_name='运维项目', biz_en_name='ops', biz_id=str(504), life_cycle='已上线'))) return