-
Notifications
You must be signed in to change notification settings - Fork 0
/
citys.go
41 lines (34 loc) · 962 Bytes
/
citys.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
35
36
37
38
39
40
41
package v1
import (
. "github.com/bmbstack/ripple/cmd/ripple/templates/internal/helper"
"net/http"
"github.com/labstack/echo/v4"
)
type CityController struct {
Group *echo.Group
BaseController
}
func (this CityController) Setup() {
this.Group.GET("/list", this.ActionIndex)
}
//================================================================================================
type RequestCity struct {
Pid int64 `form:"pid" json:"pid"`
}
func (this CityController) ActionIndex(ctx echo.Context) error {
params := &RequestCity{}
err := ctx.Bind(params)
if err != nil {
return ctx.JSON(http.StatusOK, ErrorJSON(ErrorMsgParamsValidateFailed, ErrorCodeParamsValidateFailed))
}
var result []map[string]interface{}
result = append(result, map[string]interface{}{
"id": 1,
"name": "北京市",
})
result = append(result, map[string]interface{}{
"id": 2,
"name": "上海市",
})
return ctx.JSON(http.StatusOK, SuccessJSON(result))
}