user_group.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. Result SearchUserGroupQueryResult
  47. }
  48. type SearchUserGroupQueryResult struct {
  49. TotalCount int64 `json:"totalCount"`
  50. UserGroups []*UserGroup `json:"userGroups"`
  51. Page int `json:"page"`
  52. PerPage int `json:"perPage"`
  53. }