Documentation
¶
Index ¶
- Constants
- Variables
- func GetSuperAdminUsers() []uint64
- func InitAppConf(configPath string)
- func InitDBConf(configPath string)
- func IsSuperAdmin(user uint64) bool
- func LoadAdmin(configPath string)
- func SaveAdminConfig()
- func SaveAppConfig()
- func SaveDBConfig()
- func SetSuperAdminUsers(users []uint64)
- type AppConfig
- type AuthorizeCfg
- type AuthorizeCookie
- type DBConfig
- type DBlink
- type DefUser
- type DefUsers
- type LoginPageVerifyCode
- type Response
- type UploadCfg
Constants ¶
View Source
const ( SUCCESS = 1 //操作成功 LoginSucess = 2 //登录成功 ERROR = 100101 //"操作失败" ParamsError = 100102 //参数错误 NoResult = 100103 //没有结果 NotFound = 100104 //没有结果 ServiceError = 100105 //服务器错误 NoRule = 100106 //没有权限 CehckCodeError = 100107 //验证码错误 VerifyFail = 100108 //参数签名验证失败 DbError = 100109 //数据访问错误 FiledRepeat = 100110 //字段重复 NoLogin = 100201 //用户未登录 TokenNotExist = 100202 //令牌不存在 TokenFail = 100203 //令牌错误 UserLocck = 100204 //用户锁定 LoginIdError = 100205 //登录id错误 LoginPassError = 100206 //密码错误 LoginFail = 100207 //登录失败 UserNameExisit = 100208 //用户名已存在 EmailExisit = 100209 //邮箱已存在 PhoneExisit = 100210 //手机号已存在 CreditNotEnough = 100301 //余额不足 GoodsInvalid = 100302 //商品已失效 PayError = 100303 //支付失败 )
View Source
const Context_UserId = "Context_UserId"
上下文中存储用户ID的键
View Source
const Context_UserInfo = "Context_UserInfo"
上下文中存储用户信息的键
View Source
const URL_BACK = "url://back"
返回上一个页面
View Source
const URL_CURRENT = "url://current"
不做任何操作
View Source
const URL_RELOAD = "url://reload"
刷新页面
Variables ¶
View Source
var AdminCacheName string
AdminCacheName admin缓存名称
View Source
var AdminCatalog string
AdminCatalog admin缓存类别
View Source
var TokenHelper *loginToken.TokenHelper
Functions ¶
func InitAppConf ¶
func InitAppConf(configPath string)
func InitDBConf ¶
func InitDBConf(configPath string)
func SaveAppConfig ¶
func SaveAppConfig()
func SaveDBConfig ¶
func SaveDBConfig()
Types ¶
type AppConfig ¶
type AppConfig struct { Name string `json:"name" yaml:"name"` // 应用名称 WebPort int `json:"webport" yaml:"webport"` //web服务监听端口 RunMode string `json:"runmode" yaml:"runmode"` //运行模式 dev prod test EnableGzip bool `json:"enablegzip" yaml:"enablegzip"` //是否启用gzip ContextPath string `json:"contextpath" yaml:"contextpath"` //虚拟路径 JSPath string `json:"jspath" yaml:"jspath"` //js访问路径 CSSPath string `json:"csspath" yaml:"csspath"` //css访问路径 ImagePath string `json:"imagepath" yaml:"imagepath"` //image访问路径 FilePath string `json:"filepath" yaml:"filepath"` //file访问路径 Cache map[string]string `json:"cache" yaml:"cache"` //缓存catalog 及 CacheName Authorize *AuthorizeCfg `json:"authorize" yaml:"authorize"` //登录认证相关配置 SnowflakeWorkID uint16 `json:"snowflakeWorkID" yaml:"snowflakeWorkID"` //全局唯一ID工作节点(雪花算法节点)0 ~ 65535 Upload *UploadCfg `json:"upload" yaml:"upload"` //上传文件设置 }
AppConfig 应用配置
var AppConf *AppConfig
type AuthorizeCfg ¶
type AuthorizeCfg struct { LoginUrl string `json:"loginUrl" yaml:"loginUrl"` //登录页面的url LoginRefParam string `json:"loginRefParam" yaml:"loginRefParam"` //跳转登录页面的携带源url的参数名 Multilogin bool `json:"multilogin" yaml:"multilogin"` //是否允许一个账号多人同时登录 是true 否false VerifyCode LoginPageVerifyCode `json:"verifyCode" yaml:"verifyCode"` //登录页验证码 Cookie AuthorizeCookie `json:"cookie" yaml:"cookie"` }
登录认证相关配置
type AuthorizeCookie ¶
type AuthorizeCookie struct { Domain string `json:"domain" yaml:"domain"` //令牌作用的域名,设置为abc.com对a.abc.com、b.abc.com均有效,设置a.abc.com对b.abc.com无效。cookie的作用域参加w3c,如果设置0.0.0.0则代表默认域名 LoginToken string `json:"loginToken" yaml:"loginToken"` //认证令牌在cookie中的名称 LoginTokenAesKey string `json:"loginTokenAesKey" yaml:"loginTokenAesKey"` //认证令牌aes加密key }
登录认证cookie
type DBConfig ¶
type DBConfig struct { DBType string `json:"db_type" yaml:"db_type"` // 数据库类型 DBDtPrefix string `json:"db_dt_prefix" yaml:"db_dt_prefix"` // 数据库表名前辍 DBLog bool `json:"db_log" yaml:"db_log"` // 日志 SkipDefaultTransaction bool `json:"db_skip_default_transaction" yaml:"db_skip_default_transaction"` // 是否禁用事务(有助于提高性能) MaxIdleConns int `json:"db_max_idle_conns" yaml:"db_max_idle_conns"` // 设置空闲连接池中的最大连接数 MaxOpenConns int `json:"db_max_open_conns" yaml:"db_max_open_conns"` // 数据库的最大打开连接数 ConnMaxLifetime int `json:"db_conn_max_life_time" yaml:"db_conn_max_life_time"` // 连接最长存活期,超过这个时间连接将不再被复用 单位秒 SlowThreshold int64 `json:"slow_threshold" yaml:"slow_threshold"` //慢查询阈值 0不记录 单位秒 Postgres DBlink `json:"postgres" yaml:"postgres"` Mysql DBlink `json:"mysql" yaml:"mysql"` Sqlite3 DBlink `json:"sqlite3" yaml:"sqlite3"` }
DBConfig 数据库配置
var DBConf *DBConfig
type DBlink ¶
type DBlink struct { DBName string `json:"db_name" yaml:"db_name"` // 连接数据库 DBUser string `json:"db_user" yaml:"db_user"` // 连接用户 DBPWD string `json:"db_pwd" yaml:"db_pwd"` // 连接密码 DBHost string `json:"db_host" yaml:"db_host"` // 连接地址 DBPort int `json:"db_port" yaml:"db_port"` // 连接端口 DBCharset string `json:"db_charset" yaml:"db_charset"` // 字符集 }
DBlink 数据库连接
type DefUser ¶
type DefUser struct { ID uint64 `json:"id" yaml:"id"` Alias string `json:"alias" yaml:"alias"` SuperAdmin bool `json:"superadmin" yaml:"superadmin"` UserName string `json:"username" yaml:"username"` Phone string `json:"phone" yaml:"phone"` Email string `json:"email" yaml:"email"` }
DefUser 默认用户信息
type DefUsers ¶
type DefUsers struct {
Users []DefUser `json:"users" yaml:"users"`
}
var Admins *DefUsers
type LoginPageVerifyCode ¶
type LoginPageVerifyCode struct { Enable bool `json:"enable" yaml:"enable"` //登录时是否启用验证码 Method string `json:"method" yaml:"method"` //认证方式 1:数字,2:字母,3:算术,4:数字字母混合. }
登录页验证码
type Response ¶
type Response struct { Code int `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data"` Url string `json:"url"` Wait int `json:"wait"` AllCount int64 `json:"allcount"` }
响应参数结构体
type UploadCfg ¶
type UploadCfg struct { MaxRequestSize string `json:"maxRequestSize" yaml:"maxRequestSize"` // 上传文件内存限制 VisitDomain string `json:"visitDomain" yaml:"visitDomain"` // 上传图片后访问的域名 VisitPath string `json:"visitPath" yaml:"visitPath"` // 上传图片后的访问路径 SavePath string `json:"savePath" yaml:"savePath"` // 保存路径 UploadRemote bool `json:"uploadRemote" yaml:"uploadRemote"` // 是否上传到远程服务器 否false 是true RemoteUploadUrl string `json:"remoteUploadUrl" yaml:"remoteUploadUrl"` // 文件站点服务器的接口地址 RemoteUploadkey string `json:"remoteUploadkey" yaml:"remoteUploadkey"` // 接口key }
func (*UploadCfg) GetMaxRequestSize ¶
Click to show internal directories.
Click to hide internal directories.