partner

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MulanPSL-2.0 Imports: 14 Imported by: 0

README

gin-partner

usage

go get -u gitee.com/binny_w/gin-partner

import "gitee.com/binny_w/gin-partner"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cors

func Cors() gin.HandlerFunc

func RateLimit

func RateLimit(redis *util.Redis, rate uint, period time.Duration) gin.HandlerFunc

func WriteJsonError

func WriteJsonError(c *gin.Context, code uint, msg string)

func WriteJsonSuccess

func WriteJsonSuccess(c *gin.Context, data any)

Types

type CommonModel

type CommonModel struct {
	// contains filtered or unexported fields
}

func NewCommonModel

func NewCommonModel(name string) *CommonModel

func (*CommonModel) ClearGetHandlers

func (m *CommonModel) ClearGetHandlers(action string)

func (*CommonModel) ClearPostHandlers

func (m *CommonModel) ClearPostHandlers(action string)

func (*CommonModel) GetHandlers

func (m *CommonModel) GetHandlers() map[string][]gin.HandlerFunc

func (*CommonModel) Name

func (m *CommonModel) Name() string

func (*CommonModel) PostHandlers

func (m *CommonModel) PostHandlers() map[string][]gin.HandlerFunc

func (*CommonModel) SetGetHandlers

func (m *CommonModel) SetGetHandlers(action string, handles ...gin.HandlerFunc)

func (*CommonModel) SetPostHandlers

func (m *CommonModel) SetPostHandlers(action string, handles ...gin.HandlerFunc)

func (*CommonModel) UseGetMiddlewares

func (m *CommonModel) UseGetMiddlewares(action string, handles ...gin.HandlerFunc)

func (*CommonModel) UsePostMiddlewares

func (m *CommonModel) UsePostMiddlewares(action string, handles ...gin.HandlerFunc)

type Config

type Config struct {
	V *viper.Viper
}

func NewConfig

func NewConfig(onChange func(e fsnotify.Event)) *Config

func (*Config) Get

func (c *Config) Get(key string) any

func (*Config) GetAll

func (c *Config) GetAll() map[string]any

func (*Config) GetBool

func (c *Config) GetBool(key string) bool

func (*Config) GetInt

func (c *Config) GetInt(key string) int

func (*Config) GetInt64

func (c *Config) GetInt64(key string) int64

func (*Config) GetIntSlice

func (c *Config) GetIntSlice(key string) []int

func (*Config) GetStrMap

func (c *Config) GetStrMap(key string) map[string]any

func (*Config) GetStrSlice

func (c *Config) GetStrSlice(key string) []string

func (*Config) GetString

func (c *Config) GetString(key string) string

func (*Config) LoadFromFile

func (c *Config) LoadFromFile(filePath, fileType string) error

func (*Config) LoadFromRemote

func (c *Config) LoadFromRemote(provider, endpoint, path, cType string) error

func (*Config) SetDefault

func (c *Config) SetDefault(key string, val any)

type Engine

type Engine struct {
	E         *gin.Engine
	PathsGet  []string
	PathsPost []string
}

func NewEngine

func NewEngine(logFile, mode string) *Engine

func (*Engine) RouterGet

func (e *Engine) RouterGet(group *gin.RouterGroup, path string, handlers ...gin.HandlerFunc) gin.IRoutes

func (*Engine) RouterGroup

func (e *Engine) RouterGroup(path string, handlers ...gin.HandlerFunc) *gin.RouterGroup

func (*Engine) RouterPost

func (e *Engine) RouterPost(group *gin.RouterGroup, path string, handlers ...gin.HandlerFunc) gin.IRoutes

func (*Engine) RouterWithModel

func (e *Engine) RouterWithModel(group *gin.RouterGroup, model Model)

func (*Engine) Run

func (e *Engine) Run(addr string, onClose func())

func (*Engine) UseMiddleware

func (e *Engine) UseMiddleware(middleware ...gin.HandlerFunc)

type Logger

type Logger struct {
	L *zap.Logger
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(filePath string) *Logger

func (*Logger) Close

func (l *Logger) Close()

func (*Logger) DPanic

func (l *Logger) DPanic(msg string, fields ...zap.Field)

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...zap.Field)

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...zap.Field)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...zap.Field)

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...zap.Field)

func (*Logger) Panic

func (l *Logger) Panic(msg string, fields ...zap.Field)

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...zap.Field)

type Model

type Model interface {
	Name() string
	GetHandlers() map[string][]gin.HandlerFunc
	PostHandlers() map[string][]gin.HandlerFunc
}

type QueryKeyword

type QueryKeyword struct {
	Page     string
	PageSize string
	OrderBy  string
	SoColumn string
	SoWord   string
}

type TableModel

type TableModel struct {
	Table          *util.MysqlTable
	OrderBys       map[string]string
	OrderByDefault string
	InfoFixer      func(row *util.MysqlRow) error
	ListFixer      func(row *util.MysqlRow) error
	InsertFixer    func(row *util.MysqlRow) error
	UpdateFixer    func(row *util.MysqlRow) error
	QueryKeyword   *QueryKeyword
	CommonModel
}

func NewTableModel

func NewTableModel(mt *util.MysqlTable, alias string, qkd *QueryKeyword) *TableModel

func NewTableModelEasy added in v0.0.3

func NewTableModelEasy(tableName string, db *util.Mysql) *TableModel

Jump to

Keyboard shortcuts

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