Skip to content

Commit

Permalink
refactor🎨:支持antd
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjianzhang committed Feb 6, 2022
1 parent 611cf4a commit 16be92e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
7 changes: 5 additions & 2 deletions sdk/antd_api/api.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func (e *Api) PageOK( result interface{}, total int, current int, pageSize int)
antd.PageOK(e.Context, result, total, current, pageSize)
}

func (e *Api) ListOK( result interface{}, total int, current int, pageSize int) {
antd.ListOK(e.Context, result, total, current, pageSize)
}

// Custom 兼容函数
func (e *Api) Custom( data gin.H) {
antd.Custum(e.Context, data)
Expand Down Expand Up @@ -133,5 +137,4 @@ func (e *Api) AddError(err error) {

func (e Api) Translate(form, to interface{}) {
pkg.Translate(form, to)
}

}
Empty file modified sdk/antd_api/binding.go
100644 → 100755
Empty file.
15 changes: 14 additions & 1 deletion sdk/pkg/response/antd/model.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ type pages struct {
Data interface{} `json:"data,omitempty"`
}

type lists struct {
Response
ListData ListData `json:"data,omitempty"` // response data
}


type ListData struct {
List interface{} `json:"list,omitempty"` // response data
Total int `json:"total,omitempty"`
Current int `json:"current,omitempty"`
PageSize int `json:"pageSize,omitempty"`
}

func (e *response) SetCode(code int32) {
switch code {
case 200, 0:
Expand All @@ -66,4 +79,4 @@ func (e *response) SetSuccess(success bool) {

func (e response) Clone() resp.Responses {
return &e
}
}
15 changes: 14 additions & 1 deletion sdk/pkg/response/antd/return.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,22 @@ func PageOK(c *gin.Context, result interface{}, total int, current int, pageSize
c.AbortWithStatusJSON(http.StatusOK, res)
}

func ListOK(c *gin.Context, result interface{}, total int, current int, pageSize int) {
var res lists
res.ListData.List = result
res.ListData.Total = total
res.ListData.Current = current
res.ListData.PageSize = pageSize
res.Success = true
res.TraceId = pkg.GenerateMsgIDFromContext(c)
c.Set("result", res)
c.Set("status", http.StatusOK)
c.AbortWithStatusJSON(http.StatusOK, res)
}

// Custum 兼容函数
func Custum(c *gin.Context, data gin.H) {
data["traceId"] = pkg.GenerateMsgIDFromContext(c)
c.Set("result", data)
c.AbortWithStatusJSON(http.StatusOK, data)
}
}

0 comments on commit 16be92e

Please sign in to comment.