sdk

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func GormErrorAs

func GormErrorAs(gorm *gorm.DB) error

GormErrorAs 检查Gorm执行错误

func MakeCondition

func MakeCondition(params any, gorm *gorm.DB) *gorm.DB

MakeCondition 生成查询器

Types

type Api

type Api struct {
}

func (*Api) Errors

func (e *Api) Errors(err error) types.IApiResult

func (*Api) Failure

func (e *Api) Failure(data ...any) types.IApiResult

Failure 通常错误数据处理

func (*Api) HttpCode

func (e *Api) HttpCode(code int) types.IApiResult

func (*Api) Json

func (e *Api) Json(data ...any) types.IApiResult

func (*Api) Jsonp

func (e *Api) Jsonp(data ...any) types.IApiResult

func (*Api) Null

func (e *Api) Null() types.IApiResult

func (*Api) Redirect

func (e *Api) Redirect() types.IApiResult

func (*Api) Result

func (e *Api) Result(api types.IApiResult, data ...any) types.IApiResult

func (*Api) String

func (e *Api) String(data ...any) types.IApiResult

func (*Api) Success

func (e *Api) Success(data ...any) types.IApiResult

Success 通常成功数据处理

func (*Api) View

func (e *Api) View(name string, data fiber.Map) types.IApiResult

func (*Api) Xml

func (e *Api) Xml(data ...any) types.IApiResult

type IRouter

type IRouter interface {
	InitRouter(r *Router)
}

type Router

type Router struct {
	Engine *fiber.App
	Router fiber.Router
}

func (*Router) DELETE

func (r *Router) DELETE(relativePath string, handlers any)

func (*Router) Exec

func (r *Router) Exec(c *fiber.Ctx, method string, handlers any) error

func (*Router) GET

func (r *Router) GET(relativePath string, handlers any)

func (*Router) Group

func (r *Router) Group(relativePath string) *Router

func (*Router) Options

func (r *Router) Options(relativePath string, handlers any)

func (*Router) POST

func (r *Router) POST(relativePath string, handlers any)

func (*Router) Put

func (r *Router) Put(relativePath string, handlers any)

type Service

type Service[T any, R any] struct {
	Data T
	Ctx  *fiber.Ctx
	// contains filtered or unexported fields
}

Service 服务

func (*Service[T, R]) Cache

func (s *Service[T, R]) Cache(ttl int64) *Service[T, R]

Cache 是否开启缓存

func (*Service[T, R]) Create

func (s *Service[T, R]) Create(data *T, omits ...string) *errors.Message

Create 创建 omits 忽略字段

func (*Service[T, R]) DB

func (s *Service[T, R]) DB() *gorm.DB

func (*Service[T, R]) Delete

func (s *Service[T, R]) Delete(id uint, omits ...string) *errors.Message

Delete 删除 omits 忽略字段

func (*Service[T, R]) Destroy

func (s *Service[T, R]) Destroy(id uint, omits ...string) *errors.Message

Destroy 彻底删除 omits 忽略字段

func (*Service[T, R]) FindByField

func (s *Service[T, R]) FindByField(field string, value any) (result *R, err *errors.Message)

FindByField 获取信息

func (*Service[T, R]) FindByFields

func (s *Service[T, R]) FindByFields(fields any) (result *R, err *errors.Message)

FindByFields 获取信息

func (*Service[T, R]) FindById

func (s *Service[T, R]) FindById(id uint) (result *R, err *errors.Message)

FindById 获取信息

func (*Service[T, R]) GetCacheDb

func (s *Service[T, R]) GetCacheDb(ttl int64) *gorm.DB

func (*Service[T, R]) GetDb

func (s *Service[T, R]) GetDb(dbName string) *gorm.DB

GetDb 获取指定DB

func (*Service[T, R]) GetReadDb

func (s *Service[T, R]) GetReadDb() *gorm.DB

GetReadDb 获取DB

func (*Service[T, R]) GetWriteDb

func (s *Service[T, R]) GetWriteDb() *gorm.DB

GetWriteDb 获取DB

func (*Service[T, R]) Search

func (s *Service[T, R]) Search(page int, pageSize int, params any) (*TPage[R], *errors.Message)

Search 分页查询

func (*Service[T, R]) Update

func (s *Service[T, R]) Update(id uint, data *T, omits ...string) *errors.Message

Update 更新信息 omits 忽略字段

func (*Service[T, R]) WithContext

func (s *Service[T, R]) WithContext(c *fiber.Ctx) *errors.Message

WithContext 绑定上下文

type TPage

type TPage[T any] struct {
	Page     int   `json:"page"`
	PageSize int   `json:"pageSize"`
	Total    int64 `json:"total"`
	Lists    []T   `json:"lists"`
}

TPage 分页查询结构体

func CreateTPage

func CreateTPage[T any](lists []T) *TPage[T]

CreateTPage 创建分页体

Jump to

Keyboard shortcuts

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