sharedutils/domain/domain.go
2023-03-11 20:24:24 +03:00

65 lines
1.6 KiB
Go

package domain
import (
"errors"
)
type SkirdaDomain struct {
DomainId string `json:"domainId"`
Users []SkirdaDomainUser `json:"users"`
Games []string `json:"games"`
Events []string `json:"events"`
}
type SkirdaDomainUser struct {
SkirdaUserId string `json:"skirdauserid"`
RolesId []string `json:"rolesid"`
}
//func (domain SkirdaDomain) BuildDomain(newGames []SkirdaGame, newSessions []SkirdaSession) {
// domain.AddGames(newGames)
// // domain.AddSessions(newSessions)
//}
type Domains []SkirdaDomain
func (domains Domains) Set(newDomains []SkirdaDomain) {
domains = append([]SkirdaDomain{}, newDomains...)
}
//func (domains Domains) FindGameByID(gameId string) (SkirdaGame, error) {
// for _, domain := range domains {
// game, _ := domain.FindGameByID(gameId)
// if game.GetSkirdaGameId() == gameId {
// return game, nil
// }
// }
//
// return nil, errors.New("")
//}
//func (domains Domains) GetGames() SkirdaGames {
// allGames := SkirdaGames{}
// for _, domain := range domains {
// allGames = append(allGames, domain.SkirdaGames...)
// }
// return allGames
//}
// func (domains Domains) GetSessions() SkirdaSessions {
// plainSessions := SkirdaSessions{}
// for _, domain := range domains {
// plainSessions = append(plainSessions, SkirdaSessions...)
// }
// return plainSessions
// }
func (domains Domains) FindDomain(domainId string) (SkirdaDomain, error) {
for _, domain := range domains {
if domain.DomainId == domainId {
return domain, nil
}
}
return SkirdaDomain{}, errors.New("not any domain founded")
}