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.StatusUser). SetService(exception.ServiceEvent). SetEndpoint(exception.EndpointEventServiceInfo). SetType(exception.TypeCommon). 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.StatusServer). SetService(exception.ServiceEvent). SetEndpoint(exception.EndpointEventServiceInfo). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). SetError(err). Build() utils.HttpResponse(c, 500, errorCode) return } event, err := eventData.GetEventById(eventId) if err != nil { errorCode := new(exception.Builder). SetStatus(exception.StatusUser). SetService(exception.ServiceEvent). SetEndpoint(exception.EndpointEventServiceInfo). SetType(exception.TypeSpecific). SetOriginal(exception.EventInfoNotFound). SetError(err). 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) }