Add attendance_list in service_event, add set user permission in user
update Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
@@ -112,23 +112,6 @@ func (self *Attendance) GetEventsByUserID(ctx context.Context, userID uuid.UUID)
|
||||
return &result, err
|
||||
}
|
||||
|
||||
func (self *Attendance) GetAttendanceByEventIdAndUserId(ctx context.Context, eventId, userId uuid.UUID) (*Attendance, error) {
|
||||
var attendance Attendance
|
||||
|
||||
err := Database.WithContext(ctx).
|
||||
Where("event_id = ? AND user_id = ?", eventId, userId).
|
||||
First(&attendance).Error
|
||||
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &attendance, nil
|
||||
}
|
||||
|
||||
func (self *Attendance) Create(ctx context.Context) error {
|
||||
self.UUID = uuid.New()
|
||||
self.AttendanceId = uuid.New()
|
||||
@@ -147,6 +130,17 @@ func (self *Attendance) Create(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *Attendance) GetAttendanceListByEventId(ctx context.Context, eventId uuid.UUID) (*[]Attendance, error) {
|
||||
var result []Attendance
|
||||
|
||||
err := Database.WithContext(ctx).
|
||||
Where("event_id = ?", eventId).
|
||||
Order("checkin_at DESC").
|
||||
Find(&result).Error
|
||||
|
||||
return &result, err
|
||||
}
|
||||
|
||||
func (self *Attendance) Update(ctx context.Context, attendanceId uuid.UUID) (*Attendance, error) {
|
||||
var attendance Attendance
|
||||
|
||||
|
||||
Reference in New Issue
Block a user