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.5 KiB

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