Files
cms-server/service/service_event/get_event_info.go
Asai Neko 1d885feb1f
All checks were successful
Client CMS Check Build (NixCN CMS) TeamCity build finished
Backend Check Build (NixCN CMS) TeamCity build finished
WIP Add join_event in service_event
Signed-off-by: Asai Neko <sugar@sne.moe>
2026-01-31 08:29:02 +08:00

72 lines
1.6 KiB
Go

package service_event
import (
"context"
"nixcn-cms/data"
"nixcn-cms/internal/exception"
"nixcn-cms/service/shared"
"github.com/google/uuid"
)
type EventInfoData struct {
EventId uuid.UUID `json:"event_id"`
}
type EventInfoPayload struct {
Context context.Context
Data *EventInfoData
}
type EventInfoResult struct {
Common shared.CommonResult
Data *data.EventIndexDoc
}
func (self *EventServiceImpl) GetEventInfo(payload *EventInfoPayload) (result *EventInfoResult) {
event, err := new(data.Event).GetEventById(payload.Context, payload.Data.EventId)
if err != nil {
exception := new(exception.Builder).
SetStatus(exception.StatusUser).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceInfo).
SetType(exception.TypeSpecific).
SetOriginal(exception.EventInfoNotFound).
SetError(err).
Throw(payload.Context)
result = &EventInfoResult{
Common: shared.CommonResult{
HttpCode: 404,
Exception: exception,
},
}
return
}
result = &EventInfoResult{
Common: shared.CommonResult{
HttpCode: 200,
Exception: new(exception.Builder).
SetStatus(exception.StatusSuccess).
SetService(exception.ServiceEvent).
SetEndpoint(exception.EndpointEventServiceInfo).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonSuccess).
Throw(payload.Context),
},
Data: &data.EventIndexDoc{
EventId: event.EventId.String(),
Name: event.Name,
Type: event.Type,
Description: event.Description,
StartTime: event.StartTime,
EndTime: event.EndTime,
Thumbnail: event.Thumbnail,
},
}
return
}