feat: base get_sysconfig支持传入具体key值

This commit is contained in:
caoqianming 2024-04-25 16:57:00 +08:00
parent 00e3129751
commit 2319ecde61
1 changed files with 7 additions and 1 deletions

View File

@ -339,7 +339,9 @@ LOGGING = {
##### 加载客户可自定义配置并提供操作方法 #####
SYS_JSON_PATH = os.path.join(BASE_DIR, 'server/conf.json')
def get_sysconfig(reload=False):
def get_sysconfig(key='', reload=False):
"""获取系统配置可指定key字符串
"""
config = cache.get('system_config', None)
if config is None or reload:
# 读取配置文件
@ -349,6 +351,10 @@ def get_sysconfig(reload=False):
config = json.loads(f.read())
cache.set('system_config', config)
return config
if key:
k_l = key.split('.')
for k in k_l:
config = config[k]
return config