forked from nixcn/nixcn-cms
44 lines
730 B
Go
44 lines
730 B
Go
package event
|
|
|
|
import (
|
|
"nixcn-cms/data"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func Info(c *gin.Context) {
|
|
event := new(data.Event)
|
|
eventIdOrig, ok := c.GetQuery("event_id")
|
|
if !ok {
|
|
c.JSON(400, gin.H{
|
|
"status": "undefinded event id",
|
|
})
|
|
return
|
|
}
|
|
|
|
// Parse event id
|
|
eventId, err := uuid.Parse(eventIdOrig)
|
|
if err != nil {
|
|
c.JSON(500, gin.H{
|
|
"status": "error parsing string to uuid",
|
|
})
|
|
return
|
|
}
|
|
|
|
err = event.GetEventById(eventId)
|
|
if err != nil {
|
|
c.JSON(404, gin.H{
|
|
"status": "event id not found",
|
|
})
|
|
return
|
|
}
|
|
|
|
c.JSON(200, gin.H{
|
|
"name": event.Name,
|
|
"start_time": event.StartTime,
|
|
"end_time": event.EndTime,
|
|
"joined_users": event.JoinedUsers,
|
|
})
|
|
}
|