models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2020 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package models 存放数据操作实体和方法,按模块划分,模块里可以有多个表,每个表再用文件区分

Index

Constants

This section is empty.

Variables

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

DefaultCommonParam 默认值

Functions

func DefaultCtx

func DefaultCtx() context.Context

DefaultCtx 默认

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 扫描

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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