Documentation ¶
Index ¶
- Constants
- func FailWithCode(code int, c *gin.Context)
- func FailWithDetailed(code int, data interface{}, message string, c *gin.Context)
- func FailWithMessage(code int, message string, c *gin.Context)
- func Ok(c *gin.Context)
- func OkWithData(data interface{}, c *gin.Context)
- func OkWithDetailed(data interface{}, message string, c *gin.Context)
- func OkWithMessage(message string, c *gin.Context)
- func Result(code int, data interface{}, msg string, c *gin.Context)
- type AliyunOSS
- type ByID
- type ByIDS
- type Config
- type Email
- type Environment
- type Etcd
- type HuaWeiObs
- type Local
- type Log
- type Mysql
- type Notify
- type PageInfo
- type PageResult
- type Qiniu
- type Redis
- type Response
- type System
- type TencentCOS
- type Upload
- type WebHook
Constants ¶
View Source
const ( EnvTesting = Environment("testing") EnvProduction = Environment("production") )
use export ENVIRONMENT=testing set global environment
View Source
const ( SUCCESS = 200 ERROR = 1000 ErrorRequestParameter = 1001 ErrorTokenGenerate = 1002 ErrorUserNameExist = 1003 )
View Source
const ( Version = "v1.1.0" ApiModule = "common/api-server" )
Variables ¶
This section is empty.
Functions ¶
func FailWithCode ¶
func FailWithDetailed ¶
func OkWithData ¶
func OkWithDetailed ¶
func OkWithMessage ¶
Types ¶
type AliyunOSS ¶ added in v1.2.0
type AliyunOSS struct { Endpoint string `mapstructure:"endpoint" json:"endpoint" yaml:"endpoint" ini:"endpoint"` AccessKeyId string `mapstructure:"access-key-id" json:"access-key-id" yaml:"access-key-id" ini:"access-key-id"` AccessKeySecret string `mapstructure:"access-key-secret" json:"access-key-secret" yaml:"access-key-secret" ini:"access-key-secret"` BucketName string `mapstructure:"bucket-name" json:"bucket-name" yaml:"bucket-name" ini:"bucket-name"` BucketUrl string `mapstructure:"bucket-url" json:"bucket-url" yaml:"bucket-url" ini:"bucket-url"` BasePath string `mapstructure:"base-path" json:"base-path" yaml:"base-path" ini:"base-path"` }
阿里云存储对象
func (*AliyunOSS) DeleteFile ¶ added in v1.2.0
func (*AliyunOSS) UploadFile ¶ added in v1.2.0
阿里云
type Config ¶
type Config struct { Log Log `mapstructure:"log" json:"log" yaml:"log" ini:"log"` System System `mapstructure:"system" json:"system" yaml:"system" ini:"system"` Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql" ini:"mysql"` Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis" ini:"redis"` Etcd Etcd `mapstructure:"etcd" json:"etcd" yaml:"etcd" ini:"etcd"` Notify Notify `mapstructure:"notify" json:"notify" yaml:"notify" ini:"notify"` Upload Upload `mapstructure:"upload" json:"upload" yaml:"upload" ini:"upload"` }
func GetConfigModels ¶
func GetConfigModels() *Config
func LoadConfig ¶
type Email ¶
type Email struct { Port int `mapstructure:"port" json:"port" yaml:"port" ini:"port"` // 端口 From string `mapstructure:"from" json:"from" yaml:"from" ini:"from"` // 收件人 Host string `mapstructure:"host" json:"host" yaml:"host" ini:"host"` // 服务器地址 IsSSL bool `mapstructure:"is-ssl" json:"is-ssl" yaml:"is-ssl" ini:"is-ssl"` // 是否SSL Secret string `mapstructure:"secret" json:"secret" yaml:"secret" ini:"secret"` // 密钥 Nickname string `mapstructure:"nickname" json:"nickname" yaml:"nickname" ini:"nickname"` // 昵称 To []string `mapstructure:"to" json:"to" yaml:"to" ini:"to"` }
notify
type Environment ¶
type Environment string
func NewGlobalEnvironment ¶
func NewGlobalEnvironment() (Environment, error)
NewGlobalEnvironment 读取系统全局配置的环境变量
func (Environment) Invalid ¶
func (env Environment) Invalid() bool
func (*Environment) Production ¶
func (env *Environment) Production() Environment
func (*Environment) String ¶
func (env *Environment) String() string
func (*Environment) Testing ¶
func (env *Environment) Testing() Environment
type Etcd ¶
type Etcd struct { Endpoints []string `mapstructure:"endpoints" json:"endpoints" yaml:"endpoints" ini:"endpoints"` Username string `mapstructure:"username" json:"username" yaml:"username" ini:"username"` Password string `mapstructure:"password" json:"password" yaml:"password" ini:"password"` DialTimeout int64 `mapstructure:"dial-timeout" json:"dial-timeout" yaml:"dial-timeout" ini:"dial-timeout"` ReqTimeout int64 `mapstructure:"req-timeout" json:"req-timeout" yaml:"req-timeout" ini:"req-timeout"` }
type HuaWeiObs ¶ added in v1.2.0
type HuaWeiObs struct { Path string `mapstructure:"path" json:"path" yaml:"path" ini:"path"` Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket" ini:"bucket"` Endpoint string `mapstructure:"endpoint" json:"endpoint" yaml:"endpoint" ini:"endpoint"` AccessKey string `mapstructure:"access-key" json:"access-key" yaml:"access-key" ini:"access-key"` SecretKey string `mapstructure:"secret-key" json:"secret-key" yaml:"secret-key" ini:"secret-key"` }
华为云存储对象
func (*HuaWeiObs) DeleteFile ¶ added in v1.2.0
func (*HuaWeiObs) NewHuaWeiObsClient ¶ added in v1.2.0
func (*HuaWeiObs) UploadFile ¶ added in v1.2.0
type Local ¶ added in v1.2.0
type Local struct {
Path string `mapstructure:"path" json:"path" yaml:"path" ini:"path"` // 本地文件路径
}
upload
func (*Local) DeleteFile ¶ added in v1.2.0
func (*Local) UploadFile ¶ added in v1.2.0
type Log ¶
type Log struct { Level string `mapstructure:"level" json:"level" yaml:"level" ini:"level"` // 级别 Format string `mapstructure:"format" json:"format" yaml:"format" ini:"level"` // 输出 Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix" ini:"level"` // 日志前缀 Director string `mapstructure:"director" json:"director" yaml:"director" ini:"level"` // 日志文件夹 ShowLine bool `mapstructure:"show-line" json:"showLine" yaml:"showLine" ini:"showLine"` // 显示行 EncodeLevel string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level" ini:"encode-level"` // 编码级 StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key" ini:"stacktrace-key"` // 栈名 LogInConsole bool `mapstructure:"log-in-console" json:"logInConsole" yaml:"log-in-console" ini:"log-in-console"` // 输出控制台 }
type Mysql ¶
type Mysql struct { Path string `mapstructure:"path" json:"path" yaml:"path" ini:"path"` // 服务器地址 Port string `mapstructure:"port" json:"port" yaml:"port" ini:"port"` // 端口 Config string `mapstructure:"config" json:"config" yaml:"config" ini:"config"` // 高级配置 Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name" ini:"db-name"` // 数据库名 Username string `mapstructure:"username" json:"username" yaml:"username" ini:"username"` // 数据库用户名 Password string `mapstructure:"password" json:"password" yaml:"password" ini:"password"` // 数据库密码 MaxIdleConns int `mapstructure:"max-idle-conns" json:"maxIdleConns" yaml:"max-idle-conns" ini:"max-idle-conns"` // 空闲中的最大连接数 MaxOpenConns int `mapstructure:"max-open-conns" json:"maxOpenConns" yaml:"max-open-conns" ini:"max-open-conns"` // 打开到数据库的最大连接数 LogMode string `mapstructure:"log-mode" json:"logMode" yaml:"log-mode" ini:"log-mode"` // 是否开启Gorm全局日志 LogZap bool `mapstructure:"log-zap" json:"logZap" yaml:"log-zap" ini:"log-zap"` // 是否通过zap写入日志文件 }
type Notify ¶ added in v1.2.0
type Notify struct { Email Email `mapstructure:"email" json:"email" yaml:"email" ini:"email"` WebHook WebHook `mapstructure:"webhook" json:"webhook" yaml:"webhook" ini:"webhook"` }
notify
type PageInfo ¶
type PageInfo struct { Page int `json:"page" form:"page"` // 页码 PageSize int `json:"page_size" form:"page_size"` // 每页大小 }
PageInfo Paging common input parameter structure
type PageResult ¶
type Qiniu ¶ added in v1.2.0
type Qiniu struct { Zone string `mapstructure:"zone" json:"zone" yaml:"zone" ini:"zone"` // 存储区域 Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket" ini:"bucket"` // 空间名称 ImgPath string `mapstructure:"img-path" json:"img-path" yaml:"img-path" ini:"img-path"` // CDN加速域名 UseHTTPS bool `mapstructure:"use-https" json:"use-https" yaml:"use-https" ini:"use-https"` // 是否使用https AccessKey string `mapstructure:"access-key" json:"access-key" yaml:"access-key" ini:"access-key"` // 秘钥AK SecretKey string `mapstructure:"secret-key" json:"secret-key" yaml:"secret-key" ini:"secret-key"` // 秘钥SK UseCdnDomains bool `mapstructure:"use-cdn-domains" json:"use-cdn-domains" yaml:"use-cdn-domains" ini:"use-cdn-domains"` // 上传是否使用CDN上传加速 }
七牛云存对象
func (*Qiniu) DeleteFile ¶ added in v1.2.0
func (*Qiniu) UploadBytes ¶ added in v1.2.0
七牛云 上传字节文件
func (*Qiniu) UploadFile ¶ added in v1.2.0
上传文件
type System ¶
type System struct { Env string `mapstructure:"env" json:"env" yaml:"env" ini:"env"` Addr int `mapstructure:"addr" json:"addr" yaml:"addr" ini:"addr"` UploadType string `mapstructure:"upload-type" json:"upload-type" yaml:"upload-type" ini:"upload-type"` // Oss类型 Version string `mapstructure:"version" json:"version" yaml:"version" ini:"version"` }
type TencentCOS ¶ added in v1.2.0
type TencentCOS struct { Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket" ini:"bucket"` Region string `mapstructure:"region" json:"region" yaml:"region" ini:"region"` SecretID string `mapstructure:"secret-id" json:"secret-id" yaml:"secret-id" ini:"secret-id"` SecretKey string `mapstructure:"secret-key" json:"secret-key" yaml:"secret-key" ini:"secret-key"` BaseURL string `mapstructure:"base-url" json:"base-url" yaml:"base-url" ini:"base-url"` PathPrefix string `mapstructure:"path-prefix" json:"path-prefix" yaml:"path-prefix" ini:"path-prefix"` }
腾讯云存储对象
func (*TencentCOS) DeleteFile ¶ added in v1.2.0
func (t *TencentCOS) DeleteFile(key string) error
DeleteFile delete file form COS
func (*TencentCOS) NewClient ¶ added in v1.2.0
func (t *TencentCOS) NewClient() *cos.Client
NewClient init COS client
func (*TencentCOS) UploadFile ¶ added in v1.2.0
func (t *TencentCOS) UploadFile(file *multipart.FileHeader) (string, string, error)
UploadFile upload file to COS
type Upload ¶ added in v1.2.0
type Upload struct { // oss Local Local `mapstructure:"local" json:"local" yaml:"local" ini:"local"` Qiniu Qiniu `mapstructure:"qiniu" json:"qiniu" yaml:"qiniu" ini:"qiniu"` AliyunOSS AliyunOSS `mapstructure:"aliyun-oss" json:"aliyun-oss" yaml:"aliyun-oss" ini:"aliyun-oss"` HuaWeiObs HuaWeiObs `mapstructure:"hua-wei-obs" json:"hua-wei-obs" yaml:"hua-wei-obs" ini:"hua-wei-obs"` TencentCOS TencentCOS `mapstructure:"tencent-cos" json:"tencent-cos" yaml:"tencent-cos" ini:"tencent-cos"` }
upload
Click to show internal directories.
Click to hide internal directories.