org.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package models
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. // Typed errors
  7. var (
  8. ErrOrgNotFound = errors.New("Organization not found")
  9. ErrOrgNameTaken = errors.New("Organization name is taken")
  10. )
  11. type Org struct {
  12. Id int64
  13. Version int
  14. Name string
  15. Address1 string
  16. Address2 string
  17. City string
  18. ZipCode string
  19. State string
  20. Country string
  21. Created time.Time
  22. Updated time.Time
  23. }
  24. // ---------------------
  25. // COMMANDS
  26. type CreateOrgCommand struct {
  27. Name string `json:"name" binding:"Required"`
  28. // initial admin user for account
  29. UserId int64 `json:"-"`
  30. Result Org `json:"-"`
  31. }
  32. type DeleteOrgCommand struct {
  33. Id int64
  34. }
  35. type UpdateOrgCommand struct {
  36. Name string
  37. OrgId int64
  38. }
  39. type UpdateOrgAddressCommand struct {
  40. OrgId int64
  41. Address
  42. }
  43. type GetOrgByIdQuery struct {
  44. Id int64
  45. Result *Org
  46. }
  47. type GetOrgByNameQuery struct {
  48. Name string
  49. Result *Org
  50. }
  51. type SearchOrgsQuery struct {
  52. Query string
  53. Name string
  54. Limit int
  55. Page int
  56. Result []*OrgDTO
  57. }
  58. type OrgDTO struct {
  59. Id int64 `json:"id"`
  60. Name string `json:"name"`
  61. }
  62. type OrgDetailsDTO struct {
  63. Id int64 `json:"id"`
  64. Name string `json:"name"`
  65. Address Address `json:"address"`
  66. }
  67. type UserOrgDTO struct {
  68. OrgId int64 `json:"orgId"`
  69. Name string `json:"name"`
  70. Role RoleType `json:"role"`
  71. }