base

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Config *BaseConfig
	Log    *iLog
	Cache  *gzcache.CacheNode
	Casbin *casbinV2.SyncedEnforcer
	Rdb    redis.Cmdable
	Mdb    *mongo.Client
)

Functions

func Fail

func Fail(ctx *gin.Context, code int64, msg ...string)

func FailWithMessage

func FailWithMessage(ctx *gin.Context, msg string)

func Gorm

func Gorm(name ...string) *gorm.DB

func LoadConfig

func LoadConfig[T any](file string, env string, target *T) error

func RegisterService

func RegisterService(service ...IService)

func Run

func Run()

func SetDb

func SetDb(name string, gdb *gorm.DB, sdb *sqlx.DB)

func Sqlx

func Sqlx(name ...string) *sqlx.DB

func Success

func Success(ctx *gin.Context, data interface{})

func SuccessWithMessage

func SuccessWithMessage(ctx *gin.Context, msg string)

Types

type BaseConfig

type BaseConfig struct {
	App    app             `mapstructure:"app"`
	Db     []databasesConf `mapstructure:"databases"`
	Redis  redisConf       `mapstructure:"redis"`
	Mongo  mongoConf       `mapstructure:"mongo"`
	Logger logger          `mapstructure:"logger"`
	Casbin casbin          `mapstructure:"casbin"`
	Jwt    jwt             `mapstructure:"jwt"`
	Oss    oss             `mapstructure:"oss"`
}

type IServer

type IServer struct {
	IService
}

func (*IServer) OnStart

func (self *IServer) OnStart() error

type IService

type IService interface {
	OnStart() error
}

type PageResult

type PageResult struct {
	List        interface{} `json:"list"`
	Total       int64       `json:"total"`
	CurrentPage int64       `json:"current_page"`
	PageSize    int64       `json:"page_size"`
}

type Response

type Response struct {
	Code    int64       `json:"code"`
	Msg     string      `json:"msg"`
	Data    interface{} `json:"data"`
	NowTime int64       `json:"nowTime"`
	UseTime string      `json:"useTime"`
}

Jump to

Keyboard shortcuts

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