调整部分前端布局和后端增删改逻辑
This commit is contained in:
@@ -141,47 +141,27 @@ class GenTableDao:
|
||||
:param is_page: 是否开启分页
|
||||
:return: 数据库列表信息对象
|
||||
"""
|
||||
if DataBaseConfig.db_type == 'postgresql':
|
||||
query_sql = """
|
||||
table_name as table_name,
|
||||
table_comment as table_comment,
|
||||
create_time as create_time,
|
||||
update_time as update_time
|
||||
from
|
||||
list_table
|
||||
where
|
||||
table_name not like 'apscheduler_%'
|
||||
and table_name not like 'gen_%'
|
||||
and table_name not in (select table_name from gen_table)
|
||||
"""
|
||||
else:
|
||||
query_sql = r"""
|
||||
table_name as table_name,
|
||||
table_comment as table_comment,
|
||||
create_time as create_time,
|
||||
update_time as update_time
|
||||
from
|
||||
information_schema.tables
|
||||
where
|
||||
table_schema = (select database())
|
||||
and table_name not like 'apscheduler\_%'
|
||||
and table_name not like 'gen\_%'
|
||||
and table_name not in (select table_name from gen_table)
|
||||
"""
|
||||
query_sql = r"""
|
||||
table_name as table_name,
|
||||
table_comment as table_comment,
|
||||
create_time as create_time,
|
||||
update_time as update_time
|
||||
from
|
||||
information_schema.tables
|
||||
where
|
||||
table_schema = (select database())
|
||||
and table_name not like 'apscheduler\_%'
|
||||
and table_name not like 'gen\_%'
|
||||
and table_name not in (select table_name from gen_table)
|
||||
"""
|
||||
if query_object.table_name:
|
||||
query_sql += """and lower(table_name) like lower(concat('%', :table_name, '%'))"""
|
||||
if query_object.table_comment:
|
||||
query_sql += """and lower(table_comment) like lower(concat('%', :table_comment, '%'))"""
|
||||
if query_object.begin_time:
|
||||
if DataBaseConfig.db_type == 'postgresql':
|
||||
query_sql += """and create_time::date >= to_date(:begin_time, 'yyyy-MM-dd')"""
|
||||
else:
|
||||
query_sql += """and date_format(create_time, '%Y%m%d') >= date_format(:begin_time, '%Y%m%d')"""
|
||||
query_sql += """and date_format(create_time, '%Y%m%d') >= date_format(:begin_time, '%Y%m%d')"""
|
||||
if query_object.end_time:
|
||||
if DataBaseConfig.db_type == 'postgresql':
|
||||
query_sql += """and create_time::date <= to_date(:end_time, 'yyyy-MM-dd')"""
|
||||
else:
|
||||
query_sql += """and date_format(create_time, '%Y%m%d') >= date_format(:end_time, '%Y%m%d')"""
|
||||
query_sql += """and date_format(create_time, '%Y%m%d') >= date_format(:end_time, '%Y%m%d')"""
|
||||
query_sql += """order by create_time desc"""
|
||||
query = select(
|
||||
text(query_sql).bindparams(**query_object.model_dump(exclude_none=True, exclude={'page_num', 'page_size'}))
|
||||
@@ -201,35 +181,20 @@ class GenTableDao:
|
||||
:param table_names: 业务表名称组
|
||||
:return: 数据库列表信息对象
|
||||
"""
|
||||
if DataBaseConfig.db_type == 'postgresql':
|
||||
query_sql = """
|
||||
select
|
||||
table_name as table_name,
|
||||
table_comment as table_comment,
|
||||
create_time as create_time,
|
||||
update_time as update_time
|
||||
from
|
||||
list_table
|
||||
where
|
||||
table_name not like 'qrtz_%'
|
||||
and table_name not like 'gen_%'
|
||||
and table_name = any(:table_names)
|
||||
"""
|
||||
else:
|
||||
query_sql = r"""
|
||||
select
|
||||
table_name as table_name,
|
||||
table_comment as table_comment,
|
||||
create_time as create_time,
|
||||
update_time as update_time
|
||||
from
|
||||
information_schema.tables
|
||||
where
|
||||
table_name not like 'qrtz\_%'
|
||||
and table_name not like 'gen\_%'
|
||||
and table_schema = (select database())
|
||||
and table_name in :table_names
|
||||
"""
|
||||
query_sql = r"""
|
||||
select
|
||||
table_name as table_name,
|
||||
table_comment as table_comment,
|
||||
create_time as create_time,
|
||||
update_time as update_time
|
||||
from
|
||||
information_schema.tables
|
||||
where
|
||||
table_name not like 'qrtz\_%'
|
||||
and table_name not like 'gen\_%'
|
||||
and table_schema = (select database())
|
||||
and table_name in :table_names
|
||||
"""
|
||||
query = text(query_sql).bindparams(table_names=tuple(table_names))
|
||||
gen_db_table_list = (await db.execute(query)).fetchall()
|
||||
|
||||
@@ -308,42 +273,32 @@ class GenTableColumnDao:
|
||||
:param table_name: 业务表名称
|
||||
:return: 业务表字段列表信息对象
|
||||
"""
|
||||
if DataBaseConfig.db_type == 'postgresql':
|
||||
query_sql = """
|
||||
select
|
||||
column_name, is_required, is_pk, sort, column_comment, is_increment, column_type
|
||||
from
|
||||
list_column
|
||||
where
|
||||
table_name = :table_name
|
||||
"""
|
||||
else:
|
||||
query_sql = """
|
||||
select
|
||||
column_name as column_name,
|
||||
case
|
||||
when is_nullable = 'no' and column_key != 'PRI' then '1'
|
||||
else '0'
|
||||
end as is_required,
|
||||
case
|
||||
when column_key = 'PRI' then '1'
|
||||
else '0'
|
||||
end as is_pk,
|
||||
ordinal_position as sort,
|
||||
column_comment as column_comment,
|
||||
case
|
||||
when extra = 'auto_increment' then '1'
|
||||
else '0'
|
||||
end as is_increment,
|
||||
column_type as column_type
|
||||
from
|
||||
information_schema.columns
|
||||
where
|
||||
table_schema = (select database())
|
||||
and table_name = :table_name
|
||||
order by
|
||||
ordinal_position
|
||||
"""
|
||||
query_sql = """
|
||||
select
|
||||
column_name as column_name,
|
||||
case
|
||||
when is_nullable = 'no' and column_key != 'PRI' then '1'
|
||||
else '0'
|
||||
end as is_required,
|
||||
case
|
||||
when column_key = 'PRI' then '1'
|
||||
else '0'
|
||||
end as is_pk,
|
||||
ordinal_position as sort,
|
||||
column_comment as column_comment,
|
||||
case
|
||||
when extra = 'auto_increment' then '1'
|
||||
else '0'
|
||||
end as is_increment,
|
||||
column_type as column_type
|
||||
from
|
||||
information_schema.columns
|
||||
where
|
||||
table_schema = (select database())
|
||||
and table_name = :table_name
|
||||
order by
|
||||
ordinal_position
|
||||
"""
|
||||
query = text(query_sql).bindparams(table_name=table_name)
|
||||
gen_db_table_columns = (await db.execute(query)).fetchall()
|
||||
|
||||
|
||||
@@ -1,30 +1,3 @@
|
||||
{% if dbType == 'postgresql' %}
|
||||
DO $$
|
||||
DECLARE
|
||||
parentId bigint;
|
||||
BEGIN
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('{{ functionName }}', '{{ parentMenuId }}', '1', '{{ businessName }}', '{{ moduleName }}/{{ businessName }}/index', 1, 0, 'C', '0', '0', '{{ permissionPrefix }}:list', '#', 'admin', current_timestamp, '', null, '{{ functionName }}菜单')
|
||||
returning menu_id into parentId;
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('{{ functionName }}查询', parentId, '1', '#', '', 1, 0, 'F', '0', '0', '{{ permissionPrefix }}:query', '#', 'admin', current_timestamp, '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('{{ functionName }}新增', parentId, '2', '#', '', 1, 0, 'F', '0', '0', '{{ permissionPrefix }}:add', '#', 'admin', current_timestamp, '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('{{ functionName }}修改', parentId, '3', '#', '', 1, 0, 'F', '0', '0', '{{ permissionPrefix }}:edit', '#', 'admin', current_timestamp, '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('{{ functionName }}删除', parentId, '4', '#', '', 1, 0, 'F', '0', '0', '{{ permissionPrefix }}:remove', '#', 'admin', current_timestamp, '', null, '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('{{ functionName }}导出', parentId, '5', '#', '', 1, 0, 'F', '0', '0', '{{ permissionPrefix }}:export', '#', 'admin', current_timestamp, '', null, '');
|
||||
END $$;
|
||||
{% else %}
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('{{ functionName }}', '{{ parentMenuId }}', '1', '{{ businessName }}', '{{ moduleName }}/{{ businessName }}/index', 1, 0, 'C', '0', '0', '{{ permissionPrefix }}:list', '#', 'admin', sysdate(), '', null, '{{ functionName }}菜单');
|
||||
@@ -47,4 +20,3 @@ values('{{ functionName }}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0'
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('{{ functionName }}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '{{ permissionPrefix }}:export', '#', 'admin', sysdate(), '', null, '');
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user