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.

77 lines
1.6 KiB

  1. package source
  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. {"8881", 1},
  38. {"8881", 2},
  39. {"8881", 8},
  40. {"9528", 1},
  41. {"9528", 2},
  42. {"9528", 3},
  43. {"9528", 4},
  44. {"9528", 5},
  45. {"9528", 6},
  46. {"9528", 7},
  47. {"9528", 8},
  48. {"9528", 9},
  49. {"9528", 10},
  50. {"9528", 11},
  51. {"9528", 12},
  52. {"9528", 14},
  53. {"9528", 15},
  54. {"9528", 16},
  55. {"9528", 17},
  56. }
  57. //@author: [SliverHorn](https://github.com/SliverHorn)
  58. //@description: sys_authority_menus 表数据初始化
  59. func (a *authoritiesMenus) Init() error {
  60. return global.GVA_DB.Table("sys_authority_menus").Transaction(func(tx *gorm.DB) error {
  61. if tx.Where("sys_authority_authority_id IN ('888', '8881', '9528')").Find(&[]AuthorityMenus{}).RowsAffected == 48 {
  62. color.Danger.Println("\n[Mysql] --> sys_authority_menus 表的初始数据已存在!")
  63. return nil
  64. }
  65. if err := tx.Create(&authorityMenus).Error; err != nil { // 遇到错误时回滚事务
  66. return err
  67. }
  68. color.Info.Println("\n[Mysql] --> sys_authority_menus 表初始数据成功!")
  69. return nil
  70. })
  71. }