sunty
2020-04-16 68ed73b2966171ef16a0b6623a9eb9c2d0968ea5
util/util.go
@@ -5,9 +5,11 @@
   "encoding/json"
   "errors"
   "fmt"
   "github.com/gin-gonic/gin"
   "io/ioutil"
   "net/http"
   "os/exec"
   "swfs/code"
   "time"
)
@@ -98,3 +100,17 @@
   total = int(middle)
   return total, nil
}
// ResponseFormat 返回数据格式化
func ResponseFormat(c *gin.Context, respStatus *code.Code, data interface{}) {
   if respStatus == nil {
      respStatus = code.RequestParamError
   }
   c.JSON(respStatus.Status, gin.H{
      "code":    respStatus.Status,
      "success": respStatus.Success,
      "msg":     respStatus.Message,
      "data":    data,
   })
   return
}