package event import ( "nixcn-cms/data" "nixcn-cms/internal/exception" "nixcn-cms/utils" "time" "github.com/gin-gonic/gin" "github.com/google/uuid" ) func Info(c *gin.Context) { eventData := new(data.Event) eventIdOrig, ok := c.GetQuery("event_id") if !ok { errorCode := new(exception.Builder). SetStatus(exception.ErrorStatusClient). SetService(exception.EventService). SetEndpoint(exception.EventInfoEndpoint). SetType(exception.ErrorTypeCommon). SetOriginal(exception.CommonErrorInvalidInput). Build() utils.HttpResponse(c, 400, errorCode) return } // Parse event id eventId, err := uuid.Parse(eventIdOrig) if err != nil { errorCode := new(exception.Builder). SetStatus(exception.ErrorStatusServer). SetService(exception.EventService). SetEndpoint(exception.EventInfoEndpoint). SetType(exception.ErrorTypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). Build() utils.HttpResponse(c, 500, errorCode) return } event, err := eventData.GetEventById(eventId) if err != nil { errorCode := new(exception.Builder). SetStatus(exception.ErrorStatusClient). SetService(exception.EventService). SetEndpoint(exception.EventInfoEndpoint). SetType(exception.ErrorTypeSpecific). SetOriginal(exception.EventInfoNotFound). Build() utils.HttpResponse(c, 404, errorCode) return } eventInfoResp := struct { Name string `json:"name"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` }{event.Name, event.StartTime, event.EndTime} utils.HttpResponse(c, 200, "", "success", eventInfoResp) }