Skip to content

Commit f2c0474

Browse files
committed
add: add new session_type payload for create,update
1 parent 5f37b0e commit f2c0474

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

app/events/usecase/update_event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func (uc usecase) UpdateEvent(ctx context.Context, id uint, payload domain.Updat
3636
Price: payload.Price,
3737
ReservationStartDate: payload.ReservationStartDate,
3838
ReservationEndDate: payload.ReservationEndDate,
39+
SessionType: payload.SessionType,
3940
UpdatedAt: null.TimeFrom(time.Now()),
4041
})
4142
if err != nil {

cmd/serve_http.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ func registerHandler(app app.App) *mux.Router {
191191

192192
// Admin Route
193193
protectedV1AdminRoute.HandleFunc("/events", app.EventHandler.GetEvents).Methods(http.MethodGet)
194-
protectedV1AdminRoute.HandleFunc("/events", app.EventHandler.CreateEvent).Methods(http.MethodPost)
194+
protectedV1AdminRoute.HandleFunc("/events/{id}", app.EventHandler.UpdateEvent).Methods(http.MethodPut)
195195
protectedV1AdminRoute.HandleFunc("/events/{id}", app.EventHandler.DeleteEvent).Methods(http.MethodDelete)
196+
protectedV1AdminRoute.HandleFunc("/events", app.EventHandler.CreateEvent).Methods(http.MethodPost)
196197
protectedV1AdminRoute.HandleFunc("/events/{id}", app.EventHandler.GetDetail).Methods(http.MethodGet)
197198
protectedV1AdminRoute.HandleFunc("/users", app.UserHandler.GetUsers).Methods(http.MethodGet)
198199

domain/event.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type EventHandler interface {
5858
ListRegistration(w http.ResponseWriter, r *http.Request)
5959
ListEventPay(w http.ResponseWriter, r *http.Request)
6060
PayProcess(w http.ResponseWriter, r *http.Request)
61+
UpdateEvent(w http.ResponseWriter, r *http.Request)
6162
}
6263

6364
type Event struct {
@@ -87,6 +88,7 @@ type Event struct {
8788
UpdatedAt null.Time `json:"-"`
8889
DeletedAt null.Time `json:"-"`
8990
AdditionalLink string `json:"additional_link"`
91+
SessionType string `json:"session_type"`
9092
}
9193

9294
func (Event) TableName() string {
@@ -133,6 +135,7 @@ type CreateEventPayload struct {
133135
ReservationStartDate null.Time `json:"reservation_start_date"`
134136
ReservationEndDate null.Time `json:"reservation_end_date"`
135137
AdditionalLink string `json:"additional_link"`
138+
SessionType string `json:"session_type"`
136139
}
137140

138141
type UpdateEventPayload struct {
@@ -155,6 +158,7 @@ type UpdateEventPayload struct {
155158
ReservationStartDate null.Time `json:"reservation_start_date"`
156159
ReservationEndDate null.Time `json:"reseveration_end_date"`
157160
AdditionalLink string `json:"additional_link"`
161+
SessionType string `json:"session_type"`
158162
}
159163

160164
type EventDTO struct {
@@ -169,6 +173,7 @@ type EventDTO struct {
169173
Duration string `json:"duration"`
170174
Capacity int `json:"capacity"`
171175
RegistrationLink string `json:"registration_link"`
176+
SessionType string `json:"session_type"`
172177
}
173178

174179
type UpdateEvenPayload struct {
@@ -282,5 +287,6 @@ func (e Event) ToDTO() EventDTO {
282287
Duration: e.Duration,
283288
Capacity: e.Capacity,
284289
RegistrationLink: e.RegistrationLink,
290+
SessionType: e.SessionType,
285291
}
286292
}

0 commit comments

Comments
 (0)