feat: base get_sysconfig可返回默认参数

This commit is contained in:
caoqianming 2024-09-03 09:50:43 +08:00
parent 89af31a383
commit 3c99770477
1 changed files with 8 additions and 2 deletions

View File

@ -341,7 +341,7 @@ LOGGING = {
##### 加载客户可自定义配置并提供操作方法 #####
SYS_JSON_PATH = os.path.join(BASE_DIR, 'server/conf.json')
def get_sysconfig(key='', reload=False):
def get_sysconfig(key='', default='raise_error', reload=False):
"""获取系统配置可指定key字符串
"""
config = cache.get('system_config', None)
@ -355,7 +355,13 @@ def get_sysconfig(key='', reload=False):
if key:
k_l = key.split('.')
for k in k_l:
try:
config = config[k]
except KeyError:
if default == 'raise_error':
raise
else:
return default
return config