mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-07-16 01:28:48 +02:00
23 lines
619 B
Go
23 lines
619 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 := GenerateUUID(event)
|
|
events[i].UUID = hash
|
|
}
|
|
return events
|
|
}
|
|
|
|
func GenerateUUID(event model.Event) string {
|
|
hash := uuid.NewSHA1(uuid.NameSpaceOID, []byte(event.Name+event.Course)).String()
|
|
return hash
|
|
}
|