mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
重构代码生成模块的模板文件,统一命名规范为下划线风格 优化GenTableQueryParam查询参数类,移除不必要的字段 修复SQLite数据库支持问题,改进表结构查询逻辑 添加数据验证处理,防止空值导致的异常 改进批量生成代码时的错误处理和参数校验
38 lines
3.3 KiB
Django/Jinja
38 lines
3.3 KiB
Django/Jinja
-- 菜单 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('{{function_name}}', '{{parent_menu_id}}', '1', '{{business_name}}', '{{module_name}}/{{business_name}}/index', 1, 0, 'C', '0', '0', '{{permission_prefix}}:list', '#', 'admin', sysdate(), '', null, '{{function_name}}菜单');
|
||
|
||
-- 按钮父菜单ID
|
||
SELECT @parentId := LAST_INSERT_ID();
|
||
|
||
-- 按钮 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('{{function_name}}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '{{permission_prefix}}:query', '#', 'admin', sysdate(), '', 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('{{function_name}}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '{{permission_prefix}}:add', '#', 'admin', sysdate(), '', 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('{{function_name}}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '{{permission_prefix}}:edit', '#', 'admin', sysdate(), '', 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('{{function_name}}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '{{permission_prefix}}:remove', '#', 'admin', sysdate(), '', 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('{{function_name}}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '{{permission_prefix}}:export', '#', 'admin', sysdate(), '', 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('{{function_name}}导入', @parentId, '6', '#', '', 1, 0, 'F', '0', '0', '{{permission_prefix}}:import', '#', 'admin', sysdate(), '', null, '');
|
||
|
||
|
||
{% for column in columns %}
|
||
{% set pythonField = column.python_field | snake_to_camel %}
|
||
{% set column_comment = column.column_comment if column.column_comment else '' %}
|
||
{% set parentheseIndex = column_comment.find("(") %}
|
||
{% set comment = column_comment[:parentheseIndex] if parentheseIndex != -1 else column_comment %}
|
||
{% if column.is_list %}
|
||
INSERT INTO `sys_table` (`table_name`, `field_name`, `prop`, `label`, `sequence`) VALUES ('{{ table_name }}', '{{ column.python_field }}', '{{ pythonField }}', '{{ comment }}', {{ loop.index0 }});
|
||
{% endif %}
|
||
{% endfor %}
|
||
INSERT INTO `sys_table` (`table_name`, `field_name`, `prop`, `label`, `sequence`, `fixed`) VALUES ('{{ table_name }}', 'operate', 'operate', '操作', {{ columns|length }}, '2');
|