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.

79 lines
1.6 KiB

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