account.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 AccountDTO struct {
  42. Id int64 `json:"id"`
  43. Name string `json:"name"`
  44. }
  45. type UserAccountDTO struct {
  46. AccountId int64 `json:"accountId"`
  47. Name string `json:"name"`
  48. Role RoleType `json:"role"`
  49. IsUsing bool `json:"isUsing"`
  50. }