mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-07-15 17:18:49 +02:00
fix:#75 added hash function to dbEventService
This commit is contained in:
@ -22,6 +22,7 @@ import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
"htwkalender/data-manager/model"
|
||||
"htwkalender/data-manager/service/functions"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
@ -197,7 +198,7 @@ func NewEvent(collection *core.Collection, event model.Event) (*Event, error) {
|
||||
ev.SetCompulsory(event.Compulsory)
|
||||
|
||||
if event.UUID == "" {
|
||||
event.UUID = uuid.NewString()
|
||||
event.UUID = functions.GenerateUUID(event)
|
||||
}
|
||||
ev.SetUUID(event.UUID)
|
||||
return ev, nil
|
||||
|
@ -10,8 +10,13 @@ import (
|
||||
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()
|
||||
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user