types

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IAppCache

type IAppCache interface {
	// 默认缓存过期时间
	DefaultExpiration() time.Duration
	// 从map数据中加载
	LoadMap(items map[string]any)
	// 注册缓存,如果缓存不存在或过期,则自动使用getter获取数据并添加缓存
	Register(key string, expire time.Duration, getter func() any)
	// 获取缓存数据,如果缓存不存在或已过期返回 nil, 并在获取时检查并重置过期
	Get(key string) (any, bool)
	// 设置缓存数据,与Register不同的是,一旦过期将不会自动存入
	Set(key string, value any, expire time.Duration)
	// 更新缓存:缓存数据存在且未过期
	Replace(key string, value any, expire time.Duration) error
	// 添加缓存:缓存数据不存在或已过期
	Add(key string, value any, expire time.Duration) error
	// 删除缓存数据
	Delete(key string)
	// 清空所有缓存数据
	Flush()
}

type IApplication

type IApplication interface {
	Init(env string) error
	Run(host string, port int)
	RegisterModel(models ...any)
	MigrateDbModels()
	GetConfig() *conf.AppConfig
}

type IAuthController

type IAuthController interface {
	HasRole(userId uint, roles ...string) bool
	HasPermission(userId uint, permissions ...string) bool
	HasAnyRole(userId uint, roles ...string) bool
	HasAnyPermission(userId uint, permissions ...string) bool
}

权限控制器

Jump to

Keyboard shortcuts

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