Skip to content

Commit d593afe

Browse files
committed
style: 字典管理器新增注释
1 parent 5b13840 commit d593afe

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

dash-fastapi-frontend/utils/dict_util.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@
44

55

66
class DictManager:
7+
"""
8+
字典管理器
9+
"""
10+
711
@classmethod
812
def get_dict_options(cls, dict_type: str):
13+
"""
14+
获取字典数据
15+
16+
:param dict_type: 字典类型
17+
:return: 字典数据
18+
"""
919
cache_dict_value = TTLCacheManager.get(target_key=dict_type)
1020
if cache_dict_value:
1121
select_options, dict_options = cache_dict_value
@@ -36,6 +46,13 @@ def get_dict_options(cls, dict_type: str):
3646

3747
@classmethod
3848
def get_dict_label(cls, dict_type: str, dict_value: Any):
49+
"""
50+
根据字典类型和字典值获取字典标签
51+
52+
:param dict_type: 字典类型
53+
:param dict_value: 字典值
54+
:return: 字典标签
55+
"""
3956
options = cls.get_dict_options(dict_type=dict_type)[1]
4057
if dict_value is None:
4158
return ''
@@ -52,6 +69,12 @@ def get_tag_color(
5269
'default', 'primary', 'success', 'info', 'warning', 'danger'
5370
] = 'default',
5471
):
72+
"""
73+
根据标签类型获取标签颜色
74+
75+
:param tag_type: 标签类型
76+
:return: 标签颜色
77+
"""
5578
if tag_type == 'primary':
5679
return 'blue'
5780
elif tag_type == 'success':
@@ -66,6 +89,13 @@ def get_tag_color(
6689

6790
@classmethod
6891
def get_dict_tag(cls, dict_type: dict, dict_value: Any):
92+
"""
93+
根据字典类型和字典值获取字典标签tag
94+
95+
:param dict_type: 字典类型
96+
:param dict_value: 字典值
97+
:return: 字典标签tag
98+
"""
6999
options = cls.get_dict_options(dict_type=dict_type)[1]
70100
for option in options:
71101
if option.get('value') == str(dict_value):

0 commit comments

Comments
 (0)