You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
1.6 KiB

  1. package source
  2. import (
  3. "gin-vue-admin/global"
  4. "gin-vue-admin/model"
  5. "github.com/gookit/color"
  6. )
  7. var AuthorityMenu = new(authorityMenu)
  8. type authorityMenu struct{}
  9. //@author: [SliverHorn](https://github.com/SliverHorn)
  10. //@description: authority_menu 视图数据初始化
  11. func (a *authorityMenu) Init() error {
  12. if global.GVA_DB.Find(&[]model.SysMenu{}).RowsAffected > 0 {
  13. color.Danger.Println("\n[Mysql] --> authority_menu 视图已存在!")
  14. return nil
  15. }
  16. if err := global.GVA_DB.Exec("CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `authority_menu` AS select `sys_base_menus`.`id` AS `id`,`sys_base_menus`.`created_at` AS `created_at`, `sys_base_menus`.`updated_at` AS `updated_at`, `sys_base_menus`.`deleted_at` AS `deleted_at`, `sys_base_menus`.`menu_level` AS `menu_level`,`sys_base_menus`.`parent_id` AS `parent_id`,`sys_base_menus`.`path` AS `path`,`sys_base_menus`.`name` AS `name`,`sys_base_menus`.`hidden` AS `hidden`,`sys_base_menus`.`component` AS `component`, `sys_base_menus`.`title` AS `title`,`sys_base_menus`.`icon` AS `icon`,`sys_base_menus`.`sort` AS `sort`,`sys_authority_menus`.`sys_authority_authority_id` AS `authority_id`,`sys_authority_menus`.`sys_base_menu_id` AS `menu_id`,`sys_base_menus`.`keep_alive` AS `keep_alive`,`sys_base_menus`.`close_tab` AS `close_tab`,`sys_base_menus`.`default_menu` AS `default_menu` from (`sys_authority_menus` join `sys_base_menus` on ((`sys_authority_menus`.`sys_base_menu_id` = `sys_base_menus`.`id`)))").Error; err != nil {
  17. return err
  18. }
  19. color.Info.Println("\n[Mysql] --> authority_menu 视图创建成功!")
  20. return nil
  21. }