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.

83 lines
1.7 KiB

  1. package information
  2. import (
  3. "gin-vue-admin/global"
  4. "github.com/gookit/color"
  5. "gorm.io/gorm"
  6. )
  7. var AuthoritiesMenus = new(authoritiesMenus)
  8. type authoritiesMenus struct{}
  9. type AuthorityMenus struct {
  10. AuthorityId string `gorm:"column:sys_authority_authority_id"`
  11. BaseMenuId uint `gorm:"column:sys_base_menu_id"`
  12. }
  13. var authorityMenus = []AuthorityMenus{
  14. {"888", 1},
  15. {"888", 2},
  16. {"888", 3},
  17. {"888", 4},
  18. {"888", 5},
  19. {"888", 6},
  20. {"888", 7},
  21. {"888", 8},
  22. {"888", 9},
  23. {"888", 10},
  24. {"888", 11},
  25. {"888", 12},
  26. {"888", 13},
  27. {"888", 14},
  28. {"888", 15},
  29. {"888", 16},
  30. {"888", 17},
  31. {"888", 18},
  32. {"888", 19},
  33. {"888", 20},
  34. {"888", 21},
  35. {"888", 22},
  36. {"888", 23},
  37. {"888", 24},
  38. {"888", 25},
  39. {"888", 26},
  40. {"888", 27},
  41. {"888", 28},
  42. {"888", 29},
  43. {"8881", 1},
  44. {"8881", 2},
  45. {"8881", 8},
  46. {"9528", 1},
  47. {"9528", 2},
  48. {"9528", 3},
  49. {"9528", 4},
  50. {"9528", 5},
  51. {"9528", 6},
  52. {"9528", 7},
  53. {"9528", 8},
  54. {"9528", 9},
  55. {"9528", 10},
  56. {"9528", 11},
  57. {"9528", 12},
  58. {"9528", 14},
  59. {"9528", 15},
  60. {"9528", 16},
  61. {"9528", 17},
  62. }
  63. //@author: [SliverHorn](https://github.com/SliverHorn)
  64. //@description: sys_authority_menus 表数据初始化
  65. func (a *authoritiesMenus) Init() error {
  66. return global.GVA_DB.Table("sys_authority_menus").Transaction(func(tx *gorm.DB) error {
  67. if tx.Where("sys_authority_authority_id IN ('888', '8881', '9528')").Find(&[]AuthorityMenus{}).RowsAffected == 48 {
  68. color.Danger.Println("\n[Mysql] --> sys_authority_menus 表的初始数据已存在!")
  69. return nil
  70. }
  71. if err := tx.Create(&authorityMenus).Error; err != nil { // 遇到错误时回滚事务
  72. return err
  73. }
  74. color.Info.Println("\n[Mysql] --> sys_authority_menus 表初始数据成功!")
  75. return nil
  76. })
  77. }