2026-07-22 01:19:46 +08:00
|
|
|
package ginx
|
2026-07-22 01:17:07 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"code.yun.ink/pkg/responsex"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Error(ctx *gin.Context, err error, ops ...responsex.Option) {
|
|
|
|
|
responsex.Error(ctx, ctx.Writer, err, ops...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ErrorWithData(ctx *gin.Context, err error, data any, ops ...responsex.Option) {
|
|
|
|
|
responsex.ErrorWithData(ctx, ctx.Writer, err, data, ops...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ErrorStr(ctx *gin.Context, msg string, ops ...responsex.Option) {
|
|
|
|
|
responsex.ErrorStr(ctx, ctx.Writer, msg, ops...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Success(ctx *gin.Context, data any, ops ...responsex.Option) {
|
|
|
|
|
responsex.Success(ctx, ctx.Writer, data, ops...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func SuccessWithPage(ctx *gin.Context, data any, page responsex.Pagination, ops ...responsex.Option) {
|
|
|
|
|
responsex.SuccessWithPage(ctx, ctx.Writer, data, &page, ops...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Custom(ctx *gin.Context, ops ...responsex.Option) {
|
|
|
|
|
responsex.ResponseCtx(ctx, ctx.Writer, ops...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func MsgMapData(ctx *gin.Context, msgKey string, format map[string]string, data any, ops ...responsex.Option) {
|
|
|
|
|
responsex.FormatMessage(ctx, ctx.Writer, msgKey, format, data, ops...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func MsgKV(ctx *gin.Context, msgKey string, k string, v string, ops ...responsex.Option) {
|
|
|
|
|
responsex.FormatMessage(ctx, ctx.Writer, msgKey, map[string]string{k: v}, nil, ops...)
|
|
|
|
|
}
|