1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- package utils
- import (
- "fmt"
- "github.com/beego/beego/v2/server/web"
- "github.com/rdlucklib/rdluck_tools/cache"
- )
- var (
- RunMode string //运行模式
- MYSQL_URL string //数据库连接
- MYSQL_URL_RDDP string //数据库连接
- MYSQL_URL_TACTICS string
- REDIS_CACHE string //缓存地址
- Rc *cache.Cache //redis缓存
- Re error //redis错误
- )
- //微信配置信息
- var (
- WxId string //微信原始ID
- WxAppId string //查研观向小程序
- WxAppSecret string //查研观向小程序
- WxPublicAppId string //查研观向小助手公众号
- WxPublicAppSecret string //查研观向小助手公众号
- HeadimgurlDefault string //默认头像
- )
- func init() {
- tmpRunMode, err := web.AppConfig.String("run_mode")
- if err != nil {
- panic("配置文件读取run_mode错误 " + err.Error())
- }
- RunMode = tmpRunMode
- if RunMode == "" {
- localIp, err := GetLocalIP()
- fmt.Println("localIp:", localIp)
- if localIp == "10.0.0.123" {
- RunMode = "debug"
- } else {
- RunMode = "release"
- }
- configPath := `/home/code/config/hongze_clpt/conf/app.conf`
- err = web.LoadAppConfig("ini", configPath)
- if err != nil {
- fmt.Println("web.LoadAppConfig Err:" + err.Error())
- }
- }
- config, err := web.AppConfig.GetSection(RunMode)
- if err != nil {
- panic("配置文件读取错误 " + err.Error())
- }
- fmt.Println(RunMode + " 模式")
- MYSQL_URL = config["mysql_url"]
- MYSQL_URL_RDDP = config["mysql_url_rddp"]
- REDIS_CACHE = config["beego_cache"]
- if len(REDIS_CACHE) <= 0 {
- panic("redis链接参数没有配置")
- }
- Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
- if Re != nil {
- fmt.Println(Re)
- panic(Re)
- }
- if RunMode == "release" {
- WxPublicAppId = "wxb7cb8a15abad5b8e" //查研观向小助手
- WxPublicAppSecret = "f425ba2863084249722af1e2a5cfffd3" //查研观向小助手
- } else {
- WxPublicAppId = "wx9b5d7291e581233a" //弘则投研公众号 开发者ID(AppID)
- WxPublicAppSecret = "f4d52e34021eee262dce9682b31f8861" //弘则投研公众号秘钥
- }
- HeadimgurlDefault = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202202/20220225/XFBBOUmDC5AXkfxnHiuqKpPtoofH.png"
- }
- //http://webapi.brilliantstart.cn/api/
- //http://webapi.brilliantstart.cn/swagger/
- //http://139.196.122.219:8603/swagger/
|