Skip to content

Commit 0463b06

Browse files
authored
feat(docs): add swagger generator (#7)
1 parent 70a08f3 commit 0463b06

22 files changed

Lines changed: 3622 additions & 17 deletions

app/events/delivery/http/create_event.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ import (
1010
"github.com/sirupsen/logrus"
1111
)
1212

13+
// CreateEvent
14+
// @Summary Create Event
15+
// @Description This endpoint create event
16+
// @Tags Event
17+
// @Accept json
18+
// @Produce json
19+
// @Param request body domain.CreateEventPayload true "Body"
20+
// @Failure 400 {object} domain.HttpResponse
21+
// @Failure 500 {object} domain.HttpResponse
22+
// @Success 200 {object} domain.HttpResponse
23+
// @Router /api/events [post]
1324
func (h Handler) CreateEvent(w http.ResponseWriter, r *http.Request) {
1425
bodyBytes, err := io.ReadAll(r.Body)
1526
if err != nil {
@@ -21,7 +32,7 @@ func (h Handler) CreateEvent(w http.ResponseWriter, r *http.Request) {
2132
return
2233
}
2334

24-
var payload domain.CreateEvenPayload
35+
var payload domain.CreateEventPayload
2536
if err := json.Unmarshal(bodyBytes, &payload); err != nil {
2637
logrus.Error("failed to unmarshal : ", err)
2738
utils.Response(domain.HttpResponse{

app/events/delivery/http/get_event_by_id.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ import (
1010
"github.com/sirupsen/logrus"
1111
)
1212

13+
// GetEventByID
14+
// @Summary Get Detail Event by ID
15+
// @Description This endpoint use to get event by id
16+
// @Tags Event
17+
// @Accept json
18+
// @Produce json
19+
// @Param id path string true "id"
20+
// @Failure 400 {object} domain.HttpResponse
21+
// @Failure 500 {object} domain.HttpResponse
22+
// @Success 200 {object} domain.Event
23+
// @Router /api/events/:id [get]
1324
func (h Handler) GetEventByID(w http.ResponseWriter, r *http.Request) {
1425
vars := mux.Vars(r)
1526
idString := vars["id"]
@@ -25,7 +36,6 @@ func (h Handler) GetEventByID(w http.ResponseWriter, r *http.Request) {
2536
}
2637

2738
data, err := h.usecase.GetEventByID(r.Context(), uint(value))
28-
2939
if err != nil {
3040
logrus.Error("failed to get event : ", err)
3141
utils.Response(domain.HttpResponse{

app/events/delivery/http/list_event.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ import (
88
"github.com/sirupsen/logrus"
99
)
1010

11+
// GetEvents
12+
// @Summary Get Events
13+
// @Description This endpoint use to get events by filter
14+
// @Tags Event
15+
// @Accept json
16+
// @Produce json
17+
// @Param limit query string true "string"
18+
// @Param page query string true "string"
19+
// @Param orderBy query string false "string"
20+
// @Param start_date query string false "string"
21+
// @Param end_date query string false "string"
22+
// @Param title query string false "string"
23+
// @Param type query string false "string"
24+
// @Param status query string false "string"
25+
// @Failure 400 {object} domain.HttpResponse
26+
// @Failure 500 {object} domain.HttpResponse
27+
// @Success 200 {object} []domain.Event
28+
// @Router /api/events [get]
1129
func (h Handler) GetEvents(w http.ResponseWriter, r *http.Request) {
1230
flterPagination, err := domain.GetPaginationFromCtx(r)
1331
if err != nil {

app/events/delivery/http/list_event_pay.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ import (
99
"github.com/sirupsen/logrus"
1010
)
1111

12+
// ListEventPay
13+
// @Summary Get List event pay
14+
// @Description This endpoint use to get list of event pay
15+
// @Tags Event
16+
// @Accept json
17+
// @Produce json
18+
// @Param limit query string true "string"
19+
// @Param page query string true "string"
20+
// @Param event_id query string false "string"
21+
// @Param start_date query string false "string"
22+
// @Param end_date query string false "string"
23+
// @Param status query string false "string"
24+
// @Failure 400 {object} domain.HttpResponse
25+
// @Failure 500 {object} domain.HttpResponse
26+
// @Success 200 {object} []domain.EventPay
27+
// @Router /api/events/pays [get]
1228
func (h Handler) ListEventPay(w http.ResponseWriter, r *http.Request) {
1329
flterPagination, err := domain.GetPaginationFromCtx(r)
1430
if err != nil {
@@ -22,7 +38,6 @@ func (h Handler) ListEventPay(w http.ResponseWriter, r *http.Request) {
2238

2339
startDate, _ := utils.ParseDate(r.URL.Query().Get("start_date"))
2440
endDate, _ := utils.ParseDate(r.URL.Query().Get("end_date"))
25-
2641
eventIDs := r.URL.Query().Get("event_id")
2742

2843
var eventID uint
@@ -47,7 +62,6 @@ func (h Handler) ListEventPay(w http.ResponseWriter, r *http.Request) {
4762
EndDate: endDate,
4863
FilterPagination: flterPagination,
4964
})
50-
5165
if err != nil {
5266
logrus.Error("failed to list event : ", err)
5367
utils.Response(domain.HttpResponse{

app/events/delivery/http/list_registration.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ import (
88
"github.com/sirupsen/logrus"
99
)
1010

11+
// ListRegistration
12+
// @Summary Get List Register user to event
13+
// @Description This endpoint use to get list of user that register on event
14+
// @Tags Event
15+
// @Accept json
16+
// @Produce json
17+
// @Param limit query string true "string"
18+
// @Param page query string true "string"
19+
// @Param event_id query string false "string"
20+
// @Param start_date query string false "string"
21+
// @Param end_date query string false "string"
22+
// @Param status query string false "string"
23+
// @Failure 400 {object} domain.HttpResponse
24+
// @Failure 500 {object} domain.HttpResponse
25+
// @Success 200 {object} []domain.RegistrationEvent
26+
// @Router /api/events/registrations [get]
1127
func (h Handler) ListRegistration(w http.ResponseWriter, r *http.Request) {
1228
flterPagination, err := domain.GetPaginationFromCtx(r)
1329
if err != nil {

app/events/delivery/http/pay_event.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ import (
1010
"github.com/sirupsen/logrus"
1111
)
1212

13+
// PayEvent
14+
// @Summary Pay Event
15+
// @Description This endpoint pay the event
16+
// @Tags Event
17+
// @Accept json
18+
// @Produce json
19+
// @Param request body domain.EventPayPayload true "Body"
20+
// @Failure 400 {object} domain.HttpResponse
21+
// @Failure 500 {object} domain.HttpResponse
22+
// @Success 200 {object} domain.HttpResponse
23+
// @Router /api/events/pay [post]
1324
func (h Handler) PayEvent(w http.ResponseWriter, r *http.Request) {
1425
bodyBytes, err := io.ReadAll(r.Body)
1526
if err != nil {

app/events/delivery/http/pay_process.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ import (
1010
"github.com/sirupsen/logrus"
1111
)
1212

13+
// PayProcess
14+
// @Summary Pay Process
15+
// @Description This endpoint use to confirm payment
16+
// @Tags Event
17+
// @Accept json
18+
// @Produce json
19+
// @Param request body domain.PayProcessPayload true "Body"
20+
// @Failure 400 {object} domain.HttpResponse
21+
// @Failure 500 {object} domain.HttpResponse
22+
// @Success 200 {object} domain.HttpResponse
23+
// @Router /api/events/pays [post]
1324
func (h Handler) PayProcess(w http.ResponseWriter, r *http.Request) {
1425
bodyBytes, err := io.ReadAll(r.Body)
1526
if err != nil {

app/events/delivery/http/register_event.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ import (
1010
"github.com/sirupsen/logrus"
1111
)
1212

13+
// RegisterEvent
14+
// @Summary Register Event
15+
// @Description This endpoint use to register event
16+
// @Tags Event
17+
// @Accept json
18+
// @Produce json
19+
// @Param request body domain.RegisterEventPayload true "Body"
20+
// @Failure 400 {object} domain.HttpResponse
21+
// @Failure 500 {object} domain.HttpResponse
22+
// @Success 200 {object} domain.HttpResponse
23+
// @Router /api/events/registrations [post]
1324
func (h Handler) RegisterEvent(w http.ResponseWriter, r *http.Request) {
1425
bodyBytes, err := io.ReadAll(r.Body)
1526
if err != nil {

app/events/delivery/http/registration_status.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ import (
99
"github.com/sirupsen/logrus"
1010
)
1111

12+
// RegistrationStatus
13+
// @Summary Register Status
14+
// @Description This endpoint use to check registration status
15+
// @Tags Event
16+
// @Accept json
17+
// @Produce json
18+
// @Param order_no path string true "ABCXX"
19+
// @Failure 400 {object} domain.HttpResponse
20+
// @Failure 500 {object} domain.HttpResponse
21+
// @Success 200 {object} domain.RegisterStatusResponse
22+
// @Router /api/events/registartions/:order_no [get]
1223
func (h Handler) RegistrationStatus(w http.ResponseWriter, r *http.Request) {
1324
vars := mux.Vars(r)
1425
order_no := vars["order_no"]

app/events/usecase/create_event.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/sirupsen/logrus"
99
)
1010

11-
func (uc usecase) CreateEvent(ctx context.Context, payload domain.CreateEvenPayload) error {
11+
func (uc usecase) CreateEvent(ctx context.Context, payload domain.CreateEventPayload) error {
1212
dataImage, err := uc.imageRepository.GetImage(ctx, payload.FileName)
1313
if err != nil {
1414
logrus.Error("failed to create event", dataImage)

0 commit comments

Comments
 (0)