diff --git a/api/v1/system/sys_auth_rule.go b/api/v1/system/sys_auth_rule.go index 272a6aa..bf028c7 100644 --- a/api/v1/system/sys_auth_rule.go +++ b/api/v1/system/sys_auth_rule.go @@ -66,7 +66,7 @@ type RuleGetParamsRes struct { type RuleInfoReq struct { g.Meta `path:"/menu/get" tags:"系统后台/菜单管理" method:"get" summary:"获取菜单信息"` commonApi.Author - Id uint `p:"required#菜单id必须"` + Id uint `p:"id" v:"required#菜单id必须"` } type RuleInfoRes struct { diff --git a/resource/template/vm/sql/mysql.template b/resource/template/vm/sql/mysql.template index cae7d66..999dcb4 100644 --- a/resource/template/vm/sql/mysql.template +++ b/resource/template/vm/sql/mysql.template @@ -27,12 +27,17 @@ DELETE FROM `sys_auth_rule` WHERE `name` = '{{.apiVersion}}/{{.modulePath}}/{{$. -- 当前日期 select @now := now(); +{{if eq .table.MenuPid 0}} -- 目录 SQL INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at` ) -VALUES({{.table.MenuPid}},'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','{{.table.TableComment}}管理','iconfont icon-fuwenbenkuang','','{{.table.TableComment}}管理',0,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','','layout/routerView/parent',0,'sys_admin',0,@now,@now); +VALUES(0,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','{{.table.TableComment}}管理','iconfont icon-fuwenbenkuang','','{{.table.TableComment}}管理',0,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','','layout/routerView/parent',0,'sys_admin',0,@now,@now); -- 菜单父目录ID SELECT @parentId := LAST_INSERT_ID(); +{{else}} +-- 菜单父目录ID +SELECT @parentId := {{$.table.MenuPid}}; +{{end}} -- 菜单 SQL INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`) diff --git a/resource/template/vm/sql/pgsql.template b/resource/template/vm/sql/pgsql.template index 9f84f9c..0bfc8e6 100644 --- a/resource/template/vm/sql/pgsql.template +++ b/resource/template/vm/sql/pgsql.template @@ -29,14 +29,18 @@ DELETE FROM sys_auth_rule WHERE name = '{{.apiVersion}}/{{.modulePath}}/{{$.tabl {{end}} {{end}} - +{{if eq .table.MenuPid 0}} -- 目录 SQL INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at ) -VALUES({{.table.MenuPid}},'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','{{.table.TableComment}}管理','iconfont icon-fuwenbenkuang','','{{.table.TableComment}}管理',0,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','','layout/routerView/parent',0,'sys_admin',0,v_time,v_time) RETURNING id INTO parentId; - +VALUES(0,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','{{.table.TableComment}}管理','iconfont icon-fuwenbenkuang','','{{.table.TableComment}}管理',0,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','','layout/routerView/parent',0,'sys_admin',0,v_time,v_time) RETURNING id INTO parentId; -- 菜单 SQL INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at) VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','{{.table.TableComment}}列表','ele-Fold','','{{.table.TableComment}}列表',1,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','','{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list/index',0,'sys_admin',0,v_time,v_time) RETURNING id INTO parentId; +{{else}} + -- 菜单 SQL + INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at) + VALUES({{$.table.MenuPid}},'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','{{.table.TableComment}}列表','ele-Fold','','{{.table.TableComment}}列表',1,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','','{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list/index',0,'sys_admin',0,v_time,v_time) RETURNING id INTO parentId; +{{end}} -- 按钮 SQL INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at)