account.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 DeleteAccountCommand struct {
  26. Id int64
  27. }
  28. type UpdateAccountCommand struct {
  29. Name string `json:"name" binding:"Required"`
  30. AccountId int64 `json:"-"`
  31. }
  32. type GetUserAccountsQuery struct {
  33. UserId int64
  34. Result []*UserAccountDTO
  35. }
  36. type GetAccountByIdQuery struct {
  37. Id int64
  38. Result *Account
  39. }
  40. type GetAccountByNameQuery struct {
  41. Name string
  42. Result *Account
  43. }
  44. type GetAccountsQuery struct {
  45. Result []*Account
  46. }
  47. type AccountDTO struct {
  48. Id int64 `json:"id"`
  49. Name string `json:"name"`
  50. }
  51. type UserAccountDTO struct {
  52. AccountId int64 `json:"accountId"`
  53. Name string `json:"name"`
  54. Role RoleType `json:"role"`
  55. IsUsing bool `json:"isUsing"`
  56. }