-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
34 lines (32 loc) · 1008 Bytes
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package http
import (
"github.com/axengine/ethevent/pkg/http/bean"
"github.com/labstack/echo/v4"
"net/http"
)
// eventList
// @Summary 查询事件
// @Description 查询事件
// @Tags Event
// @Accept json
// @Produce json
// @Param Request body bean.EventListRo true "request param"
// @Success 200 {array} bean.Event "success"
// @Router /v1/event/list [POST]
func (hs *HttpServer) eventList(c echo.Context) error {
var req bean.EventListRo
if err := c.Bind(&req); err != nil {
return c.JSON(http.StatusOK, new(bean.Resp).FailMsg("invalid parameter"))
}
if err := c.Validate(req); err != nil {
return c.JSON(http.StatusOK, new(bean.Resp).FailMsg(err.Error()))
}
if req.OrderRo != nil && req.PageRo == nil {
return c.JSON(http.StatusOK, new(bean.Resp).FailMsg("pageRo Required"))
}
data, err := hs.svc.EventList(c.Request().Context(), &req)
if err != nil {
return c.JSON(http.StatusOK, new(bean.Resp).FailErr(c, err))
}
return c.JSON(http.StatusOK, new(bean.Resp).Success(data))
}