common

package
v2.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusCaptchaError 验证码错误
	StatusCaptchaError = -9
	// StatusNonPrivileged 无权限
	StatusNonPrivileged = -2
	// StatusNotLoggedIn 未登录
	StatusNotLoggedIn = -1
	// StatusFailure 操作失败
	StatusFailure = 0
	// StatusSuccess 操作成功
	StatusSuccess = 1
)

Variables

View Source
var (

	//ErrUserNotLoggedIn 用户未登录
	ErrUserNotLoggedIn = errors.New(`User not logged in`)
	//ErrUserNotFound 用户不存在
	ErrUserNotFound = errors.New(`User does not exist`)
	//ErrUserNoPerm 用户无权限
	ErrUserNoPerm = errors.New(`User has no permission`)
	//ErrUserDisabled 用户已被禁用
	ErrUserDisabled = errors.New(`User has been disabled`)

	// ErrIgnoreConfigChange 忽略配置文件更改
	ErrIgnoreConfigChange = errors.New(`Ingore file`)
)
View Source
var (
	// PageMaxSize 每页最大数据量
	PageMaxSize = 1000

	// Sorts 获取数据查询时的排序方式
	Sorts = clientPagination.Sorts
)
View Source
var LogParsers = map[string]func(line *tail.Line) (interface{}, error){}

LogParsers 日志格式解析器

Functions

func CaptchaInfo

func CaptchaInfo(hostAlias string, captchaName string, args ...string) echo.H

CaptchaInfo 新验证码信息

func DirSharding

func DirSharding(id uint64) uint64

DirSharding 文件夹分组(暂不使用)

func Err

func Err(ctx echo.Context, err error) (ret interface{})

Err 获取错误信息

func IsError

func IsError(err interface{}) bool

IsError 是否是错误信息

func IsMessage

func IsMessage(err interface{}) bool

IsMessage 判断err是否为Message

func IsOk

func IsOk(err interface{}) bool

IsOk 是否是成功信息

func IsRightUploadFile

func IsRightUploadFile(ctx echo.Context, src string) error

IsRightUploadFile 是否是正确的上传文件

func IsUserDisabled

func IsUserDisabled(err error) bool

IsUserDisabled 用户是否被禁用

func IsUserNoPerm

func IsUserNoPerm(err error) bool

IsUserNoPerm 用户是否没有操作权限

func IsUserNotFound

func IsUserNotFound(err error) bool

IsUserNotFound 用户是否不存在

func IsUserNotLoggedIn

func IsUserNotLoggedIn(err error) bool

IsUserNotLoggedIn 用户是否未登录

func LogShow

func LogShow(ctx echo.Context, logFile string, extensions ...echo.H) error

LogShow 获取日志内容用于显示

func ModifyAsThumbnailName

func ModifyAsThumbnailName(originName, thumbnailName string) string

ModifyAsThumbnailName 将指向临时文件夹的缩略图路径改为新位置上的缩略图路径 originName 为新位置上的原始图路径 thumbnailName 为临时位置上的缩略图路径

func MoveAvatarToUserDir

func MoveAvatarToUserDir(ctx echo.Context, src string, typ string, id uint64) (string, error)

MoveAvatarToUserDir 移动临时文件夹中的头像到用户目录

func MoveEmbedTemporaryFiles

func MoveEmbedTemporaryFiles(ctx echo.Context, content string, typ string, id uint64) (int, string, error)

MoveEmbedTemporaryFiles 转移被嵌入到文本内容中临时文件

func MoveUploadedFileToOwnerDir

func MoveUploadedFileToOwnerDir(ctx echo.Context, src string, typ string, id uint64) (string, error)

MoveUploadedFileToOwnerDir 移动上传的文件到所有者目录

func OkString

func OkString(err interface{}) string

OkString 获取成功信息

func Paging

func Paging(ctx echo.Context) (page int, size int)

Paging 获取当前页码和每页数据量

func PagingWithLister

func PagingWithLister(ctx echo.Context, m Lister, varSuffix ...string) (*pagination.Pagination, error)

PagingWithLister 通过分页查询接口获取分页信息

func PagingWithListerCond

func PagingWithListerCond(ctx echo.Context, m Lister, cond db.Compound, varSuffix ...string) (*pagination.Pagination, error)

PagingWithListerCond 通过分页查询接口和附加条件获取分页信息

func PagingWithPagination

func PagingWithPagination(ctx echo.Context, delKeys ...string) (page int, size int, totalRows int, p *pagination.Pagination)

PagingWithPagination 获取分页信息

func PagingWithSelectList

func PagingWithSelectList(ctx echo.Context, param *factory.Param, varSuffix ...string) (*pagination.Pagination, error)

PagingWithSelectList 通过Select查询参数获取分页信息

func ReadCache

func ReadCache(dir string, name string) (content []byte, err error)

ReadCache 读缓存文件

func RemoveAvatar

func RemoveAvatar(typ string, id uint64) error

RemoveAvatar 删除头像

func RemoveCache

func RemoveCache(dir string, names ...string) (err error)

RemoveCache 删除缓存文件

func RemoveUploadedFile

func RemoveUploadedFile(typ string, id uint64) error

RemoveUploadedFile 删除被上传的文件

func Replacex

func Replacex(s string, oldAndNew map[string]string) string

Replacex 根据map替换

func SendErr

func SendErr(ctx echo.Context, err error)

SendErr 记录错误信息 (SendFail的别名)

func SendFail

func SendFail(ctx echo.Context, msg string)

SendFail 记录失败信息

func SendOk

func SendOk(ctx echo.Context, msg string)

SendOk 记录成功信息

func VerifyAndSetCaptcha

func VerifyAndSetCaptcha(ctx echo.Context, hostAlias string, captchaName string, args ...string) echo.Data

VerifyAndSetCaptcha 验证码验证并设置新验证码信息

func VerifyCaptcha

func VerifyCaptcha(ctx echo.Context, hostAlias string, captchaName string, args ...string) echo.Data

VerifyCaptcha 验证码验证

func WriteCache

func WriteCache(dir string, name string, content []byte) (err error)

WriteCache 写缓存文件

Types

type List

type List struct {
	*ListParam
	// contains filtered or unexported fields
}

List 页码分页列表封装

func NewLister

func NewLister(list Lister, recv interface{}, mw func(db.Result) db.Result, args ...interface{}) *List

NewLister 创建页码分页列表查询

func (*List) DataGrid

func (f *List) DataGrid(ctx echo.Context, searchField string, args ...string) (map[string]interface{}, error)

DataGrid 分页信息

func (*List) DataTable

func (f *List) DataTable(ctx echo.Context, args ...string) (map[string]interface{}, error)

DataTable 分页信息

func (*List) List

func (f *List) List(recv interface{}, mw func(db.Result) db.Result, page, size int, args ...interface{}) (func() int64, error)

List 分页查询

func (*List) Paging

func (f *List) Paging(ctx echo.Context, varSuffix ...string) (*pagination.Pagination, error)

Paging 分页信息

type ListFunc

type ListFunc = PageListFunc

ListFunc PageListFunc别名

type ListParam

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

ListParam 列表参数

func NewListParam

func NewListParam(recv interface{}, mw func(db.Result) db.Result, args ...interface{}) *ListParam

NewListParam 列表参数

func (*ListParam) AddCond

func (f *ListParam) AddCond(args ...interface{})

AddCond 添加条件

func (*ListParam) AddMiddleware

func (f *ListParam) AddMiddleware(mw ...func(db.Result) db.Result)

AddMiddleware 添加中间件

func (*ListParam) Conds

func (f *ListParam) Conds() []interface{}

Conds 获取条件

func (*ListParam) Middleware

func (f *ListParam) Middleware() func(db.Result) db.Result

Middleware 获取中间件

func (*ListParam) Model

func (f *ListParam) Model() interface{}

Model 模型实例

func (*ListParam) SetConds

func (f *ListParam) SetConds(args []interface{})

SetConds 设置条件

type Lister

type Lister interface {
	List(recv interface{}, mw func(db.Result) db.Result, page, size int, args ...interface{}) (func() int64, error)
}

Lister 页码分页列表查询接口

type Messager

type Messager interface {
	Successor
	error
}

Messager 信息接口

var DefaultNopMessage Messager = &NopMessage{}

DefaultNopMessage 默认空消息

func Message

func Message(err interface{}) Messager

Message 获取err中的信息接口

type NopMessage

type NopMessage struct {
}

NopMessage 空消息

func (*NopMessage) Error

func (n *NopMessage) Error() string

Error 错误信息

func (*NopMessage) String

func (n *NopMessage) String() string

String 信息字符串

func (*NopMessage) Success

func (n *NopMessage) Success() string

Success 成功信息

type OffsetList

type OffsetList struct {
	*ListParam
	// contains filtered or unexported fields
}

OffsetList 偏移值分页列表查询封装

func NewOffsetLister

func NewOffsetLister(list OffsetLister, recv interface{}, mw func(db.Result) db.Result, args ...interface{}) *OffsetList

NewOffsetLister 创建偏移值分页列表查询

func (*OffsetList) ChunkList

func (f *OffsetList) ChunkList(eachPageCallback func() error, size int, offset int) error

ChunkList 分批查询列表

func (*OffsetList) DataGrid

func (f *OffsetList) DataGrid(ctx echo.Context, searchField string, args ...string) (map[string]interface{}, error)

DataGrid 分页信息

func (*OffsetList) DataTable

func (f *OffsetList) DataTable(ctx echo.Context, args ...string) (map[string]interface{}, error)

DataTable 分页信息

func (*OffsetList) ListByOffset

func (f *OffsetList) ListByOffset(recv interface{}, mw func(db.Result) db.Result, offset, size int, args ...interface{}) (func() int64, error)

ListByOffset 分页查询

type OffsetListFunc

type OffsetListFunc func(recv interface{}, mw func(db.Result) db.Result, pageOrOffset, size int, args ...interface{}) (func() int64, error)

OffsetListFunc 偏移列表函数

func (OffsetListFunc) ListByOffset

func (f OffsetListFunc) ListByOffset(recv interface{}, mw func(db.Result) db.Result, offset, size int, args ...interface{}) (func() int64, error)

ListByOffset 实现OffsetLiser接口

type OffsetLister

type OffsetLister interface {
	ListByOffset(recv interface{}, mw func(db.Result) db.Result, offset, size int, args ...interface{}) (func() int64, error)
}

OffsetLister 偏移值分页列表查询接口

type PageListFunc

type PageListFunc func(recv interface{}, mw func(db.Result) db.Result, page, size int, args ...interface{}) (func() int64, error)

PageListFunc 分页列表函数

func (PageListFunc) List

func (f PageListFunc) List(recv interface{}, mw func(db.Result) db.Result, page, size int, args ...interface{}) (func() int64, error)

List 实现Lister接口

type StatusColor

type StatusColor string

StatusColor 状态色

func HTTPStatusColor

func HTTPStatusColor(httpCode int) StatusColor

HTTPStatusColor HTTP状态码相应颜色

func (StatusColor) Bootstrap

func (s StatusColor) Bootstrap() string

Bootstrap 前端框架 bootstrap css 状态样式

func (StatusColor) String

func (s StatusColor) String() string

func (StatusColor) Terminal

func (s StatusColor) Terminal() func(string, ...interface{})

Terminal 控制台样式

type Success

type Success struct {
	Value string
}

Success 成功信息

func (*Success) String

func (s *Success) String() string

func (*Success) Success

func (s *Success) Success() string

Success 成功信息

type Successor

type Successor interface {
	Success() string
}

Successor 成功信息接口

func NewOk

func NewOk(v string) Successor

NewOk 创建成功信息

func Ok

func Ok(v string) Successor

Ok 操作成功

Directories

Path Synopsis
client

Jump to

Keyboard shortcuts

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