g

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordRepeat = errors.New("数据已经存在")
	ErrDateBusy     = errors.New("数据在使用")
)

Functions

This section is empty.

Types

type Error

type Error struct {
	Inner      error
	Text       string // 业务错误信息,通常是中文提示,返回给客户端
	StackTrace string
	Misc       map[string]any // miscellaneous(各种各样) information
}

Error 自定义错误

func NewError

func NewError(message string) *Error

func NewErrorf

func NewErrorf(format string, a ...any) *Error

func WrapError

func WrapError(err error, message string) *Error

WrapError new Error

func (*Error) Error

func (err *Error) Error() string

func (*Error) Is

func (err *Error) Is(target error) bool

Is inner error 断言

func (*Error) Unwrap

func (err *Error) Unwrap() error

Unwrap 返回 inner error

type FindByIDService

type FindByIDService[T any] struct{}

func (*FindByIDService[T]) FindByID

func (*FindByIDService[T]) FindByID(tx *gorm.DB, id string) (T, *Error)

type IBase

type IBase[T any, Q any] interface {
	PageList(Q) (*page.Data[T], *Error)
	Create(T) *Error
	Update(T) *Error
	Delete(int) *Error
}

type IBaseApi

type IBaseApi interface {
	PageList(ctx *gin.Context)
	Create(ctx *gin.Context)
	Update(ctx *gin.Context)
	Delete(ctx *gin.Context)
}

type UniqueService

type UniqueService[T any] struct{}

UniqueService 校验传入值是否已经在数据库中存在 T 表示要查询表的Model k为 'id' 作为排除,比如更新时

type UserService struct{
	g.Unique[model.User]
}

func (*UniqueService[T]) Verify

func (*UniqueService[T]) Verify(tx *gorm.DB, q map[string]any) *Error

Jump to

Keyboard shortcuts

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