layer

package
v1.10.9 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//StackLogger func(ctx *gin.Context, err error)
	ErrMsgMap                  map[int]string
	NmqResponseStatusCodeError = 500
	NmqRetryError              = 34002
)

Functions

func ErrorToRanderJson

func ErrorToRanderJson(err error) puzzle.DefaultRender

Types

type Api

type Api struct {
	Flow
}

func (*Api) PreUse

func (entity *Api) PreUse(args ...interface{})

type BaseError

type BaseError interface {
}

type Controller

type Controller struct {
	Flow
}

func (*Controller) Action

func (entity *Controller) Action()

func (*Controller) BindParam

func (entity *Controller) BindParam(req interface{}) bool

func (*Controller) BindParamError added in v1.1.4

func (entity *Controller) BindParamError(req interface{}) error

func (*Controller) RenderHttpError

func (entity *Controller) RenderHttpError(errNo int, errDetail ...interface{})

func (*Controller) RenderJsonAbort

func (entity *Controller) RenderJsonAbort(err error)

func (*Controller) RenderJsonFail

func (entity *Controller) RenderJsonFail(err error)

func (*Controller) RenderJsonSucc

func (entity *Controller) RenderJsonSucc(data interface{})

type Dao

type Dao struct {
	Flow
	// contains filtered or unexported fields
}

func (*Dao) Create

func (entity *Dao) Create(value interface{}) error

func (*Dao) GetDB

func (entity *Dao) GetDB(args ...string) *gorm.DB

func (*Dao) GetModel added in v1.10.7

func (entity *Dao) GetModel() interface{}

func (*Dao) GetTable

func (entity *Dao) GetTable() string

deprecated

func (*Dao) PreUse

func (entity *Dao) PreUse(args ...interface{})

默认第一个参数为db,可利用该特性批量处理事务

func (*Dao) Printf added in v1.10.1

func (entity *Dao) Printf(msg string, args ...interface{})

func (*Dao) SetDB

func (entity *Dao) SetDB(db *gorm.DB)

func (*Dao) SetModel added in v1.10.7

func (entity *Dao) SetModel(model interface{})

func (*Dao) SetTable

func (entity *Dao) SetTable(tableName string)

deprecated

func (*Dao) Update

func (entity *Dao) Update(model interface{}, attrs interface{}, query interface{}, args ...interface{}) error

Update selected Fields, if attrs is an object, it will ignore default value field; if attrs is map, it will ignore unchanged field.

type DataSet added in v1.10.1

type DataSet struct {
	Flow
}

type Flow

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

func (*Flow) CountArgs

func (entity *Flow) CountArgs() int

func (*Flow) GetAllArgs

func (entity *Flow) GetAllArgs() []interface{}

func (*Flow) GetArgs

func (entity *Flow) GetArgs(idx int) interface{}

func (*Flow) GetContext

func (entity *Flow) GetContext() *gin.Context

func (*Flow) GetLog

func (entity *Flow) GetLog() *zap.SugaredLogger

func (*Flow) GetLogCtx

func (entity *Flow) GetLogCtx() *puzzle.LogCtx

func (*Flow) LogDebug

func (entity *Flow) LogDebug(args ...interface{})

提供给业务使用的server log 日志打印方法

func (*Flow) LogDebugf

func (entity *Flow) LogDebugf(format string, args ...interface{})

func (*Flow) LogError

func (entity *Flow) LogError(args ...interface{})

func (*Flow) LogErrorf

func (entity *Flow) LogErrorf(format string, args ...interface{})

func (*Flow) LogInfo

func (entity *Flow) LogInfo(args ...interface{})

func (*Flow) LogInfof

func (entity *Flow) LogInfof(format string, args ...interface{})

func (*Flow) LogWarn

func (entity *Flow) LogWarn(args ...interface{})

func (*Flow) LogWarnf

func (entity *Flow) LogWarnf(format string, args ...interface{})

func (*Flow) PreUse

func (entity *Flow) PreUse(args ...interface{})

参数为Use的可选参数部分

func (*Flow) SetArgs

func (entity *Flow) SetArgs(idx int, arg interface{}) *Flow

func (*Flow) SetContext

func (entity *Flow) SetContext(ctx *gin.Context) *Flow

func (*Flow) SetLog

func (entity *Flow) SetLog(log *zap.SugaredLogger) *Flow

func (*Flow) SetLogCtx

func (entity *Flow) SetLogCtx(logCtx *puzzle.LogCtx) *Flow

func (*Flow) Use

func (entity *Flow) Use(newFlow IFlow, args ...interface{}) interface{}

use 支持可选参数

type IApi

type IApi interface {
	IFlow
}

type IConsumer

type IConsumer interface {
	IFlow
	Run(args []string) error
	Setup(sarama.ConsumerGroupSession) error
	Cleanup(sarama.ConsumerGroupSession) error
	ConsumeClaim(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error
}

type IController

type IController interface {
	IFlow
	BindParam(req interface{}) bool
	Action()
	RenderJsonFail(err error)
	RenderJsonSucc(data interface{})
	RenderJsonAbort(err error)
	RenderHttpError(errNo int, errDetail ...interface{})
}

type IDao

type IDao interface {
	IFlow
	GetDB() *gorm.DB
	SetDB(db *gorm.DB)
	SetTable(tableName string)
	GetTable() string
	SetModel(model interface{})
	GetModel() interface{}
}

type IDataSet added in v1.10.1

type IDataSet interface {
	IFlow
}

type IFlow

type IFlow interface {
	GetContext() *gin.Context
	SetContext(*gin.Context) *Flow
	GetArgs(idx int) interface{}
	SetArgs(idx int, arg interface{}) *Flow
	GetAllArgs() []interface{}
	Use(newFlow IFlow, args ...interface{}) interface{}
	PreUse(args ...interface{})
	GetLogCtx() *puzzle.LogCtx
	SetLogCtx(logCtx *puzzle.LogCtx) *Flow
	GetLog() *zap.SugaredLogger
	SetLog(log *zap.SugaredLogger) *Flow
}

type INMQConsumer

type INMQConsumer interface {
	IFlow
	Process() (interface{}, error)
}

type IService

type IService interface {
	IFlow
}

type ITask

type ITask interface {
	IFlow
	Run(args []string) error
}

type KFKConsumer added in v1.0.4

type KFKConsumer struct {
	Flow

	Ready  chan bool
	Topics []string
	// contains filtered or unexported fields
}

func (*KFKConsumer) Cleanup added in v1.0.4

func (entity *KFKConsumer) Cleanup(sarama.ConsumerGroupSession) error

func (*KFKConsumer) ConsumeClaim added in v1.0.4

func (entity *KFKConsumer) ConsumeClaim(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error

func (*KFKConsumer) LogAndExit added in v1.0.4

func (entity *KFKConsumer) LogAndExit(format string, args ...interface{})

func (*KFKConsumer) LoopKafka added in v1.0.4

func (entity *KFKConsumer) LoopKafka(handler ConsumeHandler)

func (*KFKConsumer) Setup added in v1.0.4

type NmqConsumer

type NmqConsumer struct {
	Flow
}

type Service

type Service struct {
	Flow
}

type Task

type Task struct {
	Flow
}

func (*Task) Run

func (entity *Task) Run(args []string) error

Jump to

Keyboard shortcuts

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