account.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. Login string `xorm:"UNIQUE NOT NULL"`
  13. Email string `xorm:"UNIQUE NOT NULL"`
  14. Name string
  15. FullName string
  16. Password string
  17. IsAdmin bool
  18. Rands string `xorm:"VARCHAR(10)"`
  19. Salt string `xorm:"VARCHAR(10)"`
  20. Company string
  21. NextDashboardId int
  22. UsingAccountId int64
  23. Created time.Time
  24. Updated time.Time
  25. }
  26. // api projection
  27. type OtherAccountDTO struct {
  28. Id int64 `json:"id"`
  29. Email string `json:"email"`
  30. Role string `json:"role"`
  31. IsUsing bool `json:"isUsing"`
  32. }
  33. // api projection model
  34. type CollaboratorDTO struct {
  35. AccountId int64 `json:"accountId"`
  36. Email string `json:"email"`
  37. Role string `json:"role"`
  38. }
  39. // api view projection
  40. type AccountDTO struct {
  41. Email string `json:"email"`
  42. Name string `json:"name"`
  43. Collaborators []*CollaboratorDTO `json:"collaborators"`
  44. }
  45. type CreateAccountCommand struct {
  46. Email string `json:"email" binding:"required"`
  47. Login string `json:"login"`
  48. Password string `json:"password" binding:"required"`
  49. Name string `json:"name"`
  50. Company string `json:"company"`
  51. Salt string `json:"-"`
  52. Result Account `json:"-"`
  53. }
  54. type SetUsingAccountCommand struct {
  55. AccountId int64
  56. UsingAccountId int64
  57. }
  58. // returns a view projection
  59. type GetAccountInfoQuery struct {
  60. Id int64
  61. Result AccountDTO
  62. }
  63. // returns a view projection
  64. type GetOtherAccountsQuery struct {
  65. AccountId int64
  66. Result []*OtherAccountDTO
  67. }
  68. type GetAccountByIdQuery struct {
  69. Id int64
  70. Result *Account
  71. }
  72. type GetAccountByLoginQuery struct {
  73. Login string
  74. Result *Account
  75. }