| 
									
										
										
										
											2017-03-27 14:36:28 +02:00
										 |  |  | package models | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-09 00:55:07 +02:00
										 |  |  | import ( | 
					
						
							|  |  |  | 	"errors" | 
					
						
							|  |  |  | 	"time" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Typed errors | 
					
						
							|  |  |  | var ( | 
					
						
							|  |  |  | 	ErrUserGroupNotFound  = errors.New("User Group not found") | 
					
						
							|  |  |  | 	ErrUserGroupNameTaken = errors.New("User Group name is taken") | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2017-03-27 14:36:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | // UserGroup model | 
					
						
							|  |  |  | type UserGroup struct { | 
					
						
							| 
									
										
										
										
											2017-04-10 01:24:16 +02:00
										 |  |  | 	Id    int64  `json:"id"` | 
					
						
							|  |  |  | 	OrgId int64  `json:"orgId"` | 
					
						
							|  |  |  | 	Name  string `json:"name"` | 
					
						
							| 
									
										
										
										
											2017-03-27 14:36:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-10 01:24:16 +02:00
										 |  |  | 	Created time.Time `json:"created"` | 
					
						
							|  |  |  | 	Updated time.Time `json:"updated"` | 
					
						
							| 
									
										
										
										
											2017-03-27 14:36:28 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-04-09 00:55:07 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | // --------------------- | 
					
						
							|  |  |  | // COMMANDS | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type CreateUserGroupCommand struct { | 
					
						
							|  |  |  | 	Name  string `json:"name" binding:"Required"` | 
					
						
							| 
									
										
										
										
											2017-04-10 01:24:16 +02:00
										 |  |  | 	OrgId int64  `json:"-"` | 
					
						
							| 
									
										
										
										
											2017-04-09 00:55:07 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	Result UserGroup `json:"-"` | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-18 15:01:05 +02:00
										 |  |  | type UpdateUserGroupCommand struct { | 
					
						
							|  |  |  | 	Id   int64 | 
					
						
							|  |  |  | 	Name string | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-09 00:55:07 +02:00
										 |  |  | type DeleteUserGroupCommand struct { | 
					
						
							|  |  |  | 	Id int64 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type GetUserGroupByIdQuery struct { | 
					
						
							|  |  |  | 	Id     int64 | 
					
						
							|  |  |  | 	Result *UserGroup | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-22 10:33:17 +02:00
										 |  |  | type GetUserGroupsByUserQuery struct { | 
					
						
							|  |  |  | 	UserId int64        `json:"userId"` | 
					
						
							|  |  |  | 	Result []*UserGroup `json:"userGroups"` | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-09 00:55:07 +02:00
										 |  |  | type SearchUserGroupsQuery struct { | 
					
						
							|  |  |  | 	Query string | 
					
						
							|  |  |  | 	Name  string | 
					
						
							|  |  |  | 	Limit int | 
					
						
							|  |  |  | 	Page  int | 
					
						
							| 
									
										
										
										
											2017-06-23 20:55:53 +02:00
										 |  |  | 	OrgId int64 | 
					
						
							| 
									
										
										
										
											2017-04-09 00:55:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-10 01:24:16 +02:00
										 |  |  | 	Result SearchUserGroupQueryResult | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type SearchUserGroupQueryResult struct { | 
					
						
							|  |  |  | 	TotalCount int64        `json:"totalCount"` | 
					
						
							|  |  |  | 	UserGroups []*UserGroup `json:"userGroups"` | 
					
						
							|  |  |  | 	Page       int          `json:"page"` | 
					
						
							|  |  |  | 	PerPage    int          `json:"perPage"` | 
					
						
							| 
									
										
										
										
											2017-04-09 00:55:07 +02:00
										 |  |  | } |