core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeInternalError = 1000
	ErrCodeInvalidParams = 1001
	ErrCodeNotFound      = 1002
	ErrCodeAlreadyExists = 1003
	ErrCodeUnauthorized  = 1004
	ErrCodeForbidden     = 1005

	FailedToDeleteNode = 1006
	FailedToGetNode    = 1007
	FailedToAddNode    = 1008

	FieldError     = 2000
	FieldInvalid   = 2001
	FieldTooLong   = 2002
	FieldTooShort  = 2003
	FieldTooSmall  = 2004
	FieldTooBig    = 2005
	FieldNotMatch  = 2006
	FieldNotUnique = 2007
	EntityNotFound = 2008
)

Variables

View Source
var Validate = validator.New(validator.WithRequiredStructEnabled())

Functions

func BindParamAndValidate

func BindParamAndValidate[T interface{}](c *gin.Context, obj *T)

func SerializeData

func SerializeData[T interface{}](source any, target *T) T

func SerializeDataAndValidate

func SerializeDataAndValidate[T interface{}](source T, target *T, doSerialize ...bool) T

func SuccessHandler

func SuccessHandler(c *gin.Context, responseData interface{})

SuccessHandler 返回成功响应

func ValidateSchema

func ValidateSchema[T interface{}](source T) T

func ValidateStruct

func ValidateStruct(i interface{}) error

ValidateStruct validates the request structure

Types

type KnownError

type KnownError struct {
	Code int
	Data interface{}
	Msg  string
}

func NewKnownError

func NewKnownError(code int, data interface{}, msg string) *KnownError

func (*KnownError) Error

func (e *KnownError) Error() string

Jump to

Keyboard shortcuts

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