Documentation ¶
Index ¶
- Constants
- Variables
- func AesDecrypt(cryted string, key string) (string, error)
- func AesEncrypt(orig string, key string) (string, error)
- func DbCreate(dataSourceName string, showSQL bool) *sqlx.DB
- func DbDeleteKV(ctx context.Context, tx DbExeAble, table string, keys []string, ...) (int64, error)
- func DbExecuteCountManyContent(ctx context.Context, tx DbExeAble, query string, n int, args ...interface{}) (int64, error)
- func DbExecuteCountNamedContent(ctx context.Context, tx DbExeAble, query string, argMap map[string]interface{}) (int64, error)
- func DbExecuteLastIDNamedContent(ctx context.Context, tx DbExeAble, query string, argMap map[string]interface{}) (int64, error)
- func DbGetNamedContent(ctx context.Context, tx DbExeAble, dest interface{}, query string, ...) (bool, error)
- func DbSelectNamedContent(ctx context.Context, tx DbExeAble, dest interface{}, query string, ...) error
- func DbStructGetDiff(tx DbExeAble, tableNames []string, sqlFilePath string) (string, error)
- func DbTransaction(ctx context.Context, db *sqlx.DB, f func(dbTx DbExeAble) error) error
- func DbUpdateKV(ctx context.Context, tx DbExeAble, table string, updateMap H, keys []string, ...) (int64, error)
- func DecodeHashID(salt string, minLen int, value string) (int, error)
- func DecodeHashIDs(salt string, minLen int, value string) ([]int, error)
- func EncodeHashID(salt string, minLen, id int) (string, error)
- func EncodeHashIDs(salt string, minLen int, ids []int) (string, error)
- func GetHash(in string) (string, error)
- func GetStringSize(str string, fontPath string, fontSize float64, dpi float64) (fixed.Rectangle26_6, fixed.Int26_6, error)
- func GetUUIDStr() string
- func GetWriteLinesWidthFont(content string, fontSize float64, width int, fontPath string) ([]string, error)
- func GetWriteSizeFont(content string, fontSize float64, fontPath string) (int, int, error)
- func GinDoEncRespSuccess(c *gin.Context, key string, isAll bool, data gin.H)
- func GinDoRespErr(c *gin.Context, code int64, msg string, data gin.H)
- func GinDoRespInternalErr(c *gin.Context)
- func GinDoRespSuccess(c *gin.Context, data gin.H)
- func GinFillBindError(c *gin.Context, err error)
- func GinMidRepeatReadBody(c *gin.Context)
- func GinMinTokenToUserID(tx DbExeAble, ...) func(*gin.Context)
- func GinMinTokenToUserIDRedis(tx DbExeAble, redisClient *redis.Client, ...) func(*gin.Context)
- func GinMinTokenToUserIDRedisIgnore(tx DbExeAble, redisClient *redis.Client, ...) func(*gin.Context)
- func GinRepeatReadBody(c *gin.Context) error
- func GinShouldBindRepeat(c *gin.Context, obj interface{}) error
- func IntArrToString(A []int64, denim string) string
- func Ip2long(ipAddr string) (uint32, error)
- func IsIntInSlice(arr []int64, str int64) bool
- func IsStringInSlice(arr []string, str string) bool
- func Join(joinType int64, obj string) *join
- func LogSetLevel(level zapcore.Level) error
- func LogSetToProd() error
- func PKCS7Padding(ciphertext []byte, blocksize int) []byte
- func PKCS7UnPadding(origData []byte) []byte
- func QiniuGetDownloadURL(ctx context.Context, access string, secret string, domain string, ...) string
- func QiniuTokenFrom(ctx context.Context, access string, secret string, bucket string) string
- func QiniuUploadImg(ctx context.Context, access string, secret string, bucket string, ...) error
- func RedisCreate(address string, password string, dbIndex int) *redis.Client
- func RedisGet(ctx context.Context, client *redis.Client, key string) (string, error)
- func RedisRm(ctx context.Context, client *redis.Client, key string) error
- func RedisSet(ctx context.Context, client *redis.Client, key, value string, du time.Duration) error
- func RedisSetBaseKey(v string)
- func SQLRedisGetWxToken(c context.Context, tx DbExeAble, redisClient *redis.Client, appID string, ...) (string, error)
- func SQLRedisRestWxToken(c context.Context, tx DbExeAble, redisClient *redis.Client, appID string, ...)
- func Select(columns ...string) *selectData
- func TencenSms(sdkID, sdkKey, appID, sign, templateID string, tels []string, ...) error
- func TimeGetMillisecond() int64
- func UploadToQiniu(ctx context.Context, access string, secret string, zone *storage.Zone, ...) error
- func WechatCheckSign(appSecret string, paramsMap gin.H) bool
- func WechatGetPrepay(...) (gin.H, error)
- func WechatGetSign(appSecret string, paramsMap gin.H) string
- func WriteOnImageFont(target *image.NRGBA, content string, fontSize float64, x int, y int, ...) error
- func WriteOnImageLinesFontWithGap(target *image.NRGBA, lines []string, fontSize float64, x int, y int, ...) error
- func XMLWalk(bs []byte) (map[string]interface{}, error)
- type Asc
- type DbExeAble
- type Desc
- type Eq
- type EqColumn
- type GinResp
- type H
- type LoggerAble
- type SQLMaker
- type StWeChatCbBody
- type WxAppCodeResp
- type WxAppUserInfoResp
- type WxJsCodeResp
- type XMLNode
Constants ¶
const ( // ErrorSuccess 成功 ErrorSuccess = 0 // ErrorSuccessMsg 成功 ErrorSuccessMsg = "success" // ErrorInternal 内部错误 ErrorInternal = -1 // ErrorInternalMsg 内部错误 ErrorInternalMsg = "internal" // ErrorBind 输入绑定错误 ErrorBind = -2 // ErrorBindMsg 输入绑定错误 ErrorBindMsg = "input bind" ErrorToken = -1000 ErrorTokenMsg = "token error" )
const (
JoinTypeInner = 1
)
Variables ¶
var GinRespInternalErr = GinResp{ ErrCode: ErrorInternal, ErrMsg: ErrorInternalMsg, }
GinRespInternalErr 成功返回
var GinRespSuccess = GinResp{ ErrCode: ErrorSuccess, ErrMsg: ErrorSuccessMsg, }
GinRespSuccess 成功返回
var ZapLog *zap.Logger
ZapLog zap日志对象
Functions ¶
func AesDecrypt ¶ added in v0.1.22
AesDecrypt aes解密
func AesEncrypt ¶ added in v0.1.22
AesEncrypt 加密
func DbDeleteKV ¶ added in v0.1.60
func DbDeleteKV(ctx context.Context, tx DbExeAble, table string, keys []string, values []interface{}) (int64, error)
DbDeleteKV 删除
func DbExecuteCountManyContent ¶
func DbExecuteCountManyContent(ctx context.Context, tx DbExeAble, query string, n int, args ...interface{}) (int64, error)
DbExecuteCountManyContent 返回sql语句并返回执行行数
func DbExecuteCountNamedContent ¶
func DbExecuteCountNamedContent(ctx context.Context, tx DbExeAble, query string, argMap map[string]interface{}) (int64, error)
DbExecuteCountNamedContent 执行sql语句返回执行个数
func DbExecuteLastIDNamedContent ¶
func DbExecuteLastIDNamedContent(ctx context.Context, tx DbExeAble, query string, argMap map[string]interface{}) (int64, error)
DbExecuteLastIDNamedContent 执行sql语句并返回lastID
func DbGetNamedContent ¶
func DbGetNamedContent(ctx context.Context, tx DbExeAble, dest interface{}, query string, argMap map[string]interface{}) (bool, error)
DbGetNamedContent 执行sql查询并返回当个元素
func DbSelectNamedContent ¶
func DbSelectNamedContent(ctx context.Context, tx DbExeAble, dest interface{}, query string, argMap map[string]interface{}) error
DbSelectNamedContent 执行sql查询并返回多行
func DbStructGetDiff ¶ added in v0.1.34
DbStructGetDiff 获取数据库更新指令
func DbTransaction ¶ added in v0.1.56
DbTransaction 执行事物
func DbUpdateKV ¶ added in v0.1.58
func DbUpdateKV(ctx context.Context, tx DbExeAble, table string, updateMap H, keys []string, values []interface{}) (int64, error)
DbUpdateKV 更新
func DecodeHashID ¶ added in v0.1.10
DecodeHashID 解析hash id
func DecodeHashIDs ¶ added in v0.1.13
DecodeHashIDs 解析hash id
func EncodeHashID ¶ added in v0.1.10
EncodeHashID 获取hash id
func EncodeHashIDs ¶ added in v0.1.13
EncodeHashIDs 获取hash id
func GetStringSize ¶ added in v0.1.74
func GetStringSize(str string, fontPath string, fontSize float64, dpi float64) (fixed.Rectangle26_6, fixed.Int26_6, error)
GetStringSize 获取制定字体文字大小
func GetWriteLinesWidthFont ¶ added in v0.1.74
func GetWriteLinesWidthFont(content string, fontSize float64, width int, fontPath string) ([]string, error)
GetWriteLinesWidthFont 获取行数
func GetWriteSizeFont ¶ added in v0.1.73
GetWriteSizeFont 获取指定字体的文字大小
func GinDoEncRespSuccess ¶ added in v0.1.23
GinDoEncRespSuccess 返回成功信息
func GinDoRespErr ¶ added in v0.1.9
GinDoRespErr 返回特殊错误
func GinDoRespInternalErr ¶ added in v0.1.9
GinDoRespInternalErr 返回错误信息
func GinDoRespSuccess ¶ added in v0.1.9
GinDoRespSuccess 返回成功信息
func GinFillBindError ¶
GinFillBindError 检测gin输入绑定错误
func GinMidRepeatReadBody ¶ added in v0.1.68
GinMidRepeatReadBody 创建可重复度body
func GinMinTokenToUserID ¶ added in v0.1.37
func GinMinTokenToUserID(tx DbExeAble, getUserIDByToken func(ctx context.Context, tx DbExeAble, token string) (int64, error)) func(*gin.Context)
GinMinTokenToUserID token转换为user_id
func GinMinTokenToUserIDRedis ¶ added in v0.1.51
func GinMinTokenToUserIDRedis(tx DbExeAble, redisClient *redis.Client, getUserIDByToken func(ctx context.Context, tx DbExeAble, redisClient *redis.Client, token string) (int64, error)) func(*gin.Context)
GinMinTokenToUserIDRedis token转换为user_id
func GinMinTokenToUserIDRedisIgnore ¶ added in v0.1.79
func GinMinTokenToUserIDRedisIgnore(tx DbExeAble, redisClient *redis.Client, getUserIDByToken func(ctx context.Context, tx DbExeAble, redisClient *redis.Client, token string) (int64, error)) func(*gin.Context)
GinMinTokenToUserIDRedisIgnore token转换为user_id
func GinShouldBindRepeat ¶ added in v0.1.3
GinShouldBindRepeat 可重复绑定参数
func IntArrToString ¶ added in v0.1.17
IntArrToString 数组转换
func IsStringInSlice ¶
IsStringInSlice 字符串是否在数组中
func PKCS7Padding ¶ added in v0.1.22
PKCS7Padding 补码
func PKCS7UnPadding ¶ added in v0.1.22
PKCS7UnPadding 去码
func QiniuGetDownloadURL ¶ added in v0.1.12
func QiniuGetDownloadURL(ctx context.Context, access string, secret string, domain string, fileKey string, deadline int64) string
QiniuGetDownloadURL 获取私有下载链接
func QiniuTokenFrom ¶ added in v0.1.70
QiniuTokenFrom 获取上传token
func QiniuUploadImg ¶ added in v0.1.75
func QiniuUploadImg(ctx context.Context, access string, secret string, bucket string, fileKey string, img image.Image) error
QiniuUploadImg 上传到qiniu
func RedisCreate ¶ added in v0.1.47
RedisCreate 创建数据库
func SQLRedisGetWxToken ¶ added in v0.1.53
func SQLRedisGetWxToken(c context.Context, tx DbExeAble, redisClient *redis.Client, appID string, funcSQLGetToken func(context.Context, DbExeAble, string) (string, string, int64, error), funcSQLSetToken func(context.Context, DbExeAble, string, string, string, int64) error, ) (string, error)
SQLRedisGetWxToken 获取小程序token
func SQLRedisRestWxToken ¶ added in v0.1.53
func SQLRedisRestWxToken(c context.Context, tx DbExeAble, redisClient *redis.Client, appID string, funcSQLResetToken func(context.Context, DbExeAble, string) error, )
SQLRedisRestWxToken 重置小程序token
func TencenSms ¶ added in v0.1.6
func TencenSms(sdkID, sdkKey, appID, sign, templateID string, tels []string, templateParam []string) error
TencenSms 发送短信
func UploadToQiniu ¶ added in v0.1.11
func UploadToQiniu(ctx context.Context, access string, secret string, zone *storage.Zone, bucket string, fileKey string, bs []byte) error
UploadToQiniu 上传到qiniu
func WechatCheckSign ¶ added in v0.1.31
WechatCheckSign 检查签名
func WechatGetPrepay ¶ added in v0.1.31
func WechatGetPrepay(appID, mchID, mchKey, payBody, outTradeNo, clientIP, cbURL, tradeType, openID string, totalFee int64) (gin.H, error)
WechatGetPrepay 获取预支付信息
func WechatGetSign ¶ added in v0.1.31
WechatGetSign 获取签名
func WriteOnImageFont ¶ added in v0.1.72
func WriteOnImageFont(target *image.NRGBA, content string, fontSize float64, x int, y int, color color.RGBA, fontPath string) error
WriteOnImageFont 根据指定字体写入图片
Types ¶
type DbExeAble ¶
type DbExeAble interface { Rebind(string) string Get(dest interface{}, query string, args ...interface{}) error Exec(query string, args ...interface{}) (sql.Result, error) Select(dest interface{}, query string, args ...interface{}) error GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error }
DbExeAble 数据库接口
type GinResp ¶ added in v0.1.5
type GinResp struct { ErrCode int64 `json:"error"` ErrMsg string `json:"error_msg"` Data gin.H `json:"data,omitempty"` }
func GinFillSuccessData ¶ added in v0.1.8
GinFillSuccessData 填充返回数据
type LoggerAble ¶
type LoggerAble interface { Debugf(template string, args ...interface{}) Infof(template string, args ...interface{}) Warnf(template string, args ...interface{}) Errorf(template string, args ...interface{}) Fatalf(template string, args ...interface{}) }
LoggerAble 日志对象接口
var Log LoggerAble
Log 对外服务的日志对象
type StWeChatCbBody ¶ added in v0.1.31
type StWeChatCbBody struct { XMLName xml.Name `xml:"xml"` Text string `xml:",chardata"` Appid string `xml:"appid"` Attach string `xml:"attach"` BankType string `xml:"bank_type"` FeeType string `xml:"fee_type"` IsSubscribe string `xml:"is_subscribe"` MchID string `xml:"mch_id"` NonceStr string `xml:"nonce_str"` Openid string `xml:"openid"` OutTradeNo string `xml:"out_trade_no"` ResultCode string `xml:"result_code"` ReturnCode string `xml:"return_code"` Sign string `xml:"sign"` TimeEnd string `xml:"time_end"` TotalFee string `xml:"total_fee"` CouponFee string `xml:"coupon_fee"` CouponCount string `xml:"coupon_count"` CouponType string `xml:"coupon_type"` CouponID string `xml:"coupon_id"` TradeType string `xml:"trade_type"` TransactionID string `xml:"transaction_id"` }
StWeChatCbBody 回调信息
func WechatCheckCb ¶ added in v0.1.31
func WechatCheckCb(mchKey string, body []byte) (*StWeChatCbBody, error)
WechatCheckCb 验证回调
type WxAppCodeResp ¶ added in v0.1.77
type WxAppCodeResp struct { AccessToken string `json:"access_token"` ExpiresIn int64 `json:"expires_in"` RefreshToken string `json:"refresh_token"` Openid string `json:"openid"` Scope string `json:"scope"` ErrCode int64 `json:"errcode"` }
WxAppCodeResp jscode回复
func WxAppCode ¶ added in v0.1.77
func WxAppCode(appID, appSecret, code string) (*WxAppCodeResp, error)
WxAppCode app登录
type WxAppUserInfoResp ¶ added in v0.1.77
type WxAppUserInfoResp struct { Openid string `json:"openid"` Nickname string `json:"nickname"` Sex int64 `json:"sex"` Province string `json:"province"` City string `json:"city"` Country string `json:"country"` Headimgurl string `json:"headimgurl"` Unionid string `json:"unionid"` ErrCode int64 `json:"errcode"` }
WxAppUserInfoResp userinfo回复
func WxAppUserInfo ¶ added in v0.1.77
func WxAppUserInfo(accessToken, openID string) (*WxAppUserInfoResp, error)
WxAppUserInfo 用户信息
type WxJsCodeResp ¶ added in v0.1.36
type WxJsCodeResp struct { OpenID string `json:"openid"` SessionKey string `json:"session_key"` Unionid string `json:"unionid"` Errcode int64 `json:"errcode"` Errmsg string `json:"errmsg"` }
WxJsCodeResp jscode回复
func WxJsCode ¶ added in v0.1.36
func WxJsCode(appID, appSecret, code string) (*WxJsCodeResp, error)
WxJsCode js登录