user_group.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package models
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. // Typed errors
  7. var (
  8. ErrUserGroupNotFound = errors.New("User Group not found")
  9. ErrUserGroupNameTaken = errors.New("User Group name is taken")
  10. )
  11. // UserGroup model
  12. type UserGroup struct {
  13. Id int64 `json:"id"`
  14. OrgId int64 `json:"orgId"`
  15. Name string `json:"name"`
  16. Created time.Time `json:"created"`
  17. Updated time.Time `json:"updated"`
  18. }
  19. // ---------------------
  20. // COMMANDS
  21. type CreateUserGroupCommand struct {
  22. Name string `json:"name" binding:"Required"`
  23. OrgId int64 `json:"-"`
  24. Result UserGroup `json:"-"`
  25. }
  26. type DeleteUserGroupCommand struct {
  27. Id int64
  28. }
  29. type GetUserGroupByIdQuery struct {
  30. Id int64
  31. Result *UserGroup
  32. }
  33. type SearchUserGroupsQuery struct {
  34. Query string
  35. Name string
  36. Limit int
  37. Page int
  38. Result SearchUserGroupQueryResult
  39. }
  40. type SearchUserGroupQueryResult struct {
  41. TotalCount int64 `json:"totalCount"`
  42. UserGroups []*UserGroup `json:"userGroups"`
  43. Page int `json:"page"`
  44. PerPage int `json:"perPage"`
  45. }