Skip to content

Commit

Permalink
2024年8月16日 优化业务权限推送格式
Browse files Browse the repository at this point in the history
  • Loading branch information
ss1917 committed Aug 16, 2024
1 parent 7300096 commit d58e7a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 6 additions & 6 deletions libs/sync_user_verift_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
8 changes: 6 additions & 2 deletions services/biz_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit d58e7a9

Please sign in to comment.