2017-04-08 17:55:07 -05:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Typed errors
|
|
|
|
var (
|
|
|
|
ErrUserGroupMemberAlreadyAdded = errors.New("User is already added to this user group")
|
|
|
|
)
|
|
|
|
|
|
|
|
// UserGroupMember model
|
|
|
|
type UserGroupMember struct {
|
|
|
|
Id int64
|
|
|
|
OrgId int64
|
|
|
|
UserGroupId int64
|
|
|
|
UserId int64
|
|
|
|
|
|
|
|
Created time.Time
|
|
|
|
Updated time.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------
|
|
|
|
// COMMANDS
|
|
|
|
|
|
|
|
type AddUserGroupMemberCommand struct {
|
2017-04-19 08:35:11 -05:00
|
|
|
UserId int64 `json:"userId" binding:"Required"`
|
2017-04-08 17:55:07 -05:00
|
|
|
OrgId int64 `json:"-"`
|
|
|
|
UserGroupId int64 `json:"-"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type RemoveUserGroupMemberCommand struct {
|
|
|
|
UserId int64
|
|
|
|
UserGroupId int64
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------
|
|
|
|
// QUERIES
|
|
|
|
|
|
|
|
type GetUserGroupMembersQuery struct {
|
|
|
|
UserGroupId int64
|
|
|
|
Result []*UserGroupMemberDTO
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------
|
|
|
|
// Projections and DTOs
|
|
|
|
|
|
|
|
type UserGroupMemberDTO struct {
|
|
|
|
OrgId int64 `json:"orgId"`
|
2017-04-27 15:36:27 -05:00
|
|
|
UserGroupId int64 `json:"userGroupId"`
|
2017-04-08 17:55:07 -05:00
|
|
|
UserId int64 `json:"userId"`
|
|
|
|
Email string `json:"email"`
|
|
|
|
Login string `json:"login"`
|
|
|
|
}
|