Skip to content

Commit cfec9a8

Browse files
author
lidehua
committed
优化代码
1 parent 645ec77 commit cfec9a8

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

api/syn.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,19 @@ package api
33
import (
44
"github.com/gin-gonic/gin"
55
"my/models"
6-
"net/http"
6+
"my/result"
77
)
88

99
func Syn(c *gin.Context) {
1010
err := models.BookMysqlToEs()
1111
error := models.SectionMysqlToEs()
1212
if err != nil {
13-
c.JSON(http.StatusOK, gin.H{
14-
"code": "500",
15-
"msg": err,
16-
})
13+
result.Fail(c, err.Error())
1714
return
1815
}
1916
if error != nil {
20-
c.JSON(http.StatusOK, gin.H{
21-
"code": "500",
22-
"msg": error,
23-
})
17+
result.Fail(c, error.Error())
2418
return
2519
}
26-
c.JSON(http.StatusOK, gin.H{
27-
"code": "200",
28-
"msg": "操作成功",
29-
})
20+
result.Success(c, "操作成功")
3021
}

0 commit comments

Comments
 (0)