app

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCommonParam = CommonParam{
	PageSize: 10,
}

DefaultCommonParam 默认值

Functions

func DefaultCtx

func DefaultCtx() context.Context

DefaultCtx 默认

func Inject

func Inject(v interface{}) (err error)

func MustInject

func MustInject(v interface{})

func MustRegisterProvider

func MustRegisterProvider(v interface{})

func RegisterProvider

func RegisterProvider(v interface{}) (err error)

Types

type Base

type Base struct {
}

Base 基底

func NewBase

func NewBase() *Base

NewBase 新建

func (*Base) ProcessConcurrent

func (b *Base) ProcessConcurrent(ctx context.Context, opt ProcessOption) error

ProcessConcurrent 并发处理

type CommonParam

type CommonParam struct {
	BeginTime int64 `json:"beginTime"` // 开始时间
	EndTime   int64 `json:"endTime"`   // 结束时间

	PageIndex int `json:"pageIndex"` // 分页开始
	PageSize  int `json:"pageSize"`  // 分页大小
}

CommonParam 通用参数

type DB

type DB = db.DB

DB DB接口

type Doer

type Doer interface {
	Do(context.Context) error
}

Doer 处理

type Entity

type Entity interface {
	Scanner
	Doer
}

Entity 实体

type ProcessOption

type ProcessOption struct {
	Query string
	Args  []interface{}

	N int // 批数量

	// 如果用接口呢?就可以不用将值返回,而是存在实体里,这样实体调用Do方法的时候就不需要传入Scan获取到的返回值
	// 这样也不会有分裂出现
	NewEntity func() Entity
}

ProcessOption 选项

type Scanner

type Scanner interface {
	Scan(context.Context, *sql.Rows) error
}

Scanner 扫描

Jump to

Keyboard shortcuts

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