44 lines
1.4 KiB
Go
Executable File
44 lines
1.4 KiB
Go
Executable File
package participanthandler
|
|
|
|
import "log"
|
|
|
|
func (c *ParticipantHandler) GetAllParticipants() []*CheckIfParticipantIsValidReturn {
|
|
// Erstellen einer Anfrage zur Überprüfung der Teilnehmergültigkeit
|
|
req := CheckIfParticipantIsValidRequest{Type: "baseDlRequest", UUID: "UUID"}
|
|
|
|
// Senden der Anfrage über das ParticipantManagement
|
|
c.ParticipantManagement.WriteJSON(req)
|
|
|
|
var res CheckIfParticipantIsValidResponse
|
|
for {
|
|
// Lesen der Antwort vom ParticipantManagement
|
|
err := c.ParticipantManagement.ReadJSON(&res)
|
|
if err != nil {
|
|
log.Fatal("CheckIfParticipantIsValidRequest - Error getting participant data:", err)
|
|
}
|
|
|
|
// Überprüfen, ob die Antwort den erwarteten Typ hat
|
|
if res.Type == "participantBaseData" {
|
|
break
|
|
}
|
|
}
|
|
|
|
var participantData []*CheckIfParticipantIsValidReturn
|
|
// Durchlaufen der Teilnehmerdaten, um den passenden Teilnehmer zu finden
|
|
for _, participant := range res.Data {
|
|
if participant.PartyID == 2 || participant.PartyID == 3 || participant.PartyID == 4 {
|
|
if participant.EquipmentNumber != 0 {
|
|
participantData = append(participantData, &CheckIfParticipantIsValidReturn{
|
|
TacticalIdentifier: participant.TacticalIdentifier,
|
|
Designator: participant.Designator,
|
|
EquipmentNumber: participant.EquipmentNumber,
|
|
Valid: true,
|
|
PartyId: participant.PartyID,
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
return participantData
|
|
}
|