| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 | 
							- package app
 
- import (
 
- 	"github.com/gin-gonic/gin"
 
- 	"net/http"
 
- )
 
- //func SetApiBaseOutputHead(code int, message string) models.ApiBaseOutputHead {
 
- //	var outData ali.AliBaseResponse
 
- //	outData.Code = code
 
- //	outData.Msg = message
 
- //	return outData
 
- //}
 
- //func ClientErr(c *gin.Context, msg string) {
 
- //	var aliOut ali.AliBaseResponse
 
- //	aliOut.Code = 400
 
- //	aliOut.Msg = msg
 
- //	c.JSON(http.StatusOK, aliOut)
 
- //}
 
- //
 
- //func ServerErr(c *gin.Context, msg string) {
 
- //	var aliOut ali.AliBaseResponse
 
- //	aliOut.Code = 500
 
- //	aliOut.Msg = msg
 
- //	c.JSON(http.StatusOK, aliOut)
 
- //}
 
- // 失败数据处理
 
- func Error(c *gin.Context, code int, err error, msg string) {
 
- 	var res Response
 
- 	if err != nil {
 
- 		res.Message = err.Error()
 
- 	} else {
 
- 		if msg != "" {
 
- 			res.Message = msg
 
- 		}
 
- 	}
 
- 	c.JSON(http.StatusOK, res.ReturnError(code))
 
- }
 
- // 通常成功数据处理
 
- func OK(c *gin.Context, data interface{}, msg string) {
 
- 	var res AliResponse
 
- 	res.Data = data
 
- 	if msg != "" {
 
- 		res.Message = msg
 
- 	}
 
- 	res.Code = 200
 
- 	c.JSON(http.StatusOK, res)
 
- }
 
- // 分页数据处理
 
- func PageOK(c *gin.Context, result interface{}, count int, pageIndex int, pageSize int, msg string) {
 
- 	var res PageRes
 
- 	res.Data.List = result
 
- 	res.Data.Count = count
 
- 	res.Data.PageIndex = pageIndex
 
- 	res.Data.PageSize = pageSize
 
- 	if msg != "" {
 
- 		res.Msg = msg
 
- 	}
 
- 	res.Code = 200
 
- 	c.JSON(http.StatusOK, res)
 
- }
 
- // 兼容函数
 
- func Custum(c *gin.Context, data gin.H) {
 
- 	c.JSON(http.StatusOK, data)
 
- }
 
 
  |