serverctl/services/entry/pkg/application/projects/model.go

49 lines
862 B
Go
Raw Normal View History

2022-02-14 01:25:36 +01:00
package projects
2022-02-14 22:19:44 +01:00
type ProjectMember struct {
MemberId int
Role string
}
2022-02-14 01:25:36 +01:00
type Project struct {
2022-02-14 22:19:44 +01:00
Id int
Name string
Members []ProjectMember
2022-02-14 01:25:36 +01:00
}
2022-02-14 22:19:44 +01:00
func NewProject(id int, name string, member *ProjectMember) *Project {
members := make([]ProjectMember, 0)
members = append(members, *member)
2022-02-14 01:25:36 +01:00
return &Project{
2022-02-14 22:19:44 +01:00
Id: id,
Name: name,
Members: members,
}
}
func NewProjectMember(memberId int, role string) *ProjectMember {
return &ProjectMember{
MemberId: memberId,
Role: role,
2022-02-14 01:25:36 +01:00
}
}
2022-02-14 22:19:44 +01:00
func (p Project) AddMember(member *ProjectMember) {
p.Members = append(p.Members, *member)
}
2022-02-14 01:25:36 +01:00
type CreateProject struct {
Name string
MemberIds []int
AdminIds []int
}
func NewCreateProject(name string, userId int) *CreateProject {
return &CreateProject{
Name: name,
MemberIds: []int{userId},
AdminIds: []int{userId},
}
}