account.go 1021 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 GetAccountByNameQuery struct {
  37. Name string
  38. Result *Account
  39. }
  40. type AccountDTO struct {
  41. Id int64 `json:"id"`
  42. Name string `json:"name"`
  43. }
  44. type UserAccountDTO struct {
  45. AccountId int64 `json:"accountId"`
  46. Name string `json:"name"`
  47. Role RoleType `json:"role"`
  48. IsUsing bool `json:"isUsing"`
  49. }