Files
cms-server/service/service_event/info.go
Asai Neko 654b196bfd
Some checks failed
Backend Check Build (NixCN CMS) TeamCity build failed
Client CMS Check Build (NixCN CMS) TeamCity build finished
Fix swagger data struct error
Signed-off-by: Asai Neko <sugar@sne.moe>
2026-01-29 01:25:12 +08:00

75 lines
1.6 KiB
Go

package service_event
import (
"context"
"nixcn-cms/data"
"nixcn-cms/internal/exception"
"nixcn-cms/service/shared"
"time"
"github.com/google/uuid"
)
type InfoData struct {
EventId uuid.UUID `json:"event_id"`
}
type InfoPayload struct {
Context context.Context
Data *InfoData
}
type InfoResponse struct {
Name string `json:"name"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
}
type InfoResult struct {
Common shared.CommonResult
Data *InfoResponse
}
func (self *EventServiceImpl) Info(payload *InfoPayload) (result *InfoResult) {
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 = &InfoResult{
Common: shared.CommonResult{
HttpCode: 404,
Exception: exception,
},
}
return
}
result = &InfoResult{
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: &InfoResponse{
Name: event.Name,
StartTime: event.StartTime,
EndTime: event.EndTime,
},
}
return
}