services

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthService

type AuthService interface {
	Service

	Sign(args ...any) (string, error)
	Check(token string, args ...string) (string, string, error)
	Black(token string) error
	IsToken(token string) bool
}

type CacheService

type CacheService interface {
	Service

	SetDefault(k string, x any)
	Set(k string, x any, d time.Duration)
	Add(k string, x any, d time.Duration) error
	Replace(k string, x any, d time.Duration) error
	Increment(k string, n int64) error
	Decrement(k string, n int64) error

	Get(k string) (any, bool)
	GetWithExpiration(k string) (any, time.Time, bool)
	Flash(k string) (any, bool)

	Delete(k string)
	Flush()

	SaveFile(filename string) error
	LoadFile(filename string) error

	ItemCount() int
}

type Config

type Config interface {
	Service
	Set(arg any) Config
	Get(fieldStr string, args ...any) any
}

Config 配置内容接口

type ConfigService

type ConfigService interface {
	Service
	Get(fieldStr string, args ...any) any
}

ConfigService 配置服务接口

type CookieService

type CookieService interface {
	Service

	Set(c *gin.Context, key, val string, args ...any)
	Get(c *gin.Context, key string) (string, error)
}

type DBLogger

type DBLogger interface {
	Set(arg any) DBLogger
	logger.Interface
}

type DBService

type DBService interface {
	Service

	AutoMigrate(dst ...interface{}) error
	Association(column string) *gorm.Association
	Attrs(attrs ...interface{}) (tx *gorm.DB)
	Assign(attrs ...interface{}) (tx *gorm.DB)
	AddError(err error) error

	Begin(opts ...*sql.TxOptions) *gorm.DB

	Create(value interface{}) (tx *gorm.DB)
	CreateInBatches(value interface{}, batchSize int) (tx *gorm.DB)
	Count(count *int64) (tx *gorm.DB)
	Connection(fc func(tx *gorm.DB) error) (err error)
	Commit() *gorm.DB
	Clauses(conds ...clause.Expression) (tx *gorm.DB)

	Distinct(args ...interface{}) (tx *gorm.DB)
	Delete(value interface{}, conds ...interface{}) (tx *gorm.DB)
	Debug() (tx *gorm.DB)
	SqlDB() (*sql.DB, error)

	Exec(sql string, values ...interface{}) (tx *gorm.DB)

	First(dest interface{}, conds ...interface{}) (tx *gorm.DB)
	Find(dest interface{}, conds ...interface{}) (tx *gorm.DB)
	FindInBatches(dest interface{}, batchSize int, fc func(tx *gorm.DB, batch int) error) *gorm.DB
	FirstOrInit(dest interface{}, conds ...interface{}) (tx *gorm.DB)
	FirstOrCreate(dest interface{}, conds ...interface{}) (tx *gorm.DB)

	Group(name string) (tx *gorm.DB)
	Get(key string) (interface{}, bool)
	GormDB() *gorm.DB

	Having(query interface{}, args ...interface{}) (tx *gorm.DB)

	InnerJoins(query string, args ...interface{}) (tx *gorm.DB)
	InstanceSet(key string, value interface{}) *gorm.DB
	InstanceGet(key string) (interface{}, bool)

	Joins(query string, args ...interface{}) (tx *gorm.DB)

	Last(dest interface{}, conds ...interface{}) (tx *gorm.DB)
	Limit(limit int) (tx *gorm.DB)

	Migrator() gorm.Migrator
	Model(value interface{}) (tx *gorm.DB)

	Not(query interface{}, args ...interface{}) (tx *gorm.DB)

	Omit(columns ...string) (tx *gorm.DB)
	Or(query interface{}, args ...interface{}) (tx *gorm.DB)
	Order(value interface{}) (tx *gorm.DB)
	Offset(offset int) (tx *gorm.DB)

	Pluck(column string, dest interface{}) (tx *gorm.DB)
	Preload(query string, args ...interface{}) (tx *gorm.DB)

	Raw(sql string, values ...interface{}) (tx *gorm.DB)
	Row() *sql.Row
	Rows() (*sql.Rows, error)
	Rollback() *gorm.DB
	RollbackTo(name string) *gorm.DB

	Save(value interface{}) (tx *gorm.DB)
	Scan(dest interface{}) (tx *gorm.DB)
	ScanRows(rows *sql.Rows, dest interface{}) error
	SavePoint(name string) *gorm.DB
	Select(query interface{}, args ...interface{}) (tx *gorm.DB)
	Scopes(funcs ...func(*gorm.DB) *gorm.DB) (tx *gorm.DB)
	Session(config *gorm.Session) *gorm.DB
	Set(key string, value interface{}) *gorm.DB
	SetupJoinTable(model interface{}, field string, joinTable interface{}) error

	Table(name string, args ...interface{}) (tx *gorm.DB)
	Take(dest interface{}, conds ...interface{}) (tx *gorm.DB)
	Transaction(fc func(tx *gorm.DB) error, opts ...*sql.TxOptions) (err error)
	ToSQL(queryFn func(tx *gorm.DB) *gorm.DB) string

	Use(plugin gorm.Plugin) error
	Unscoped() (tx *gorm.DB)
	Update(column string, value interface{}) (tx *gorm.DB)
	Updates(values interface{}) (tx *gorm.DB)
	UpdateColumn(column string, value interface{}) (tx *gorm.DB)
	UpdateColumns(values interface{}) (tx *gorm.DB)

	WithContext(ctx context.Context) *gorm.DB
	Where(query interface{}, args ...interface{}) (tx *gorm.DB)
}

type Exception

type Exception interface {
	error
	Service
	Set(arg any) Exception
	Get(field string) (any, error)
	New(code int, args ...any) Exception
	Build(args ...any) Exception
	Handle(c *gin.Context) bool
}

Exception 异常内容接口

type ExceptionService

type ExceptionService interface {
	Service
	Build(args ...any) Exception
	Handle(c *gin.Context) bool
}

ExceptionService 异常服务接口

type Handler

type Handler any

Handler 将 gin 中间件使用的处理程序定义为返回值.

type Handlers

type Handlers []Handler

Handlers HandlersChain 定义 HandlerFunc 的切片.

type IRouter

type IRouter interface {
	IRoutes
	Group(string, ...Handler) IRouter
}

IRouter 定义所有路由器句柄接口, 包括单路由器和组路由器.

type IRoutes

type IRoutes interface {
	Use(...Handler) RouteService

	Handle(string, string, ...Handler) IRoutes
	Any(string, ...Handler) IRoutes
	GET(string, ...Handler) IRoutes
	POST(string, ...Handler) IRoutes
	DELETE(string, ...Handler) IRoutes
	PATCH(string, ...Handler) IRoutes
	PUT(string, ...Handler) IRoutes
	OPTIONS(string, ...Handler) IRoutes
	HEAD(string, ...Handler) IRoutes
	Match([]string, string, ...Handler) IRoutes

	StaticFile(string, string) IRoutes
	StaticFileFS(string, string, http.FileSystem) IRoutes
	Static(string, string) IRoutes
	StaticFS(string, http.FileSystem) IRoutes
}

IRoutes 定义所有路由器句柄接口.

type LoggerService

type LoggerService interface {
	Service

	Check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry
	Core() zapcore.Core

	Debug(msg string, fields ...zap.Field)
	DPanic(msg string, fields ...zap.Field)
	Error(msg string, fields ...zap.Field)
	Fatal(msg string, fields ...zap.Field)
	Info(msg string, fields ...zap.Field)
	Level() zapcore.Level
	Log(lvl zapcore.Level, msg string, fields ...zap.Field)
	Named(s string) *zap.Logger
	Panic(msg string, fields ...zap.Field)

	Sugar() *zap.SugaredLogger
	Sync() error

	WithOptions(opts ...zap.Option) *zap.Logger
	With(fields ...zap.Field) *zap.Logger
	Warn(msg string, fields ...zap.Field)

	Zap() *zap.Logger

	DB() DBLogger
}

LoggerService 日志服务

type Passwd

type Passwd interface {
	Hash(passwd string) (string, error)
	Check(passwd string, hash string) error
}

type PasswdService

type PasswdService interface {
	Service

	Hash(passwd string) (string, error)
	Check(passwd string, hash string) error
}

type Response

type Response interface {
	Service
	Set(any) Response
	Get(field string) (any, error)
	New(code int, args ...any) Response
	Build(code int, args ...any) Response
	Handle(c *gin.Context) bool
}

Response 响应体接口

type ResponseService

type ResponseService interface {
	Service
	Build(code int, args ...any) Response
	Handle(c *gin.Context) bool
	IsToken(token string) bool
}

ResponseService 响应体服务接口

type RouteService

type RouteService interface {
	Service

	Handler() http.Handler
	SecureJsonPrefix(prefix string) RouteService

	Delims(left, right string) RouteService
	LoadHTMLGlob(pattern string)
	LoadHTMLGlobs(patterns ...string) error
	LoadHTMLFS(embed fs.FS, patterns ...string)
	LoadHTMLFiles(files ...string)
	SetHTMLTemplate(tmpl *template.Template)
	SetFuncMap(funcMap template.FuncMap)

	NoRoute(handlers ...Handler)
	NoMethod(handlers ...Handler)

	Routes() (routes gin.RoutesInfo)

	Run(addr ...string) (err error)
	RunTLS(addr, certFile, keyFile string) (err error)
	RunUnix(file string) (err error)
	RunFd(fd int) (err error)
	RunListener(listener net.Listener) (err error)

	HandleContext(c *gin.Context)

	Group(relativePath string, handlers ...Handler) IRouter
	UseBefore(middleware ...Handler) RouteService
	Use(middleware ...Handler) RouteService
	Handle(httpMethod, relativePath string, handlers ...Handler) IRoutes
	Any(relativePath string, handlers ...Handler) IRoutes
	GET(relativePath string, handlers ...Handler) IRoutes
	POST(relativePath string, handlers ...Handler) IRoutes
	DELETE(relativePath string, handlers ...Handler) IRoutes
	PATCH(relativePath string, handlers ...Handler) IRoutes
	PUT(relativePath string, handlers ...Handler) IRoutes
	OPTIONS(relativePath string, handlers ...Handler) IRoutes
	HEAD(relativePath string, handlers ...Handler) IRoutes
	Match(methods []string, relativePath string, handlers ...Handler) IRoutes

	StaticFile(relativePath, filepath string) IRoutes
	StaticFileFS(relativePath, filepath string, fs http.FileSystem) IRoutes
	Static(relativePath, root string) IRoutes
	StaticFS(relativePath string, fs http.FileSystem) IRoutes

	ServeHTTP(w http.ResponseWriter, req *http.Request)
}

RouteService 路由服务接口

type Service

type Service interface {
	Init(...Service) Service
}

Service 服务通用接口

type Storage

type Storage interface {
	Image(c *gin.Context) (string, string, error)
	File(c *gin.Context) (string, string, error)
}

type SymCryptService

type SymCryptService interface {
	Service

	Encrypt(plain string) (string, error)
	Decrypt(cipher string) (string, error)
}

type TransAll

type TransAll map[string]any

type TransCategory

type TransCategory map[string]TransMap

type TransMap

type TransMap map[string]string

type TranslateService

type TranslateService interface {
	Service

	DBError(err error) error
}

type UploadService

type UploadService interface {
	Service

	Image(c *gin.Context) (string, string, error)
	File(c *gin.Context) (string, string, error)
	Store(storage string) Storage
}

type UtilService

type UtilService interface {
	Service

	Nanoid(args ...int) string
	Direct(v reflect.Value) reflect.Value

	SetEnv(env, key, value string) error
	SecretKey(length int) (string, error)

	ExcpKey() string
	BlackTokenKey(nanoid string) string

	Ptr(v any) any

	CreateDir(dir string) string
	IsExist(file string) bool
}

type ValidatorService

type ValidatorService interface {
	Service
	Translate(errs validator.ValidationErrors) validator.ValidationErrorsTranslations
	GetTrans() ut.Translator
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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