org.go 1002 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package models
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. // Typed errors
  7. var (
  8. ErrOrgNotFound = errors.New("Organization not found")
  9. )
  10. type Org struct {
  11. Id int64
  12. Version int
  13. Name string
  14. Created time.Time
  15. Updated time.Time
  16. }
  17. // ---------------------
  18. // COMMANDS
  19. type CreateOrgCommand struct {
  20. Name string `json:"name" binding:"Required"`
  21. // initial admin user for account
  22. UserId int64 `json:"-"`
  23. Result Org `json:"-"`
  24. }
  25. type DeleteOrgCommand struct {
  26. Id int64
  27. }
  28. type UpdateOrgCommand struct {
  29. Name string `json:"name" binding:"Required"`
  30. OrgId int64 `json:"-"`
  31. }
  32. type GetOrgByIdQuery struct {
  33. Id int64
  34. Result *Org
  35. }
  36. type GetOrgByNameQuery struct {
  37. Name string
  38. Result *Org
  39. }
  40. type SearchOrgsQuery struct {
  41. Query string
  42. Name string
  43. Limit int
  44. Page int
  45. Result []*OrgDTO
  46. }
  47. type OrgDTO struct {
  48. Id int64 `json:"id"`
  49. Name string `json:"name"`
  50. }
  51. type UserOrgDTO struct {
  52. OrgId int64 `json:"orgId"`
  53. Name string `json:"name"`
  54. Role RoleType `json:"role"`
  55. }