Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f28a3edbcf | ||
|
|
1d203d1d2f |
@@ -21,12 +21,18 @@ func (dh *DatabaseHandler) StartNewEvent(event *models.Event) error {
|
|||||||
return dh.database.AddNewColum(&event)
|
return dh.database.AddNewColum(&event)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dh *DatabaseHandler) GetEvent(id uint) (event []models.Event, err error) {
|
func (dh *DatabaseHandler) GetEvent(id uint) (events []models.Event, err error) {
|
||||||
if !dh.DatabaseOpened() {
|
if !dh.DatabaseOpened() {
|
||||||
return event, errors.New("database not opened")
|
return events, errors.New("database not opened")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dh.database.GetById(&event, "Attendees", id)
|
err = dh.database.GetById(&events, "Attendees", id)
|
||||||
|
|
||||||
|
for i := range events {
|
||||||
|
for j := range events[i].Attendees {
|
||||||
|
events[i].Attendees[j].Decrypt(dh.token)
|
||||||
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ type Event struct {
|
|||||||
Name string `gorm:"column:name" json:"name"`
|
Name string `gorm:"column:name" json:"name"`
|
||||||
Date string `gorm:"column:date" json:"date"`
|
Date string `gorm:"column:date" json:"date"`
|
||||||
Day string `gorm:"column:day" json:"day"`
|
Day string `gorm:"column:day" json:"day"`
|
||||||
Attendees []*Member `gorm:"many2many:member_events;"`
|
Attendees []*Member `gorm:"many2many:member_events;constraint:OnDelete:CASCADE;" json:"attendees"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ type Member struct {
|
|||||||
FirstVisit string `gorm:"column:firstVisit" json:"firstVisit,omitempty"`
|
FirstVisit string `gorm:"column:firstVisit" json:"firstVisit,omitempty"`
|
||||||
LastVisit string `gorm:"column:lastVisit" json:"lastVisit,omitempty"`
|
LastVisit string `gorm:"column:lastVisit" json:"lastVisit,omitempty"`
|
||||||
GroupId *int `json:"GroupId,omitempty"`
|
GroupId *int `json:"GroupId,omitempty"`
|
||||||
Group *Group `gorm:"foreignKey:GroupId" json:"group,omitempty"`
|
Group *Group `gorm:"foreignKey:GroupId;constraint:OnDelete:CASCADE;"json:"group,omitempty"`
|
||||||
ResponsibleId *int `json:"ResponsibleId,omitempty"`
|
ResponsibleId *int `json:"ResponsibleId,omitempty"`
|
||||||
Responsible *Member `gorm:"foreignKey:ResponsibleId" json:"responsible,omitempty"`
|
Responsible *Member `gorm:"foreignKey:ResponsibleId;constraint:OnDelete:CASCADE;" json:"responsible,omitempty"`
|
||||||
Comment string `gorm:"column:comment" json:"comment,omitempty"`
|
Comment string `gorm:"column:comment" json:"comment,omitempty"`
|
||||||
Events []*Event `gorm:"many2many:member_events;" `
|
Events []*Event `gorm:"many2many:member_events;" `
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user