account.go 950 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. Name string
  13. Created time.Time
  14. Updated time.Time
  15. }
  16. // ---------------------
  17. // COMMANDS
  18. type CreateAccountCommand struct {
  19. Name string `json:"name" binding:"Required"`
  20. // initial admin user for account
  21. UserId int64 `json:"-"`
  22. Result Account `json:"-"`
  23. }
  24. type UpdateAccountCommand struct {
  25. Name string `json:"name" binding:"Required"`
  26. AccountId int64 `json:"-"`
  27. }
  28. type GetUserAccountsQuery struct {
  29. UserId int64
  30. Result []*UserAccountDTO
  31. }
  32. type GetAccountByIdQuery struct {
  33. Id int64
  34. Result *Account
  35. }
  36. type AccountDTO struct {
  37. Id int64 `json:"id"`
  38. Name string `json:"name"`
  39. }
  40. type UserAccountDTO struct {
  41. AccountId int64 `json:"accountId"`
  42. Name string `json:"name"`
  43. Role RoleType `json:"role"`
  44. IsUsing bool `json:"isUsing"`
  45. }