@@ -38,6 +38,7 @@ type EventUsecase interface {
3838 CreateRegistrationEvent (ctx context.Context , payload RegisterEventPayload ) (RegisterEventResponse , error )
3939 CreateEventPay (ctx context.Context , payload EventPayPayload ) error
4040 GetEventByID (ctx context.Context , id uint ) (resp EventDTO , err error )
41+ GetEventByIDAdmin (ctx context.Context , id uint ) (resp EventAdminDTO , err error )
4142 DeleteEvent (ctx context.Context , id uint ) (err error )
4243 RegistrationStatus (ctx context.Context , orderNo string ) (resp RegisterStatusResponse , err error )
4344 ListRegistration (ctx context.Context , filter EventFilter ) (resp []RegistrationEvent , pagination Pagination , err error )
@@ -121,7 +122,6 @@ type CreateEventPayload struct {
121122 Author string `json:"author" validate:"required"`
122123 FileName string `json:"file_name" validate:"required"`
123124 Slug string `json:"slug" validate:"required"`
124- IsOnline string `json:"is_online" validate:"required"`
125125 Date null.Time `json:"date" validate:"required"`
126126 Type constants.EventType `json:"type" validate:"required"`
127127 Location string `json:"location" validate:"required"`
@@ -135,7 +135,7 @@ type CreateEventPayload struct {
135135 ReservationStartDate null.Time `json:"reservation_start_date"`
136136 ReservationEndDate null.Time `json:"reservation_end_date"`
137137 AdditionalLink string `json:"additional_link"`
138- SessionType string `json:"session_type"`
138+ SessionType string `json:"session_type" validate:"required" `
139139}
140140
141141type UpdateEventPayload struct {
@@ -144,7 +144,6 @@ type UpdateEventPayload struct {
144144 Author string `json:"author" validate:"required"`
145145 FileName string `json:"file_name" validate:"required"`
146146 Slug string `json:"slug" validate:"required"`
147- IsOnline string `json:"is_online" validate:"required"`
148147 Date null.Time `json:"date" validate:"required"`
149148 Type constants.EventType `json:"type" validate:"required"`
150149 Location string `json:"location" validate:"required"`
@@ -158,7 +157,7 @@ type UpdateEventPayload struct {
158157 ReservationStartDate null.Time `json:"reservation_start_date"`
159158 ReservationEndDate null.Time `json:"reseveration_end_date"`
160159 AdditionalLink string `json:"additional_link"`
161- SessionType string `json:"session_type"`
160+ SessionType string `json:"session_type" validate:"required" `
162161}
163162
164163type EventDTO struct {
@@ -178,6 +177,29 @@ type EventDTO struct {
178177 Status string `json:"status"`
179178}
180179
180+ type EventAdminDTO struct {
181+ ID int `json:"id"`
182+ Title string `json:"title"`
183+ Description string `json:"description"`
184+ Author string `json:"author"`
185+ FileName string `json:"file_name"`
186+ Slug string `json:"slug"`
187+ Date null.Time `json:"date"`
188+ Type constants.EventType `json:"type"`
189+ Location string `json:"location"`
190+ Duration string `json:"duration"`
191+ Status string `json:"status"`
192+ Capacity int `json:"capacity"`
193+ Price float64 `json:"price"`
194+ RegistrationLink string `json:"registration_link"`
195+ Tags []string `json:"tags"`
196+ Speakers []string `json:"speakers"`
197+ ReservationStartDate null.Time `json:"reservation_start_date"`
198+ ReservationEndDate null.Time `json:"reservation_end_date"`
199+ // AdditionalLink string `json:"additional_link"`
200+ SessionType string `json:"session_type"`
201+ }
202+
181203type UpdateEvenPayload struct {
182204 Title string `json:"title"`
183205 Description string `json:"description"`
@@ -294,3 +316,40 @@ func (e Event) ToDTO() EventDTO {
294316 SessionType : e .SessionType ,
295317 }
296318}
319+
320+ func (e Event ) ToAdminDTO () EventAdminDTO {
321+ id := int (e .ID )
322+
323+ tags := make ([]string , len (e .Tags ))
324+ for i , tag := range e .Tags {
325+ tags [i ] = tag .Tag
326+ }
327+
328+ speakers := make ([]string , len (e .Speakers ))
329+ for i , speaker := range e .Speakers {
330+ speakers [i ] = speaker .Name
331+ }
332+
333+ return EventAdminDTO {
334+ ID : id ,
335+ Title : e .Title ,
336+ Description : e .Description ,
337+ Author : e .Author .Username ,
338+ FileName : e .Image ,
339+ Slug : e .Slug ,
340+ Date : e .Date ,
341+ Type : e .Type ,
342+ Location : e .Location ,
343+ Duration : e .Duration ,
344+ Status : e .Status ,
345+ Capacity : e .Capacity ,
346+ Price : e .Price ,
347+ RegistrationLink : e .RegistrationLink ,
348+ Tags : tags ,
349+ Speakers : speakers ,
350+ ReservationStartDate : e .ReservationStartDate ,
351+ ReservationEndDate : e .ReservationEndDate ,
352+ // AdditionalLink: e.AdditionalLink,
353+ SessionType : e .SessionType ,
354+ }
355+ }
0 commit comments