Skip to content

Commit f902bca

Browse files
committed
Update the dict pagination query parameters
1 parent 93f4f28 commit f902bca

File tree

9 files changed

+131
-116
lines changed

9 files changed

+131
-116
lines changed

backend/plugin/dict/api/v1/sys/dict_data.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ async def get_dict_data(
4545
)
4646
async def get_dict_datas_paged(
4747
db: CurrentSession,
48+
type_code: Annotated[str | None, Query(description='字典类型编码')] = None,
4849
label: Annotated[str | None, Query(description='字典数据标签')] = None,
4950
value: Annotated[str | None, Query(description='字典数据键值')] = None,
5051
status: Annotated[int | None, Query(description='状态')] = None,
5152
type_id: Annotated[int | None, Query(description='字典类型 ID')] = None,
5253
) -> ResponseSchemaModel[PageData[GetDictDataDetail]]:
53-
dict_data_select = await dict_data_service.get_select(label=label, value=value, status=status, type_id=type_id)
54+
dict_data_select = await dict_data_service.get_select(
55+
type_code=type_code, label=label, value=value, status=status, type_id=type_id
56+
)
5457
page_data = await paging_data(db, dict_data_select)
5558
return response_base.success(data=page_data)
5659

backend/plugin/dict/crud/crud_dict_data.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ async def get_all(self, db: AsyncSession) -> Sequence[DictData]:
3232
"""
3333
return await self.select_models(db, load_strategies={'type': 'noload'})
3434

35-
async def get_list(self, label: str | None, value: str | None, status: int | None, type_id: int | None) -> Select:
35+
async def get_list(
36+
self, type_code: str | None, label: str | None, value: str | None, status: int | None, type_id: int | None
37+
) -> Select:
3638
"""
3739
获取字典数据列表
3840
41+
:param type_code: 字典类型编码
3942
:param label: 字典数据标签
4043
:param value: 字典数据键值
4144
:param status: 字典状态
@@ -44,6 +47,8 @@ async def get_list(self, label: str | None, value: str | None, status: int | Non
4447
"""
4548
filters = {}
4649

50+
if type_code is not None:
51+
filters['type_code'] = type_code
4752
if label is not None:
4853
filters['label__like'] = f'%{label}%'
4954
if value is not None:

backend/plugin/dict/model/dict_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class DictData(Base):
2121
__tablename__ = 'sys_dict_data'
2222

2323
id: Mapped[id_key] = mapped_column(init=False)
24+
type_code: Mapped[str] = mapped_column(String(32), comment='对应的字典类型编码')
2425
label: Mapped[str] = mapped_column(String(32), comment='字典标签')
2526
value: Mapped[str] = mapped_column(String(32), comment='字典值')
2627
sort: Mapped[int] = mapped_column(default=0, comment='排序')

backend/plugin/dict/schema/dict_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class DictDataSchemaBase(SchemaBase):
1212
"""字典数据基础模型"""
1313

1414
type_id: int = Field(description='字典类型 ID')
15+
type_code: str = Field(description='字典类型编码')
1516
label: str = Field(description='字典标签')
1617
value: str = Field(description='字典值')
1718
sort: int = Field(description='排序')

backend/plugin/dict/service/dict_data_service.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,22 @@ async def get_all() -> Sequence[DictData]:
3636
return dict_datas
3737

3838
@staticmethod
39-
async def get_select(*, label: str | None, value: str | None, status: int | None, type_id: int | None) -> Select:
39+
async def get_select(
40+
*, type_code: str | None, label: str | None, value: str | None, status: int | None, type_id: int | None
41+
) -> Select:
4042
"""
4143
获取字典数据列表查询条件
4244
45+
:param type_code: 字典类型编码
4346
:param label: 字典数据标签
4447
:param value: 字典数据键值
4548
:param status: 状态
4649
:param type_id: 字典类型 ID
4750
:return:
4851
"""
49-
return await dict_data_dao.get_list(label=label, value=value, status=status, type_id=type_id)
52+
return await dict_data_dao.get_list(
53+
type_code=type_code, label=label, value=value, status=status, type_id=type_id
54+
)
5055

5156
@staticmethod
5257
async def create(*, obj: CreateDictDataParam) -> None:

backend/plugin/dict/sql/mysql/init_snowflake_test_data.sql

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@ values
1010
(2048602512755392512, '菜单显示', 'sys_menu_display', 1, '菜单是否显示', now(), null),
1111
(2048602512818307072, '菜单缓存', 'sys_menu_cache', 1, '菜单是否缓存', now(), null);
1212

13-
insert into sys_dict_data (id, label, value, sort, status, remark, type_id, created_time, updated_time)
13+
insert into sys_dict_data (id, type_code, label, value, sort, status, remark, type_id, created_time, updated_time)
1414
values
15-
(2048602512881221632, '停用', 0, 1, 1, '系统停用状态', 2048602512340156416, now(), null),
16-
(2048602512948330496, '正常', 1, 2, 1, '系统正常状态', 2048602512340156416, now(), null),
17-
(2048602513015439360, '目录', 0, 1, 1, '菜单目录类型', 2048602512369516544, now(), null),
18-
(2048602513078353920, '菜单', 1, 2, 1, '普通菜单类型', 2048602512369516544, now(), null),
19-
(2048602513128685568, '按钮', 2, 3, 1, '按钮权限类型', 2048602512369516544, now(), null),
20-
(2048602513174822912, '内嵌', 3, 4, 1, '内嵌页面类型', 2048602512369516544, now(), null),
21-
(2048602513241931776, '外链', 4, 5, 1, '外部链接类型', 2048602512369516544, now(), null),
22-
(2048602513292263424, '失败', 0, 1, 1, '登录失败状态', 2048602512432431104, now(), null),
23-
(2048602513359372288, '成功', 1, 2, 1, '登录成功状态', 2048602512432431104, now(), null),
24-
(2048602513422286848, 'AND', 0, 1, 1, '逻辑与运算符', 2048602512495345664, now(), null),
25-
(2048602513476812800, 'OR', 1, 2, 1, '逻辑或运算符', 2048602512495345664, now(), null),
26-
(2048602513543921664, '等于(==)', 0, 1, 1, '等于比较表达式', 2048602512549871616, now(), null),
27-
(2048602513590059008, '不等于(!=)', 1, 2, 1, '不等于比较表达式', 2048602512549871616, now(), null),
28-
(2048602513657167872, '大于(>)', 2, 3, 1, '大于比较表达式', 2048602512549871616, now(), null),
29-
(2048602513720082432, '大于等于(>=)', 3, 4, 1, '大于等于比较表达式', 2048602512549871616, now(), null),
30-
(2048602513782996992, '小于(<)', 4, 5, 1, '小于比较表达式', 2048602512549871616, now(), null),
31-
(2048602513850105856, '小于等于(<=)', 5, 6, 1, '小于等于比较表达式', 2048602512549871616, now(), null),
32-
(2048602513917214720, '包含(in)', 6, 7, 1, '包含表达式', 2048602512549871616, now(), null),
33-
(2048602513984323584, '不包含(not in)', 7, 8, 1, '不包含表达式', 2048602512549871616, now(), null),
34-
(2048602514051432448, '', 0, 1, 1, '不是前端参数配置', 2048602512616980480, now(), null),
35-
(2048602514118541312, '', 1, 2, 1, '是前端参数配置', 2048602512616980480, now(), null),
36-
(2048602514168872960, '', 0, 1, 1, '不进行数据权限过滤', 2048602512692477952, now(), null),
37-
(2048602514231787520, '', 1, 2, 1, '进行数据权限过滤', 2048602512692477952, now(), null),
38-
(2048602514303090688, '隐藏', 0, 1, 1, '菜单隐藏', 2048602512755392512, now(), null),
39-
(2048602514366005248, '显示', 1, 2, 1, '菜单显示', 2048602512755392512, now(), null),
40-
(2048602514433114112, '不缓存', 0, 1, 1, '菜单不缓存', 2048602512818307072, now(), null),
41-
(2048602514500222976, '缓存', 1, 2, 1, '菜单缓存', 2048602512818307072, now(), null);
15+
(2048602512881221632, 'sys_status', '停用', '0', 1, 1, '系统停用状态', 2048602512340156416, now(), null),
16+
(2048602512948330496, 'sys_status', '正常', '1', 2, 1, '系统正常状态', 2048602512340156416, now(), null),
17+
(2048602513015439360, 'sys_menu_type', '目录', '0', 1, 1, '菜单目录类型', 2048602512369516544, now(), null),
18+
(2048602513078353920, 'sys_menu_type', '菜单', '1', 2, 1, '普通菜单类型', 2048602512369516544, now(), null),
19+
(2048602513128685568, 'sys_menu_type', '按钮', '2', 3, 1, '按钮权限类型', 2048602512369516544, now(), null),
20+
(2048602513174822912, 'sys_menu_type', '内嵌', '3', 4, 1, '内嵌页面类型', 2048602512369516544, now(), null),
21+
(2048602513241931776, 'sys_menu_type', '外链', '4', 5, 1, '外部链接类型', 2048602512369516544, now(), null),
22+
(2048602513292263424, 'sys_login_status', '失败', '0', 1, 1, '登录失败状态', 2048602512432431104, now(), null),
23+
(2048602513359372288, 'sys_login_status', '成功', '1', 2, 1, '登录成功状态', 2048602512432431104, now(), null),
24+
(2048602513422286848, 'sys_data_rule_operator', 'AND', '0', 1, 1, '逻辑与运算符', 2048602512495345664, now(), null),
25+
(2048602513476812800, 'sys_data_rule_operator', 'OR', '1', 2, 1, '逻辑或运算符', 2048602512495345664, now(), null),
26+
(2048602513543921664, 'sys_data_rule_expression', '等于(==)', '0', 1, 1, '等于比较表达式', 2048602512549871616, now(), null),
27+
(2048602513590059008, 'sys_data_rule_expression', '不等于(!=)', '1', 2, 1, '不等于比较表达式', 2048602512549871616, now(), null),
28+
(2048602513657167872, 'sys_data_rule_expression', '大于(>)', '2', 3, 1, '大于比较表达式', 2048602512549871616, now(), null),
29+
(2048602513720082432, 'sys_data_rule_expression', '大于等于(>=)', '3', 4, 1, '大于等于比较表达式', 2048602512549871616, now(), null),
30+
(2048602513782996992, 'sys_data_rule_expression', '小于(<)', '4', 5, 1, '小于比较表达式', 2048602512549871616, now(), null),
31+
(2048602513850105856, 'sys_data_rule_expression', '小于等于(<=)', '5', 6, 1, '小于等于比较表达式', 2048602512549871616, now(), null),
32+
(2048602513917214720, 'sys_data_rule_expression', '包含(in)', '6', 7, 1, '包含表达式', 2048602512549871616, now(), null),
33+
(2048602513984323584, 'sys_data_rule_expression', '不包含(not in)', '7', 8, 1, '不包含表达式', 2048602512549871616, now(), null),
34+
(2048602514051432448, 'sys_frontend_config', '', '0', 1, 1, '不是前端参数配置', 2048602512616980480, now(), null),
35+
(2048602514118541312, 'sys_frontend_config', '', '1', 2, 1, '是前端参数配置', 2048602512616980480, now(), null),
36+
(2048602514168872960, 'sys_data_permission', '', '0', 1, 1, '不进行数据权限过滤', 2048602512692477952, now(), null),
37+
(2048602514231787520, 'sys_data_permission', '', '1', 2, 1, '进行数据权限过滤', 2048602512692477952, now(), null),
38+
(2048602514303090688, 'sys_menu_display', '隐藏', '0', 1, 1, '菜单隐藏', 2048602512755392512, now(), null),
39+
(2048602514366005248, 'sys_menu_display', '显示', '1', 2, 1, '菜单显示', 2048602512755392512, now(), null),
40+
(2048602514433114112, 'sys_menu_cache', '不缓存', '0', 1, 1, '菜单不缓存', 2048602512818307072, now(), null),
41+
(2048602514500222976, 'sys_menu_cache', '缓存', '1', 2, 1, '菜单缓存', 2048602512818307072, now(), null);

backend/plugin/dict/sql/mysql/init_test_data.sql

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@ values
1010
(8, '菜单显示', 'sys_menu_display', 1, '菜单是否显示', now(), null),
1111
(9, '菜单缓存', 'sys_menu_cache', 1, '菜单是否缓存', now(), null);
1212

13-
insert into sys_dict_data (id, label, value, sort, status, remark, type_id, created_time, updated_time)
13+
insert into sys_dict_data (id, type_code, label, value, sort, status, remark, type_id, created_time, updated_time)
1414
values
15-
(1, '停用', 0, 1, 1, '系统停用状态', 1, now(), null),
16-
(2, '正常', 1, 2, 1, '系统正常状态', 1, now(), null),
17-
(3, '目录', 0, 1, 1, '菜单目录类型', 2, now(), null),
18-
(4, '菜单', 1, 2, 1, '普通菜单类型', 2, now(), null),
19-
(5, '按钮', 2, 3, 1, '按钮权限类型', 2, now(), null),
20-
(6, '内嵌', 3, 4, 1, '内嵌页面类型', 2, now(), null),
21-
(7, '外链', 4, 5, 1, '外部链接类型', 2, now(), null),
22-
(8, '失败', 0, 1, 1, '登录失败状态', 3, now(), null),
23-
(9, '成功', 1, 2, 1, '登录成功状态', 3, now(), null),
24-
(10, 'AND', 0, 1, 1, '逻辑与运算符', 4, now(), null),
25-
(11, 'OR', 1, 2, 1, '逻辑或运算符', 4, now(), null),
26-
(12, '等于(==)', 0, 1, 1, '等于比较表达式', 5, now(), null),
27-
(13, '不等于(!=)', 1, 2, 1, '不等于比较表达式', 5, now(), null),
28-
(14, '大于(>)', 2, 3, 1, '大于比较表达式', 5, now(), null),
29-
(15, '大于等于(>=)', 3, 4, 1, '大于等于比较表达式', 5, now(), null),
30-
(16, '小于(<)', 4, 5, 1, '小于比较表达式', 5, now(), null),
31-
(17, '小于等于(<=)', 5, 6, 1, '小于等于比较表达式', 5, now(), null),
32-
(18, '包含(in)', 6, 7, 1, '包含表达式', 5, now(), null),
33-
(19, '不包含(not in)', 7, 8, 1, '不包含表达式', 5, now(), null),
34-
(20, '', 0, 1, 1, '不是前端参数配置', 6, now(), null),
35-
(21, '', 1, 2, 1, '是前端参数配置', 6, now(), null),
36-
(22, '', 0, 1, 1, '不进行数据权限过滤', 7, now(), null),
37-
(23, '', 1, 2, 1, '进行数据权限过滤', 7, now(), null),
38-
(24, '隐藏', 0, 1, 1, '菜单隐藏', 8, now(), null),
39-
(25, '显示', 1, 2, 1, '菜单显示', 8, now(), null),
40-
(26, '不缓存', 0, 1, 1, '菜单不缓存', 9, now(), null),
41-
(27, '缓存', 1, 2, 1, '菜单缓存', 9, now(), null);
15+
(1, 'sys_status', '停用', '0', 1, 1, '系统停用状态', 1, now(), null),
16+
(2, 'sys_status', '正常', '1', 2, 1, '系统正常状态', 1, now(), null),
17+
(3, 'sys_menu_type', '目录', '0', 1, 1, '菜单目录类型', 2, now(), null),
18+
(4, 'sys_menu_type', '菜单', '1', 2, 1, '普通菜单类型', 2, now(), null),
19+
(5, 'sys_menu_type', '按钮', '2', 3, 1, '按钮权限类型', 2, now(), null),
20+
(6, 'sys_menu_type', '内嵌', '3', 4, 1, '内嵌页面类型', 2, now(), null),
21+
(7, 'sys_menu_type', '外链', '4', 5, 1, '外部链接类型', 2, now(), null),
22+
(8, 'sys_login_status', '失败', '0', 1, 1, '登录失败状态', 3, now(), null),
23+
(9, 'sys_login_status', '成功', '1', 2, 1, '登录成功状态', 3, now(), null),
24+
(10, 'sys_data_rule_operator', 'AND', '0', 1, 1, '逻辑与运算符', 4, now(), null),
25+
(11, 'sys_data_rule_operator', 'OR', '1', 2, 1, '逻辑或运算符', 4, now(), null),
26+
(12, 'sys_data_rule_expression', '等于(==)', '0', 1, 1, '等于比较表达式', 5, now(), null),
27+
(13, 'sys_data_rule_expression', '不等于(!=)', '1', 2, 1, '不等于比较表达式', 5, now(), null),
28+
(14, 'sys_data_rule_expression', '大于(>)', '2', 3, 1, '大于比较表达式', 5, now(), null),
29+
(15, 'sys_data_rule_expression', '大于等于(>=)', '3', 4, 1, '大于等于比较表达式', 5, now(), null),
30+
(16, 'sys_data_rule_expression', '小于(<)', '4', 5, 1, '小于比较表达式', 5, now(), null),
31+
(17, 'sys_data_rule_expression', '小于等于(<=)', '5', 6, 1, '小于等于比较表达式', 5, now(), null),
32+
(18, 'sys_data_rule_expression', '包含(in)', '6', 7, 1, '包含表达式', 5, now(), null),
33+
(19, 'sys_data_rule_expression', '不包含(not in)', '7', 8, 1, '不包含表达式', 5, now(), null),
34+
(20, 'sys_frontend_config', '', '0', 1, 1, '不是前端参数配置', 6, now(), null),
35+
(21, 'sys_frontend_config', '', '1', 2, 1, '是前端参数配置', 6, now(), null),
36+
(22, 'sys_data_permission', '', '0', 1, 1, '不进行数据权限过滤', 7, now(), null),
37+
(23, 'sys_data_permission', '', '1', 2, 1, '进行数据权限过滤', 7, now(), null),
38+
(24, 'sys_menu_display', '隐藏', '0', 1, 1, '菜单隐藏', 8, now(), null),
39+
(25, 'sys_menu_display', '显示', '1', 2, 1, '菜单显示', 8, now(), null),
40+
(26, 'sys_menu_cache', '不缓存', '0', 1, 1, '菜单不缓存', 9, now(), null),
41+
(27, 'sys_menu_cache', '缓存', '1', 2, 1, '菜单缓存', 9, now(), null);

0 commit comments

Comments
 (0)