sharedutils/domain/domain.go

67 lines
1.5 KiB
Go
Raw Normal View History

2023-01-24 13:46:17 +00:00
package domain
import (
"errors"
)
type SkirdaDomain struct {
2023-03-09 14:01:26 +00:00
DomainId string `json:"domainId"`
//SkirdaGames `json:"games"`
Users []SkirdaDomainUser
2023-03-09 14:01:26 +00:00
Games []string `json:"games"`
Events []string `json:"events"`
2023-02-12 16:58:53 +00:00
// skirdasession.SkirdaSessions
2023-01-24 13:46:17 +00:00
}
type SkirdaDomainUser struct {
SkirdaUserId string
Role string
}
2023-03-09 14:01:26 +00:00
//func (domain SkirdaDomain) BuildDomain(newGames []SkirdaGame, newSessions []SkirdaSession) {
// domain.AddGames(newGames)
// // domain.AddSessions(newSessions)
//}
2023-01-24 13:46:17 +00:00
type Domains []SkirdaDomain
func (domains Domains) Set(newDomains []SkirdaDomain) {
domains = append([]SkirdaDomain{}, newDomains...)
}
2023-03-09 14:01:26 +00:00
//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
//}
2023-01-24 13:46:17 +00:00
2023-02-12 16:58:53 +00:00
// func (domains Domains) GetSessions() SkirdaSessions {
// plainSessions := SkirdaSessions{}
// for _, domain := range domains {
// plainSessions = append(plainSessions, SkirdaSessions...)
// }
// return plainSessions
// }
2023-01-24 13:46:17 +00:00
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")
}