新的应用平台采用国密SM4算法进行加解密
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

package formatoutput
import (
"appNewPlatform/generalmethod"
"fmt"
"net/http"
"github.com/gin-gonic/gin"
)
// 格式化输出
func Result(code int, data interface{}, c *gin.Context, msgAry ...string) {
var msg string
if _, isTrue := ErrorCodeMsg[code]; isTrue {
msg = ErrorCodeMsg[code]
}
if len(msgAry) > 0 {
for _, v := range msgAry {
if msg == "" {
msg = fmt.Sprintf("%v", v)
} else {
msg = fmt.Sprintf("%v。%v", msg, v)
}
}
}
c.JSON(http.StatusOK, Reply{code, msg, data}) //输出json格式数据
}
// 格式化输出
func ResultInterface(data interface{}, c *gin.Context) {
c.JSON(http.StatusOK, data) //输出json格式数据
}
//列表输出标准格式
/*
@total 总数
@count 当前页总数
@page 页数
@pageSize 每页显示数量
@data 返回数据
*/
func ResultList(code, page, pageSize int, total, count int64, data interface{}, c *gin.Context) (printMap map[string]interface{}) {
outMap := generalmethod.MapOut[string]()
outMap["count"] = count
outMap["total"] = total
outMap["page"] = page
outMap["pagesize"] = pageSize
outMap["list"] = data
printMap = outMap
Result(code, outMap, c)
return
}