2017-03-27 07:36:28 -05:00
|
|
|
package models
|
|
|
|
|
2017-04-08 17:55:07 -05:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Typed errors
|
|
|
|
var (
|
2018-02-16 04:45:53 -06:00
|
|
|
ErrTeamNotFound = errors.New("Team not found")
|
|
|
|
ErrTeamNameTaken = errors.New("Team name is taken")
|
|
|
|
ErrTeamMemberNotFound = errors.New("Team member not found")
|
2017-04-08 17:55:07 -05:00
|
|
|
)
|
2017-03-27 07:36:28 -05:00
|
|
|
|
2017-12-08 09:25:45 -06:00
|
|
|
// Team model
|
|
|
|
type Team struct {
|
2017-04-09 18:24:16 -05:00
|
|
|
Id int64 `json:"id"`
|
|
|
|
OrgId int64 `json:"orgId"`
|
|
|
|
Name string `json:"name"`
|
2017-12-20 14:20:12 -06:00
|
|
|
Email string `json:"email"`
|
2017-03-27 07:36:28 -05:00
|
|
|
|
2017-04-09 18:24:16 -05:00
|
|
|
Created time.Time `json:"created"`
|
|
|
|
Updated time.Time `json:"updated"`
|
2017-03-27 07:36:28 -05:00
|
|
|
}
|
2017-04-08 17:55:07 -05:00
|
|
|
|
|
|
|
// ---------------------
|
|
|
|
// COMMANDS
|
|
|
|
|
2017-12-08 09:25:45 -06:00
|
|
|
type CreateTeamCommand struct {
|
2017-04-08 17:55:07 -05:00
|
|
|
Name string `json:"name" binding:"Required"`
|
2017-12-20 14:20:12 -06:00
|
|
|
Email string `json:"email"`
|
2017-04-09 18:24:16 -05:00
|
|
|
OrgId int64 `json:"-"`
|
2017-04-08 17:55:07 -05:00
|
|
|
|
2017-12-08 09:25:45 -06:00
|
|
|
Result Team `json:"-"`
|
2017-04-08 17:55:07 -05:00
|
|
|
}
|
|
|
|
|
2017-12-08 09:25:45 -06:00
|
|
|
type UpdateTeamCommand struct {
|
2017-12-20 14:20:12 -06:00
|
|
|
Id int64
|
|
|
|
Name string
|
|
|
|
Email string
|
2018-02-09 10:26:15 -06:00
|
|
|
OrgId int64 `json:"-"`
|
2017-04-18 08:01:05 -05:00
|
|
|
}
|
|
|
|
|
2017-12-08 09:25:45 -06:00
|
|
|
type DeleteTeamCommand struct {
|
2018-02-09 10:26:15 -06:00
|
|
|
OrgId int64
|
|
|
|
Id int64
|
2017-04-08 17:55:07 -05:00
|
|
|
}
|
|
|
|
|
2017-12-08 09:25:45 -06:00
|
|
|
type GetTeamByIdQuery struct {
|
2018-02-09 10:26:15 -06:00
|
|
|
OrgId int64
|
2017-04-08 17:55:07 -05:00
|
|
|
Id int64
|
2017-12-08 09:25:45 -06:00
|
|
|
Result *Team
|
2017-04-08 17:55:07 -05:00
|
|
|
}
|
|
|
|
|
2017-12-08 09:25:45 -06:00
|
|
|
type GetTeamsByUserQuery struct {
|
2018-02-09 10:26:15 -06:00
|
|
|
OrgId int64
|
2017-12-11 10:46:05 -06:00
|
|
|
UserId int64 `json:"userId"`
|
2017-12-08 09:25:45 -06:00
|
|
|
Result []*Team `json:"teams"`
|
2017-05-22 03:33:17 -05:00
|
|
|
}
|
|
|
|
|
2017-12-08 09:25:45 -06:00
|
|
|
type SearchTeamsQuery struct {
|
2017-04-08 17:55:07 -05:00
|
|
|
Query string
|
|
|
|
Name string
|
|
|
|
Limit int
|
|
|
|
Page int
|
2017-06-23 13:55:53 -05:00
|
|
|
OrgId int64
|
2017-04-08 17:55:07 -05:00
|
|
|
|
2017-12-08 09:25:45 -06:00
|
|
|
Result SearchTeamQueryResult
|
2017-04-09 18:24:16 -05:00
|
|
|
}
|
|
|
|
|
2017-12-14 10:22:45 -06:00
|
|
|
type SearchTeamDto struct {
|
|
|
|
Id int64 `json:"id"`
|
|
|
|
OrgId int64 `json:"orgId"`
|
|
|
|
Name string `json:"name"`
|
2017-12-20 14:20:12 -06:00
|
|
|
Email string `json:"email"`
|
|
|
|
AvatarUrl string `json:"avatarUrl"`
|
2017-12-14 10:22:45 -06:00
|
|
|
MemberCount int64 `json:"memberCount"`
|
|
|
|
}
|
|
|
|
|
2017-12-08 09:25:45 -06:00
|
|
|
type SearchTeamQueryResult struct {
|
2017-12-14 10:22:45 -06:00
|
|
|
TotalCount int64 `json:"totalCount"`
|
|
|
|
Teams []*SearchTeamDto `json:"teams"`
|
|
|
|
Page int `json:"page"`
|
|
|
|
PerPage int `json:"perPage"`
|
2017-04-08 17:55:07 -05:00
|
|
|
}
|