user_group.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 UpdateUserGroupCommand struct {
  27. Id int64
  28. Name string
  29. }
  30. type DeleteUserGroupCommand struct {
  31. Id int64
  32. }
  33. type GetUserGroupByIdQuery struct {
  34. Id int64
  35. Result *UserGroup
  36. }
  37. type GetUserGroupsByUserQuery struct {
  38. UserId int64 `json:"userId"`
  39. Result []*UserGroup `json:"userGroups"`
  40. }
  41. type SearchUserGroupsQuery struct {
  42. Query string
  43. Name string
  44. Limit int
  45. Page int
  46. OrgId int64
  47. Result SearchUserGroupQueryResult
  48. }
  49. type SearchUserGroupQueryResult struct {
  50. TotalCount int64 `json:"totalCount"`
  51. UserGroups []*UserGroup `json:"userGroups"`
  52. Page int `json:"page"`
  53. PerPage int `json:"perPage"`
  54. }