admin.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package model
  2. import "gorm.io/gorm"
  3. const (
  4. AdminRole = "admin"
  5. AdminUserID = "1"
  6. MenuResourcePrefix = "menu:"
  7. ApiResourcePrefix = "api:"
  8. PermSep = ","
  9. )
  10. type AdminUser struct {
  11. gorm.Model
  12. Username string `gorm:"type:varchar(50);not null;uniqueIndex;comment:'用户名'"`
  13. Nickname string `gorm:"type:varchar(50);not null;comment:'昵称'"`
  14. Password string `gorm:"type:varchar(255);not null;comment:'密码'"`
  15. Email string `gorm:"type:varchar(100);not null;comment:'电子邮件'"`
  16. Phone string `gorm:"type:varchar(20);not null;comment:'手机号'"`
  17. }
  18. func (m *AdminUser) TableName() string {
  19. return "admin_users"
  20. }
  21. type Role struct {
  22. gorm.Model
  23. Name string `json:"name" gorm:"column:name;type:varchar(100);uniqueIndex;comment:角色名"`
  24. Sid string `json:"sid" gorm:"column:sid;type:varchar(100);uniqueIndex;comment:角色标识"`
  25. }
  26. func (m *Role) TableName() string {
  27. return "roles"
  28. }
  29. type Api struct {
  30. gorm.Model
  31. Group string `gorm:"type:varchar(100);not null;comment:'API分组'"`
  32. Name string `gorm:"type:varchar(100);not null;comment:'API名称'"`
  33. Path string `gorm:"type:varchar(255);not null;comment:'API路径'"`
  34. Method string `gorm:"type:varchar(20);not null;comment:'HTTP方法'"`
  35. }
  36. func (m *Api) TableName() string {
  37. return "api"
  38. }