Documentation ¶
Index ¶
- Constants
- Variables
- func BackendURL(ctx echo.Context) string
- func BatchAdd(ctx echo.Context, field string, adder Adder, before func(*string) error, ...) (added []string, err error)
- func BoolToFlag(v bool) string
- func CaptchaForm(c echo.Context, args ...interface{}) template.HTML
- func CaptchaInfo(hostAlias string, captchaName string, captchaID string, args ...string) echo.H
- func ClearHTML(title string) string
- func ContentEncode(content string, contypes ...string) string
- func CookieConfig() scookie.Config
- func Crypto() codec.Codec
- func Decrypt(secret string, datas ...*string)
- func DecryptedByRandomSecret(ctx echo.Context, sessionKey string, datas ...*string)
- func DeleteRandomSecret(ctx echo.Context, sessionKey string)
- func DirSharding(id uint64) uint64
- func Encrypt(secret string, datas ...*string)
- func Err(ctx echo.Context, err error) (ret interface{})
- func FlagToBool(v string) bool
- func Float32Sum(numbers ...float32) float32
- func Float64Sum(numbers ...float64) float64
- func FloorNumber(page int, pageSize int, index int) int
- func GenAndRecordCaptchaID(ctx echo.Context, opt *hdlCaptcha.Options) string
- func GenCaptchaError(ctx echo.Context, hostAlias string, captchaName string, id string, ...) echo.Data
- func GenPassword() (string, error)
- func GenSecret(sizes ...uint) string
- func GetBoolFlag(value string, defaults ...string) string
- func GetCaptchaID(ctx echo.Context, id string) (string, error)
- func GetContype(value string, defaults ...string) string
- func GetEnumValue(enums []string, value string, defaults string) string
- func GetErr(key string) (err error)
- func GetHistoryOrNewCaptchaID(ctx echo.Context) string
- func GetLocalIP(ver ...int) (string, error)
- func GetLocalIPs() (ipv4 []string, ipv6 []string, err error)
- func GetLocalIPv4() (ipv4 string, err error)
- func GetLocalIPv6() (ipv6 string, err error)
- func GetNowTime(ctx echo.Context) time.Time
- func HPoolGet() echo.H
- func HPoolRelease(m echo.H)
- func HTMLFilter() *bluemonday.Policy
- func IDSharding(id uint64, shardingNum float64) uint64
- func IPv4ToMachineID(ipv4 string) (uint16, error)
- func IsAnonymousMode(ownerType string) bool
- func IsCaptchaErrCode(code stdCode.Code) bool
- func IsCaptchaError(err error) bool
- func IsErr(err error, key string) bool
- func IsError(err interface{}) bool
- func IsFailureCode(code stdCode.Code) bool
- func IsMessage(err interface{}) bool
- func IsNoRetry(err error) bool
- func IsOk(err interface{}) bool
- func IsUserDisabled(err error) bool
- func IsUserNoPerm(err error) bool
- func IsUserNotFound(err error) bool
- func IsUserNotLoggedIn(err error) bool
- func JSONBytesParseError(err error, jsonBytes []byte) error
- func LogShow(ctx echo.Context, logFile string, extensions ...echo.H) error
- func LookPath(bin string, otherPaths ...string) (string, error)
- func MD5Sharding(str interface{}, length ...int) string
- func MarkdownPickoutCodeblock(content string) (repl []string, newContent string)
- func MarkdownRestorePickout(repl []string, content string) string
- func ModTimeCache(dir string, name string) (time.Time, error)
- func ModelObjects(m factory.Model) []interface{}
- func MonthSharding(ctx echo.Context) string
- func MyCleanTags(value string) string
- func MyCleanText(value string) string
- func MyRemoveXSS(content string) string
- func NewSonyflake(startDate string, machineIDs ...uint16) (*sonyflake.Sonyflake, error)
- func NewStrictPolicy() *bluemonday.Policy
- func NewUGCPolicy() *bluemonday.Policy
- func NextID(machineIDs ...uint16) (uint64, error)
- func NoLink() *bluemonday.Policy
- func NoRetry(err error) *errNoRetry
- func OkString(err interface{}) string
- func OnErrorRetry(f func() error, maxTimes int, interval time.Duration) error
- func ParseMachineIDFromEnvVar() (uint16, error)
- func ParseMysqlConnectionURL(settings *mysql.ConnectionURL)
- func ParseSQL(sqlFile string, isFile bool, installer func(string) error) (err error)
- func ProcessError(ctx echo.Context, err error) error
- func ReadCache(dir string, name string) (content []byte, err error)
- func RegisterErr(key string, err error)
- func RemoveBytesXSS(content []byte, noLinks ...bool) []byte
- func RemoveCache(dir string, names ...string) (err error)
- func RemoveReaderXSS(reader io.Reader, noLinks ...bool) *bytes.Buffer
- func RemoveXSS(content string, noLinks ...bool) string
- func ReplaceCharset(sqlStr string, charset string, checkCreateDDL ...bool) string
- func ReplacePrefix(m factory.Model, field string, oldPrefix string, newPrefix string) error
- func Retry(maxRetries int, fn func() error, stepDuration ...time.Duration) error
- func RetryBy(maxRetries int, fn func() error, stepDuration func(int) time.Duration) error
- func SQLLineParser(exec func(string) error, useCommentSQL ...bool) func(string) error
- func SeekLinesWithoutComments(r io.Reader) (string, error)
- func SendErr(ctx echo.Context, err error)
- func SendFail(ctx echo.Context, msg string)
- func SendOk(ctx echo.Context, msg string)
- func SetRandomSecret(ctx echo.Context, sessionKey string, storeKey ...string)
- func SetSonyflake(startDate string, machineIDs ...uint16) (sonyFlake *sonyflake.Sonyflake, err error)
- func Setting(group ...string) echo.H
- func SonyflakeInit(machineIDs ...uint16) *sonyflake.Sonyflake
- func SplitSingleMutibytes(content string) string
- func SplitSingleMutibytesBytes(content []byte) []byte
- func StringMapPoolGet() param.StringMap
- func StringMapPoolRelease(m param.StringMap)
- func SystemAPIKey() string
- func TemplateTags(keys ...string) echo.H
- func Tx(ctx echo.Context) factory.Transactioner
- func URLValuesPoolGet() url.Values
- func URLValuesPoolRelease(m url.Values)
- func UniqueID(machineIDs ...uint16) (string, error)
- func VerifyAndSetCaptcha(ctx echo.Context, hostAlias string, captchaName string, args ...string) echo.Data
- func VerifyCaptcha(ctx echo.Context, hostAlias string, captchaName string, args ...string) echo.Data
- func WithoutCommentsLineParser(exec func(string) error) func(string) error
- func WriteCache(dir string, name string, content []byte) (err error)
- func YearSharding(ctx echo.Context) string
- type APIKeyGetter
- type Adder
- type ConfigFromDB
- type CookieConfigGetter
- type ErrorTab
- type Errors
- type List
- type Lister
- type LogParser
- type Messager
- type NopMessage
- type OffsetListFunc
- type OffsetLister
- type PageListFunc
- type SQLQuery
- func (s *SQLQuery) CacheKey(cacheKey string) *SQLQuery
- func (s *SQLQuery) CacheTTL(ttlSeconds int64) *SQLQuery
- func (s *SQLQuery) GetFloat64(query string, args ...interface{}) (null.Float64, error)
- func (s *SQLQuery) GetInt(query string, args ...interface{}) (null.Int, error)
- func (s *SQLQuery) GetInt32(query string, args ...interface{}) (null.Int32, error)
- func (s *SQLQuery) GetInt64(query string, args ...interface{}) (null.Int64, error)
- func (s *SQLQuery) GetModel(name string, args ...interface{}) (interface{}, error)
- func (s *SQLQuery) GetModels(name string, args ...interface{}) ([]interface{}, error)
- func (s *SQLQuery) GetModelsWithPaging(name string, args ...interface{}) ([]interface{}, error)
- func (s *SQLQuery) GetRow(query string, args ...interface{}) (null.StringMap, error)
- func (s *SQLQuery) GetRows(query string, args ...interface{}) (null.StringMapSlice, error)
- func (s *SQLQuery) GetString(query string, args ...interface{}) (null.String, error)
- func (s *SQLQuery) GetUint(query string, args ...interface{}) (null.Uint, error)
- func (s *SQLQuery) GetUint32(query string, args ...interface{}) (null.Uint32, error)
- func (s *SQLQuery) GetUint64(query string, args ...interface{}) (null.Uint64, error)
- func (s *SQLQuery) GetValue(recv interface{}, query string, args ...interface{}) error
- func (s *SQLQuery) Limit(limit int) *SQLQuery
- func (s *SQLQuery) LinkID(dbLinkID int) *SQLQuery
- func (s *SQLQuery) LinkName(dbLinkName string) *SQLQuery
- func (s *SQLQuery) MustGetFloat64(query string, args ...interface{}) null.Float64
- func (s *SQLQuery) MustGetInt(query string, args ...interface{}) null.Int
- func (s *SQLQuery) MustGetInt32(query string, args ...interface{}) null.Int32
- func (s *SQLQuery) MustGetInt64(query string, args ...interface{}) null.Int64
- func (s *SQLQuery) MustGetModel(structName string, args ...interface{}) interface{}
- func (s *SQLQuery) MustGetModels(structName string, args ...interface{}) []interface{}
- func (s *SQLQuery) MustGetModelsWithPaging(structName string, args ...interface{}) []interface{}
- func (s *SQLQuery) MustGetRow(query string, args ...interface{}) null.StringMap
- func (s *SQLQuery) MustGetRows(query string, args ...interface{}) null.StringMapSlice
- func (s *SQLQuery) MustGetString(query string, args ...interface{}) null.String
- func (s *SQLQuery) MustGetUint(query string, args ...interface{}) null.Uint
- func (s *SQLQuery) MustGetUint32(query string, args ...interface{}) null.Uint32
- func (s *SQLQuery) MustGetUint64(query string, args ...interface{}) null.Uint64
- func (s *SQLQuery) Offset(offset int) *SQLQuery
- func (s *SQLQuery) OrderBy(sorts ...interface{}) *SQLQuery
- type SelectPageSortValues
- type SetContext
- type SortedURLValues
- func (s *SortedURLValues) Add(key, value string)
- func (s SortedURLValues) ApplyCond(cond *db.Compounds)
- func (s *SortedURLValues) Del(key string)
- func (s SortedURLValues) Get(key string) string
- func (s SortedURLValues) Has(key string) bool
- func (s *SortedURLValues) ParseQuery(query string) (err error)
- func (s *SortedURLValues) Set(key, value string)
- type StatusColor
- type Stringify
- type Success
- type Successor
- type URLValues
Constants ¶
const ( ConfigName = `ConfigFromFile` SettingName = `ConfigFromDB` )
const DirShardingNum = float64(50000)
DirShardingNum 文件夹分组基数
Variables ¶
var ( MustGetMyContext = defaults.MustGetContext MustGetContext = defaults.MustGetContext NewMockContext = defaults.NewMockContext )
var ( //ErrUserNotLoggedIn 用户未登录 ErrUserNotLoggedIn = echo.NewError(`User not logged in`, code.Unauthenticated) //ErrUserNotFound 用户不存在 ErrUserNotFound = echo.NewError(`User does not exist`, code.UserNotFound) //ErrUserNoPerm 用户无权限 ErrUserNoPerm = echo.NewError(`User has no permission`, code.NonPrivileged) //ErrUserDisabled 用户已被禁用 ErrUserDisabled = echo.NewError(`User has been disabled`, code.UserDisabled) //ErrBalanceNoEnough 余额不足 ErrBalanceNoEnough = echo.NewError(`Balance is not enough`, code.BalanceNoEnough) //ErrCaptcha 验证码错误 ErrCaptcha = echo.NewError(`Captcha is incorrect`, code.CaptchaError) //ErrCaptchaIdMissing 缺少captchaId ErrCaptchaIdMissing = echo.NewError(`Missing captchaId`, code.CaptchaIdMissing).SetZone(`captchaId`) //ErrInvalidAppID App ID 无效 ErrInvalidAppID = echo.NewError(`Invalid app id`, code.InvalidAppID) //ErrInvalidSign 无效签名 ErrInvalidSign = echo.NewError(`Invalid sign`, code.InvalidSignature) //ErrInvalidToken 令牌无效 ErrInvalidToken = echo.NewError(`Invalid token`, code.InvalidToken) //ErrRepeatOperation 重复操作 ErrRepeatOperation = echo.NewError(`Repeat operation`, code.RepeatOperation) //ErrUnsupported 不支持 ErrUnsupported = echo.NewError(`Unsupported`, code.Unsupported) //ErrOperationTimeout 操作超时 ErrOperationTimeout = echo.NewError(`Operation timeout`, code.OperationTimeout) //ErrOperationFail 操作失败 ErrOperationFail = echo.NewError(`Operation fail`, code.Failure) //ErrResponseFormatError 响应格式错误 ErrResponseFormatError = echo.NewError(`Response format error`, code.AbnormalResponse) //ErrRequestTimeout 提交超时 ErrRequestTimeout = echo.NewError(`Request timeout`, code.RequestTimeout) //ErrRequestFail 提交失败 ErrRequestFail = echo.NewError(`Request fail`, code.RequestFailure) // ErrIgnoreConfigChange 忽略配置文件更改 ErrIgnoreConfigChange = errors.New(`Ignore configuration file changes`) // ErrNext 需要继续向下检查 ErrNext = errors.New("Next") ErrConcurrentLock = errors.New("Concurrent lock has been triggered") ErrContextCanceled = errors.New("Context canceled") )
var ( // Sorts 获取数据查询时的排序方式 Sorts = clientPagination.Sorts Paging = dbPagination.Paging PagingWithPagination = dbPagination.PagingWithPagination PagingWithLister = dbPagination.PagingWithLister PagingWithListerCond = dbPagination.PagingWithListerCond PagingWithSelectList = dbPagination.PagingWithSelectList NewLister = dbPagination.NewLister NewListParam = dbPagination.NewListParam NewOffsetLister = dbPagination.NewOffsetLister )
var ( ErrInvalidIPAddress = errors.New("Invalid IP address") ErrNotSet = errors.New("Not set") )
var ErrorProcessors = []render.ErrorProcessor{ func(ctx echo.Context, err error) (processed bool, newErr error) { if errors.Is(err, db.ErrNoMoreRows) { return true, echo.NewError(ctx.T(`数据不存在`), stdCode.DataNotFound) } return false, err }, }
var LogParsers = map[string]LogParser{}
LogParsers 日志格式解析器
var NewErrors = errorslice.New
var SQLKeyReplacer = strings.NewReplacer("`", "``", ".", "`.`")
var (
SonyflakeStartDate = `2018-09-01 08:08:08`
)
Functions ¶
func BackendURL ¶
func BatchAdd ¶
func BatchAdd(ctx echo.Context, field string, adder Adder, before func(*string) error, seperators ...string) (added []string, err error)
BatchAdd 批量添加(常用于批量添加分类) BatchAdd(ctx, `ident,>name`, adder, before, `=`) 可以通过在字段名称前面添加“>”前缀来指定表单字段名称,如果不指定则默认使用第一个作为表单字段名
func BoolToFlag ¶
func CaptchaInfo ¶
CaptchaInfo 新验证码信息
func ContentEncode ¶
func CookieConfig ¶
func DecryptedByRandomSecret ¶
DecryptedByRandomSecret 用上次设置的随机密码解密
func DeleteRandomSecret ¶
DeleteRandomSecret 删除随机密码
func FlagToBool ¶
func Float32Sum ¶
func Float64Sum ¶
func GenAndRecordCaptchaID ¶
func GenAndRecordCaptchaID(ctx echo.Context, opt *hdlCaptcha.Options) string
func GenCaptchaError ¶
func GenPassword ¶
func GetBoolFlag ¶
func GetContype ¶
func GetLocalIPs ¶ added in v5.0.1
GetLocalIPs 获取本机网卡IP
func GetLocalIPv4 ¶ added in v5.0.1
GetLocalIPv4 获取本机网卡IPv4
func GetLocalIPv6 ¶ added in v5.0.1
GetLocalIPv6 获取本机网卡IPv6
func HPoolRelease ¶
func IPv4ToMachineID ¶
func IsAnonymousMode ¶
func IsFailureCode ¶
func JSONBytesParseError ¶
func MarkdownRestorePickout ¶
func ModTimeCache ¶
ModTimeCache 缓存文件修改时间
func ModelObjects ¶
func MyCleanTags ¶
func MyCleanText ¶
func MyRemoveXSS ¶
func NewSonyflake ¶
NewSonyflake 19位
func NewStrictPolicy ¶
func NewStrictPolicy() *bluemonday.Policy
func NewUGCPolicy ¶
func NewUGCPolicy() *bluemonday.Policy
func NoLink ¶
func NoLink() *bluemonday.Policy
func ParseMachineIDFromEnvVar ¶ added in v5.1.1
func ParseMysqlConnectionURL ¶
func ParseMysqlConnectionURL(settings *mysql.ConnectionURL)
func RegisterErr ¶
func RemoveBytesXSS ¶
func ReplaceCharset ¶
ReplaceCharset 替换DDL语句中的字符集
func ReplacePrefix ¶
ReplacePrefix 替换前缀数据
func SQLLineParser ¶
func SetRandomSecret ¶
SetRandomSecret 设置随机密码
func SetSonyflake ¶
func SonyflakeInit ¶
func SplitSingleMutibytes ¶
func StringMapPoolGet ¶
func StringMapPoolRelease ¶
func SystemAPIKey ¶
func SystemAPIKey() string
func TemplateTags ¶
func URLValuesPoolGet ¶
func URLValuesPoolRelease ¶
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 ¶
WriteCache 写缓存文件
Types ¶
type Adder ¶
type Adder interface { Set(interface{}, ...interface{}) Add() (interface{}, error) }
Adder interface
type ConfigFromDB ¶
type CookieConfigGetter ¶
type Errors ¶
type Errors = errorslice.Errors
type List ¶
type List = dbPagination.List
type Lister ¶
type Lister = dbPagination.Lister
type Messager ¶
Messager 信息接口
var DefaultNopMessage Messager = &NopMessage{}
DefaultNopMessage 默认空消息
type OffsetListFunc ¶
type OffsetListFunc = dbPagination.OffsetListFunc
type OffsetLister ¶
type OffsetLister = dbPagination.OffsetLister
type PageListFunc ¶
type PageListFunc = dbPagination.PageListFunc
type SQLQuery ¶
type SQLQuery struct {
// contains filtered or unexported fields
}
func NewSQLQuery ¶
func NewSQLQueryLimit ¶
func (*SQLQuery) GetFloat64 ¶
func (*SQLQuery) GetModelsWithPaging ¶
func (*SQLQuery) GetRows ¶
func (s *SQLQuery) GetRows(query string, args ...interface{}) (null.StringMapSlice, error)
GetRows 查询多行
func (*SQLQuery) MustGetFloat64 ¶
func (*SQLQuery) MustGetInt ¶
func (*SQLQuery) MustGetInt32 ¶
func (*SQLQuery) MustGetInt64 ¶
func (*SQLQuery) MustGetModel ¶
func (*SQLQuery) MustGetModels ¶
func (*SQLQuery) MustGetModelsWithPaging ¶
func (*SQLQuery) MustGetRow ¶
func (*SQLQuery) MustGetRows ¶
func (s *SQLQuery) MustGetRows(query string, args ...interface{}) null.StringMapSlice
func (*SQLQuery) MustGetString ¶
func (*SQLQuery) MustGetUint ¶
func (*SQLQuery) MustGetUint32 ¶
func (*SQLQuery) MustGetUint64 ¶
type SelectPageSortValues ¶ added in v5.1.0
func SelectPageCond ¶
func (SelectPageSortValues) AddToSorts ¶ added in v5.1.0
func (s SelectPageSortValues) AddToSorts(sorts []interface{}) []interface{}
func (SelectPageSortValues) IsEmpty ¶ added in v5.1.0
func (s SelectPageSortValues) IsEmpty() bool
func (SelectPageSortValues) IsMultiple ¶ added in v5.1.0
func (s SelectPageSortValues) IsMultiple() bool
func (SelectPageSortValues) OrderByString ¶ added in v5.1.0
func (s SelectPageSortValues) OrderByString() string
type SetContext ¶
type SortedURLValues ¶
type SortedURLValues []*URLValues
func NewSortedURLValues ¶
func NewSortedURLValues(query string) SortedURLValues
func (*SortedURLValues) Add ¶
func (s *SortedURLValues) Add(key, value string)
func (SortedURLValues) ApplyCond ¶
func (s SortedURLValues) ApplyCond(cond *db.Compounds)
func (*SortedURLValues) Del ¶
func (s *SortedURLValues) Del(key string)
func (SortedURLValues) Get ¶
func (s SortedURLValues) Get(key string) string
func (SortedURLValues) Has ¶
func (s SortedURLValues) Has(key string) bool
func (*SortedURLValues) ParseQuery ¶
func (s *SortedURLValues) ParseQuery(query string) (err error)
ParseQuery 解析 URL Query copy from standard library src/net/url/url.go: func parseQuery(m Values, query string) (err error)
func (*SortedURLValues) Set ¶
func (s *SortedURLValues) Set(key, value string)
type StatusColor ¶
type StatusColor string
StatusColor 状态色
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 控制台样式