mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-07-16 09:38:49 +02:00
18 lines
528 B
Go
18 lines
528 B
Go
package functions
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
"htwkalender/data-manager/model"
|
|
)
|
|
|
|
// generateUUIDs generates a UUID for each event based on the event name, course and semester
|
|
// the UUID is used to identify the event in the database
|
|
func GenerateUUIDs(events []model.Event) []model.Event {
|
|
for i, event := range events {
|
|
// generate a hash value from the event name, course and semester
|
|
hash := uuid.NewSHA1(uuid.NameSpaceOID, []byte(event.Name+event.Course))
|
|
events[i].UUID = hash.String()
|
|
}
|
|
return events
|
|
}
|