manager.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package manager
  2. import "go-common/library/time"
  3. // User for manager.
  4. type User struct {
  5. UserID int64 `json:"user_id"`
  6. System string `json:"-"`
  7. UserName string `json:"user_name"`
  8. RoleID int64 `json:"role_id"`
  9. RoleName string `json:"role_name"`
  10. CTime time.Time `json:"-"`
  11. MTime time.Time `json:"-"`
  12. }
  13. // Role for manager.
  14. type Role struct {
  15. RoleID int64 `json:"role_id"`
  16. System string `json:"-"`
  17. RoleName string `json:"role_name"`
  18. Auths map[string]*Auth `json:"auths"`
  19. Models map[string]*Model `json:"models"`
  20. CTime time.Time `json:"-"`
  21. MTime time.Time `json:"-"`
  22. }
  23. // Auth for manager.
  24. type Auth struct {
  25. AuthID int64 `json:"auth_id"`
  26. System string `json:"-"`
  27. AuthName string `json:"auth_name"`
  28. AuthFlag string `json:"auth_flag"`
  29. CTime time.Time `json:"-"`
  30. MTime time.Time `json:"-"`
  31. }
  32. // Users User sorted.
  33. type Users []*User
  34. func (u Users) Len() int { return len(u) }
  35. func (u Users) Less(i, j int) bool { return int64(u[i].UserID) < int64(u[j].UserID) }
  36. func (u Users) Swap(i, j int) { u[i], u[j] = u[j], u[i] }
  37. // Roles Role sorted.
  38. type Roles []*Role
  39. func (r Roles) Len() int { return len(r) }
  40. func (r Roles) Less(i, j int) bool { return int64(r[i].RoleID) < int64(r[j].RoleID) }
  41. func (r Roles) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
  42. // Auths Auth sorted.
  43. type Auths []*Auth
  44. func (a Auths) Len() int { return len(a) }
  45. func (a Auths) Less(i, j int) bool { return int64(a[i].AuthID) < int64(a[j].AuthID) }
  46. func (a Auths) Swap(i, j int) { a[i], a[j] = a[j], a[i] }