api

package
v1.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 2 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SuccessCode    = 200
	ErrorCode      = 100
	ErrorParameter = 422
	SuccessMsg     = "success"
	ErrorMsg       = "error"
	ParameterMsg   = "参数错误"
)

Functions

func DataWithErr

func DataWithErr(ctx *gin.Context, err error, data interface{}, fns ...ResponseFn)

func Error

func Error(ctx *gin.Context, fns ...ResponseFn)

Error /*

func ParameterError

func ParameterError(ctx *gin.Context, fns ...ResponseFn)

ParameterError /*

func Router added in v1.2.2

func Router[T any](routerName string, data CommonService[T], api *gin.RouterGroup, uris ...RouterConst) (router *gin.RouterGroup)

func Success

func Success(ctx *gin.Context, fns ...ResponseFn)

Success /*

func WeChatPayError

func WeChatPayError(ctx *gin.Context)

WeChatPayError /*

func WeChatPaySuccess

func WeChatPaySuccess(ctx *gin.Context)

Types

type Common added in v1.2.2

type Common[T any] struct {
	// contains filtered or unexported fields
}

func (*Common[T]) Add added in v1.2.2

func (c *Common[T]) Add() gin.HandlerFunc

func (*Common[T]) Content added in v1.2.2

func (c *Common[T]) Content() gin.HandlerFunc

func (*Common[T]) Delete added in v1.2.2

func (c *Common[T]) Delete() gin.HandlerFunc

func (*Common[T]) List added in v1.2.2

func (c *Common[T]) List() gin.HandlerFunc

func (*Common[T]) ListPage added in v1.2.2

func (c *Common[T]) ListPage() gin.HandlerFunc

func (*Common[T]) Status added in v1.2.2

func (c *Common[T]) Status() gin.HandlerFunc

func (*Common[T]) Update added in v1.2.2

func (c *Common[T]) Update() gin.HandlerFunc

func (*Common[T]) UpdateFiled added in v1.2.2

func (c *Common[T]) UpdateFiled() gin.HandlerFunc

type CommonApi added in v1.2.2

type CommonApi interface {
	Content() gin.HandlerFunc
	Status() gin.HandlerFunc
	UpdateFiled() gin.HandlerFunc
	Add() gin.HandlerFunc
	Update() gin.HandlerFunc
	Delete() gin.HandlerFunc
	List() gin.HandlerFunc
	ListPage() gin.HandlerFunc
}

func NewCommon added in v1.2.2

func NewCommon[T any](common CommonService[T]) CommonApi

type CommonService added in v1.2.2

type CommonService[T any] interface {
	Add(ctx *gin.Context) (err error)
	Update(ctx *gin.Context) (err error)
	Delete(ctx *gin.Context) (err error)
	List(ctx *gin.Context) (items []*T, err error)
	ListPage(ctx *gin.Context) (list []*T, count int64, err error)
	UpdateFiled(ctx *gin.Context) (err error)
	Content(ctx *gin.Context) (content *T, err error)
	Status(ctx *gin.Context) (err error)
}

type Response

type Response struct {
	Code int         `json:"code" `
	Msg  string      `json:"msg" `
	Data interface{} `json:"data" `
}

type ResponseFn

type ResponseFn func(response *Response) *Response

func Code

func Code(code int) ResponseFn

Code /*

func Data

func Data(data interface{}) ResponseFn

Data /*

func Err

func Err(err error) ResponseFn

Err /*

func Msg

func Msg(msg string) ResponseFn

Msg /*

type RouterConst added in v1.2.4

type RouterConst string
const Add RouterConst = "add"
const Content RouterConst = "content"
const Delete RouterConst = "delete"
const List RouterConst = "list"
const ListPage RouterConst = "listPage"
const Status RouterConst = "status"
const Update RouterConst = "update"
const UpdateFiled RouterConst = "updateFiled"

type RouterFn added in v1.2.2

type RouterFn func(router *gin.RouterGroup)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL