Documentation ¶
Index ¶
- Variables
- func InitValidateTrans(validate *validator.Validate) ut.Translator
- func RandCheckCode(n int) string
- func RandString(base string, n int) string
- func ServerFail(ctx *gin.Context, err error) bool
- func ServerFailf(ctx *gin.Context, code int, msg string, err error) bool
- func ServerResult(ctx *gin.Context, code int, msg string, data any, err error)
- func ServerSuccess(ctx *gin.Context, msg string, data any)
- func ShouldBind(ctx *gin.Context, obj any) bool
- func ShouldBindJSON(ctx *gin.Context, obj any) bool
- func TransError(err error) string
- func UID() string
- type DBCfgParam
- type EmailCfgParam
- type MinioCfgParam
- type MinioClient
- func (m *MinioClient) FGetObject(bucket, objectName, filePath string) error
- func (m *MinioClient) FPutObject(bucket, region, objectName, filePath string) error
- func (m *MinioClient) GetClient() *minio.Client
- func (m *MinioClient) GetObject(bucket, objectName string) ([]byte, error)
- func (m *MinioClient) MakeBucket(bucket string, region string) error
- func (m *MinioClient) PutObject(bucket, region, objectName string, file io.Reader, fileSize int64) error
- func (m *MinioClient) SetClient(cli *minio.Client)
- type RedisCfgParam
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Log *zap.SugaredLogger EmailCfg = &EmailCfgParam{} RedisCfg = &RedisCfgParam{} RedisClient *redis.Client DBCfg = &DBCfgParam{} DB *sqlx.DB MinioCfg = &MinioCfgParam{} Minio = &MinioClient{} )
View Source
var (
Trans ut.Translator
)
Functions ¶
func InitValidateTrans ¶
func InitValidateTrans(validate *validator.Validate) ut.Translator
func RandString ¶
RandString randomly generate a specified length string based on the given string 依据给定字符串生成给定长度的随机字符串
func ServerFail ¶
服务器错误,判断异常是否为空,为空返回true,非空返回false并向客户端发送服务器错误信息
func ServerFailf ¶
服务器错误,判断异常是否为空,为空返回true,非空返回false并向客户端发送服务器错误信息
func ServerResult ¶
统一响应方法
func ShouldBindJSON ¶
参数绑定封装,仅只需要判断为false则return即可
func TransError ¶
Types ¶
type DBCfgParam ¶
type DBCfgParam struct { Host string `toml:"host"` // 数据库地址 127.0.0.1:3306 User string `toml:"user"` // 数据库用户名 Password string `toml:"password"` // 数据库密码 Database string `toml:"database"` // 数据库名 Charset string `toml:"charset"` // 数据库字符集 utf8mb4 ParseTime string `toml:"parseTime"` // 是否分析时间 True Loc string `toml:"loc"` // loc Local }
func (*DBCfgParam) DSN ¶
func (dp *DBCfgParam) DSN() string
type EmailCfgParam ¶
type EmailCfgParam struct { Name string `toml:"name" xml:"name" json:"name"` // 发送者名称 MailAddr string `toml:"mailAddr" xml:"mailAddr" json:"mailAddr"` // 发送者邮箱地址 youemail@email.com SmtpAddr string `toml:"smtpAddr" xml:"smtpAddr" json:"smtpAddr"` // 邮箱服务器地址(包含端口号)非SSL协议: 例如网易的 smtp.163.com:25 HostAddr string `toml:"hostAddr" xml:"hostAddr" json:"hostAddr"` // 登录授权时服务器地址,不包含端口号: 例如网易的 smtp.163.com Password string `toml:"password" xml:"password" json:"password"` // 发送者邮箱授权密钥 IsStatus bool // 是否启用 }
邮箱配置
type MinioCfgParam ¶
type MinioCfgParam struct { EndPoint string `toml:"endPoint"` // minio服务器地址 服务ID-地址 AccessKey string `toml:"accessKey"` // minio 访问密钥 SecretKey string `toml:"secretKey"` // minio 保密密钥 UseSSL bool `toml:"useSSL"` // minio 服务协议是否使用https Bucket string `toml:"bucket"` // 文件上传使用的桶 }
MinioCfgParam minio参数配置
func (*MinioCfgParam) Connect ¶
func (mcp *MinioCfgParam) Connect() (*minio.Client, error)
type MinioClient ¶
type MinioClient struct {
// contains filtered or unexported fields
}
MinioClient minio服务
func (*MinioClient) FGetObject ¶
func (m *MinioClient) FGetObject(bucket, objectName, filePath string) error
FGetObject 获取文件
func (*MinioClient) FPutObject ¶
func (m *MinioClient) FPutObject(bucket, region, objectName, filePath string) error
FPutObject 文件上传
func (*MinioClient) GetObject ¶
func (m *MinioClient) GetObject(bucket, objectName string) ([]byte, error)
GetObject 获取文件
func (*MinioClient) MakeBucket ¶
func (m *MinioClient) MakeBucket(bucket string, region string) error
MakeBucket 创建minio桶
type RedisCfgParam ¶
type RedisCfgParam struct { Host string `toml:"host"` // 地址 127.0.0.1:6379 Password string `toml:"password"` // 密码 DB int `toml:"db"` // 默认连接库 }
Redis配置
Click to show internal directories.
Click to hide internal directories.