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.

80 lines
1.4 KiB

  1. package datas
  2. import (
  3. "github.com/gookit/color"
  4. "gorm.io/gorm"
  5. )
  6. type SysAuthorityMenus struct {
  7. SysAuthorityAuthorityId string
  8. SysBaseMenuId uint
  9. }
  10. var AuthorityMenus = []SysAuthorityMenus{
  11. {"888", 1},
  12. {"888", 2},
  13. {"888", 3},
  14. {"888", 4},
  15. {"888", 5},
  16. {"888", 6},
  17. {"888", 7},
  18. {"888", 8},
  19. {"888", 9},
  20. {"888", 10},
  21. {"888", 11},
  22. {"888", 12},
  23. {"888", 13},
  24. {"888", 14},
  25. {"888", 15},
  26. {"888", 16},
  27. {"888", 17},
  28. {"888", 18},
  29. {"888", 19},
  30. {"888", 20},
  31. {"888", 21},
  32. {"888", 22},
  33. {"888", 23},
  34. {"888", 24},
  35. {"888", 25},
  36. {"888", 26},
  37. {"888", 27},
  38. {"8881", 1},
  39. {"8881", 2},
  40. {"8881", 8},
  41. {"8881", 17},
  42. {"8881", 18},
  43. {"8881", 19},
  44. {"8881", 20},
  45. {"9528", 1},
  46. {"9528", 2},
  47. {"9528", 3},
  48. {"9528", 4},
  49. {"9528", 5},
  50. {"9528", 6},
  51. {"9528", 7},
  52. {"9528", 8},
  53. {"9528", 9},
  54. {"9528", 10},
  55. {"9528", 11},
  56. {"9528", 12},
  57. {"9528", 13},
  58. {"9528", 14},
  59. {"9528", 15},
  60. {"9528", 17},
  61. {"9528", 18},
  62. {"9528", 19},
  63. {"9528", 20},
  64. }
  65. func InitSysAuthorityMenus(db *gorm.DB) (err error) {
  66. return db.Table("sys_authority_menus").Transaction(func(tx *gorm.DB) error {
  67. if tx.Where("sys_authority_authority_id IN ?", []string{"888", "8881", "9528"}).Find(&[]SysAuthorityMenus{}).RowsAffected == 53 {
  68. color.Danger.Println("sys_authority_menus表的初始数据已存在!")
  69. return nil
  70. }
  71. if err := tx.Create(&AuthorityMenus).Error; err != nil { // 遇到错误时回滚事务
  72. return err
  73. }
  74. return nil
  75. })
  76. }