feat: base get_sysconfig支持传入具体key值
This commit is contained in:
parent
00e3129751
commit
2319ecde61
|
@ -339,7 +339,9 @@ LOGGING = {
|
||||||
##### 加载客户可自定义配置并提供操作方法 #####
|
##### 加载客户可自定义配置并提供操作方法 #####
|
||||||
SYS_JSON_PATH = os.path.join(BASE_DIR, 'server/conf.json')
|
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)
|
config = cache.get('system_config', None)
|
||||||
if config is None or reload:
|
if config is None or reload:
|
||||||
# 读取配置文件
|
# 读取配置文件
|
||||||
|
@ -349,6 +351,10 @@ def get_sysconfig(reload=False):
|
||||||
config = json.loads(f.read())
|
config = json.loads(f.read())
|
||||||
cache.set('system_config', config)
|
cache.set('system_config', config)
|
||||||
return config
|
return config
|
||||||
|
if key:
|
||||||
|
k_l = key.split('.')
|
||||||
|
for k in k_l:
|
||||||
|
config = config[k]
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue