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.

35 lines
1.1 KiB

  1. package system
  2. import (
  3. "github.com/flipped-aurora/gin-vue-admin/server/global"
  4. "github.com/flipped-aurora/gin-vue-admin/server/model/system"
  5. "github.com/pkg/errors"
  6. uuid "github.com/satori/go.uuid"
  7. "gorm.io/gorm"
  8. )
  9. var User = new(user)
  10. type user struct{}
  11. func (u *user) TableName() string {
  12. return "sys_users"
  13. }
  14. func (u *user) Initialize() error {
  15. entities := []system.SysUser{
  16. {UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "https://qmplusimg.henrongyi.top/gva_header.jpg", AuthorityId: "888"},
  17. {UUID: uuid.NewV4(), Username: "a303176530", Password: "3ec063004a6f31642261936a379fde3d", NickName: "QMPlusUser", HeaderImg: "https:///qmplusimg.henrongyi.top/1572075907logo.png", AuthorityId: "9528"},
  18. }
  19. if err := global.GVA_DB.Create(&entities).Error; err != nil {
  20. return errors.Wrap(err, u.TableName()+"表数据初始化失败!")
  21. }
  22. return nil
  23. }
  24. func (u *user) CheckDataExist() bool {
  25. if errors.Is(global.GVA_DB.Where("username = ?", "a303176530").First(&system.SysUser{}).Error, gorm.ErrRecordNotFound) { // 判断是否存在数据
  26. return false
  27. }
  28. return true
  29. }