Files
ops2/backend/routers/return.go
T
kevin 0b67a9bf09 up
Signed-off-by: 吴文峰 <kevin@lmve.net>
2026-01-13 21:08:19 +08:00

35 lines
700 B
Go

package routers
import "github.com/gin-gonic/gin"
func ReturnJson(ctx *gin.Context, errMsg string, data map[string]interface{}) {
var errCode = ErrorCode[errMsg]
returnData := map[string]interface{}{}
// cookie, have_cookie := ctx.Get("cookie")
// if have_cookie {
// returnData["cookie"] = cookie
// }
returnData["err_code"] = errCode
returnData["err_msg"] = errMsg
if data != nil {
returnData["return"] = data
}
ctx.JSON(200, &returnData)
//ctx.Abort()
}
func Return_file(ctx *gin.Context, file_path string, preview bool) {
if preview {
ctx.File(file_path)
} else {
//需要从数据库拉取原始文件名
//ctx.FileAttachment(file_info.Path, file_info.Name)
}
}