From d58e7a985e8655d823fef5f61d4b5a56e54c37b1 Mon Sep 17 00:00:00 2001 From: shenshuo <191715030@qq.com> Date: Fri, 16 Aug 2024 11:54:43 +0800 Subject: [PATCH] =?UTF-8?q?2024=E5=B9=B48=E6=9C=8816=E6=97=A5=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=B8=9A=E5=8A=A1=E6=9D=83=E9=99=90=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/sync_user_verift_v4.py | 12 ++++++------ services/biz_service.py | 8 ++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) 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