account.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package models
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. // Typed errors
  7. var (
  8. ErrAccountNotFound = errors.New("Account not found")
  9. )
  10. type Account struct {
  11. Id int64
  12. Version int
  13. Name string
  14. Created time.Time
  15. Updated time.Time
  16. }
  17. // ---------------------
  18. // COMMANDS
  19. type CreateAccountCommand struct {
  20. Name string `json:"name" binding:"Required"`
  21. // initial admin user for account
  22. UserId int64 `json:"-"`
  23. Result Account `json:"-"`
  24. }
  25. type UpdateAccountCommand struct {
  26. Name string `json:"name" binding:"Required"`
  27. AccountId int64 `json:"-"`
  28. }
  29. type GetUserAccountsQuery struct {
  30. UserId int64
  31. Result []*UserAccountDTO
  32. }
  33. type GetAccountByIdQuery struct {
  34. Id int64
  35. Result *Account
  36. }
  37. type GetAccountByNameQuery struct {
  38. Name string
  39. Result *Account
  40. }
  41. type GetAccountsQuery struct {
  42. Result []*Account
  43. }
  44. type AccountDTO struct {
  45. Id int64 `json:"id"`
  46. Name string `json:"name"`
  47. }
  48. type UserAccountDTO struct {
  49. AccountId int64 `json:"accountId"`
  50. Name string `json:"name"`
  51. Role RoleType `json:"role"`
  52. IsUsing bool `json:"isUsing"`
  53. }