account.go 1.7 KB

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