Skip to content

Commit d2605ed

Browse files
committed
refactor🎨:代码格式化
1 parent c7222a1 commit d2605ed

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

Diff for: sdk/antd_api/api.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -28,53 +28,52 @@ type Api struct {
2828
func (e Api) GetLogger() *logger.Helper {
2929
return api.GetRequestLogger(e.Context)
3030
}
31+
3132
// GetOrm 获取Orm DB
3233
func (e *Api) GetOrm(c *gin.Context) (*gorm.DB, error) {
3334
db, err := pkg.GetOrm(c)
3435
if err != nil {
35-
e.Error( http.StatusInternalServerError, "数据库连接获取失败", "9")
36+
e.Error(http.StatusInternalServerError, "数据库连接获取失败", "9")
3637
return nil, err
3738
}
3839
return db, nil
3940
}
4041

4142
// Error 通常错误数据处理
4243
// showType error display type: 0 silent; 1 message.warn; 2 message.error; 4 notification; 9 page
43-
func (e *Api) Error( errCode int, errMsg string, showType string) {
44+
func (e *Api) Error(errCode int, errMsg string, showType string) {
4445
if showType == "" {
4546
showType = "2"
4647
}
4748
antd.Error(e.Context, strconv.Itoa(errCode), errMsg, showType)
4849
}
4950

5051
// OK 通常成功数据处理
51-
func (e *Api) OK( data interface{}) {
52+
func (e *Api) OK(data interface{}) {
5253
antd.OK(e.Context, data)
5354
}
5455

5556
// PageOK 分页数据处理
56-
func (e *Api) PageOK( result interface{}, total int, current int, pageSize int) {
57+
func (e *Api) PageOK(result interface{}, total int, current int, pageSize int) {
5758
antd.PageOK(e.Context, result, total, current, pageSize)
5859
}
5960

60-
func (e *Api) ListOK( result interface{}, total int, current int, pageSize int) {
61+
func (e *Api) ListOK(result interface{}, total int, current int, pageSize int) {
6162
antd.ListOK(e.Context, result, total, current, pageSize)
6263
}
6364

6465
// Custom 兼容函数
65-
func (e *Api) Custom( data gin.H) {
66+
func (e *Api) Custom(data gin.H) {
6667
antd.Custum(e.Context, data)
6768
}
6869

69-
7070
// MakeContext 设置http上下文
7171
func (e *Api) MakeContext(c *gin.Context) *Api {
7272
e.Context = c
7373
e.Logger = api.GetRequestLogger(c)
7474
return e
7575
}
7676

77-
7877
// Bind 参数校验
7978
func (e *Api) Bind(d interface{}, bindings ...binding.Binding) *Api {
8079
var err error
@@ -137,4 +136,4 @@ func (e *Api) AddError(err error) {
137136

138137
func (e Api) Translate(form, to interface{}) {
139138
pkg.Translate(form, to)
140-
}
139+
}

Diff for: sdk/pkg/response/antd/model.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type Response struct {
2121
ShowType string `json:"showType,omitempty"` // error display type: 0 silent; 1 message.warn; 2 message.error; 4 notification; 9 page
2222
TraceId string `json:"traceId,omitempty"` // Convenient for back-end Troubleshooting: unique request ID
2323
Host string `json:"host,omitempty"` // onvenient for backend Troubleshooting: host of current access server
24+
Status string `json:"status,omitempty"`
2425
}
2526
type response struct {
2627
Response
@@ -29,10 +30,10 @@ type response struct {
2930

3031
type Pages struct {
3132
Response
32-
Data interface{} `json:"data,omitempty"` // response data
33-
Total int `json:"total,omitempty"`
34-
Current int `json:"current,omitempty"`
35-
PageSize int `json:"pageSize,omitempty"`
33+
Data interface{} `json:"data,omitempty"` // response data
34+
Total int `json:"total,omitempty"`
35+
Current int `json:"current,omitempty"`
36+
PageSize int `json:"pageSize,omitempty"`
3637
}
3738

3839
type pages struct {
@@ -45,12 +46,11 @@ type lists struct {
4546
ListData ListData `json:"data,omitempty"` // response data
4647
}
4748

48-
4949
type ListData struct {
50-
List interface{} `json:"list,omitempty"` // response data
51-
Total int `json:"total,omitempty"`
52-
Current int `json:"current,omitempty"`
53-
PageSize int `json:"pageSize,omitempty"`
50+
List interface{} `json:"list,omitempty"` // response data
51+
Total int `json:"total,omitempty"`
52+
Current int `json:"current,omitempty"`
53+
PageSize int `json:"pageSize,omitempty"`
5454
}
5555

5656
func (e *response) SetCode(code int32) {
@@ -79,4 +79,4 @@ func (e *response) SetSuccess(success bool) {
7979

8080
func (e response) Clone() resp.Responses {
8181
return &e
82-
}
82+
}

Diff for: sdk/pkg/response/antd/return.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ func OK(c *gin.Context, data interface{}) {
2828
var res response
2929
res.Data = data
3030
res.Success = true
31+
res.Status = "done"
32+
res.TraceId = pkg.GenerateMsgIDFromContext(c)
33+
c.Set("result", res)
34+
c.Set("status", http.StatusOK)
35+
c.AbortWithStatusJSON(http.StatusOK, res)
36+
}
37+
38+
func UpFileOK(c *gin.Context, data interface{}) {
39+
var res response
40+
res.Data = data
41+
res.Success = true
42+
res.Status = "done"
3143
res.TraceId = pkg.GenerateMsgIDFromContext(c)
3244
c.Set("result", res)
3345
c.Set("status", http.StatusOK)
@@ -66,4 +78,4 @@ func Custum(c *gin.Context, data gin.H) {
6678
data["traceId"] = pkg.GenerateMsgIDFromContext(c)
6779
c.Set("result", data)
6880
c.AbortWithStatusJSON(http.StatusOK, data)
69-
}
81+
}

0 commit comments

Comments
 (0)