Add agenda service and submit api
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
@@ -110,3 +110,33 @@ func (self *Event) FastListEvents(ctx context.Context, limit, offset int64) (*[]
|
||||
|
||||
return &results, nil
|
||||
}
|
||||
|
||||
func (self *Event) GetEventsByUserId(ctx context.Context, userId uuid.UUID, limit, offset int64) (*[]EventIndexDoc, error) {
|
||||
var results []EventIndexDoc
|
||||
|
||||
err := Database.WithContext(ctx).
|
||||
Table("events").
|
||||
Select(`
|
||||
events.event_id,
|
||||
events.name,
|
||||
events.type,
|
||||
events.description,
|
||||
events.start_time,
|
||||
events.end_time,
|
||||
events.thumbnail,
|
||||
events.enable_kyc,
|
||||
(SELECT COUNT(*) FROM attendances WHERE attendances.event_id = events.event_id) as join_count
|
||||
`).
|
||||
Joins("JOIN attendances ON attendances.event_id = events.event_id").
|
||||
Where("attendances.user_id = ?", userId).
|
||||
Order("events.start_time DESC").
|
||||
Limit(int(limit)).
|
||||
Offset(int(offset)).
|
||||
Scan(&results).Error
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &results, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user