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.

23 lines
686 B

  1. package datas
  2. import (
  3. "time"
  4. "gin-vue-admin/model"
  5. "gorm.io/gorm"
  6. )
  7. var Authorities = []model.SysAuthority{
  8. {CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "888", AuthorityName: "普通用户", ParentId: "0"},
  9. {CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "8881", AuthorityName: "普通用户子角色", ParentId: "888"},
  10. {CreatedAt: time.Now(), UpdatedAt: time.Now(), AuthorityId: "9528", AuthorityName: "测试角色", ParentId: "0"},
  11. }
  12. func InitSysAuthority(db *gorm.DB) (err error) {
  13. return db.Transaction(func(tx *gorm.DB) error {
  14. if tx.Create(&Authorities).Error != nil { // 遇到错误时回滚事务
  15. return err
  16. }
  17. return nil
  18. })
  19. }