135 lines
2.7 KiB
Go
135 lines
2.7 KiB
Go
package domain
|
|
|
|
import "math"
|
|
|
|
type OpponentsDefeated struct {
|
|
rankAtt int
|
|
scoreAtt int
|
|
rankDef int
|
|
scoreDef int
|
|
rankSup int
|
|
scoreSup int
|
|
rankTotal int
|
|
scoreTotal int
|
|
}
|
|
|
|
const opponentsDefeatedModelName = "OpponentsDefeated"
|
|
|
|
func NewOpponentsDefeated(
|
|
rankAtt int,
|
|
scoreAtt int,
|
|
rankDef int,
|
|
scoreDef int,
|
|
rankSup int,
|
|
scoreSup int,
|
|
rankTotal int,
|
|
scoreTotal int,
|
|
) (OpponentsDefeated, error) {
|
|
if err := validateIntInRange(rankAtt, 0, math.MaxInt); err != nil {
|
|
return OpponentsDefeated{}, ValidationError{
|
|
Model: opponentsDefeatedModelName,
|
|
Field: "rankAtt",
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
if err := validateIntInRange(scoreAtt, 0, math.MaxInt); err != nil {
|
|
return OpponentsDefeated{}, ValidationError{
|
|
Model: opponentsDefeatedModelName,
|
|
Field: "scoreAtt",
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
if err := validateIntInRange(rankDef, 0, math.MaxInt); err != nil {
|
|
return OpponentsDefeated{}, ValidationError{
|
|
Model: opponentsDefeatedModelName,
|
|
Field: "rankDef",
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
if err := validateIntInRange(scoreDef, 0, math.MaxInt); err != nil {
|
|
return OpponentsDefeated{}, ValidationError{
|
|
Model: opponentsDefeatedModelName,
|
|
Field: "scoreDef",
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
if err := validateIntInRange(rankSup, 0, math.MaxInt); err != nil {
|
|
return OpponentsDefeated{}, ValidationError{
|
|
Model: opponentsDefeatedModelName,
|
|
Field: "rankSup",
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
if err := validateIntInRange(scoreSup, 0, math.MaxInt); err != nil {
|
|
return OpponentsDefeated{}, ValidationError{
|
|
Model: opponentsDefeatedModelName,
|
|
Field: "scoreSup",
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
if err := validateIntInRange(rankTotal, 0, math.MaxInt); err != nil {
|
|
return OpponentsDefeated{}, ValidationError{
|
|
Model: opponentsDefeatedModelName,
|
|
Field: "rankTotal",
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
if err := validateIntInRange(scoreTotal, 0, math.MaxInt); err != nil {
|
|
return OpponentsDefeated{}, ValidationError{
|
|
Model: opponentsDefeatedModelName,
|
|
Field: "scoreTotal",
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
return OpponentsDefeated{
|
|
rankAtt: rankAtt,
|
|
scoreAtt: scoreAtt,
|
|
rankDef: rankDef,
|
|
scoreDef: scoreDef,
|
|
rankSup: rankSup,
|
|
scoreSup: scoreSup,
|
|
rankTotal: rankTotal,
|
|
scoreTotal: scoreTotal,
|
|
}, nil
|
|
}
|
|
|
|
func (o OpponentsDefeated) RankAtt() int {
|
|
return o.rankAtt
|
|
}
|
|
|
|
func (o OpponentsDefeated) ScoreAtt() int {
|
|
return o.scoreAtt
|
|
}
|
|
|
|
func (o OpponentsDefeated) RankDef() int {
|
|
return o.rankDef
|
|
}
|
|
|
|
func (o OpponentsDefeated) ScoreDef() int {
|
|
return o.scoreDef
|
|
}
|
|
|
|
func (o OpponentsDefeated) RankSup() int {
|
|
return o.rankSup
|
|
}
|
|
|
|
func (o OpponentsDefeated) ScoreSup() int {
|
|
return o.scoreSup
|
|
}
|
|
|
|
func (o OpponentsDefeated) RankTotal() int {
|
|
return o.rankTotal
|
|
}
|
|
|
|
func (o OpponentsDefeated) ScoreTotal() int {
|
|
return o.scoreTotal
|
|
}
|