package event import ( "nixcn-cms/internal/exception" "nixcn-cms/service/service_event" "nixcn-cms/utils" "github.com/gin-gonic/gin" "github.com/google/uuid" ) // Info retrieves basic information about a specific event. // // @Summary Get Event Information // @Description Fetches the name, start time, and end time of an event using its UUID. // @Tags Event // @Accept json // @Produce json // @Param event_id query string true "Event UUID" // @Success 200 {object} utils.RespStatus{data=data.EventIndexDoc} "Successful retrieval" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input" // @Failure 401 {object} utils.RespStatus{data=nil} "Missing User ID / Unauthorized" // @Failure 404 {object} utils.RespStatus{data=nil} "Event Not Found" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error" // @Security ApiKeyAuth // @Router /event/info [get] func (self *EventHandler) Info(c *gin.Context) { userIdOrig, ok := c.Get("user_id") if !ok { errorCode := new(exception.Builder). SetStatus(exception.StatusUser). SetService(exception.ServiceUser). SetEndpoint(exception.EndpointUserServiceInfo). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorMissingUserId). Throw(c). String() utils.HttpResponse(c, 403, errorCode) return } userId, err := uuid.Parse(userIdOrig.(string)) if err != nil { errorCode := new(exception.Builder). SetStatus(exception.StatusServer). SetService(exception.ServiceUser). SetEndpoint(exception.EndpointUserServiceInfo). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). SetError(err). Throw(c). String() utils.HttpResponse(c, 500, errorCode) return } eventIdOrig := c.Query("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). Throw(c). String() utils.HttpResponse(c, 500, errorCode) return } result := self.svc.GetEventInfo(&service_event.EventInfoPayload{ Context: c, UserId: userId, Data: &service_event.EventInfoData{ EventId: eventId, }, }) if result.Common.Exception.Original != exception.CommonSuccess { utils.HttpResponse(c, result.Common.HttpCode, result.Common.Exception.String()) return } utils.HttpResponse(c, 200, result.Common.Exception.String(), result.Data) }