package utils import ( "fmt" "github.com/beego/beego/v2/server/web" "github.com/rdlucklib/rdluck_tools/cache" "strconv" ) var ( RunMode string //运行模式 MYSQL_URL string //数据库连接 MYSQL_URL_CYGX string // 查研观向 REDIS_CACHE string //缓存地址 Rc *cache.Cache //redis缓存 Re error //redis错误 ) // 微信配置信息 var ( WxId string //微信原始ID WxAppId string //买方研选小程序 WxAppSecret string //买方研选小程序 WxPlatform = 12 // 注册平台:1-日度点评公众号; 2-管理后台; 3-PC端网站; 4-查研观向小程序; 6-研报小程序; 7-查研观向开发平台; 8-查研观向小助手公众号; 9-研报备用小程序,10:买方研选小程序(权益),11:买方研选网页版(权益)12买方研选公众号', WxPublicAppId string //买方研选公众号 WxPublicAppSecret string //买方研选公众号 HeadimgurlDefault string //默认头像 ) // 日志配置 var ( LogPath string //调用过程中的日志存放地址 LogFile string LogDataPath string //调用过程中图表相关的日志存放地址 LogDataFile string BinLogPath string //数据库相关的日志存放地址 BinLogFile string ApiLogPath string //接口请求地址和接口返回值日志存放地址 ApiLogFile string LogMaxDays int //日志最大保留天数 ) 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_mfyx_gzh/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_CYGX = config["mysql_url_cygx"] 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 = "wx2f85cdbe74585222" //买方研选 WxPublicAppSecret = "98e4a09c9ba6a0b34e0df3192ba1aba3" //买方研选 WxId = "gh_38912ddf5884" //买方研选公众号原始ID } else { WxPublicAppId = "wx9b5d7291e581233a" //弘则投研公众号 开发者ID(AppID) WxPublicAppSecret = "f4d52e34021eee262dce9682b31f8861" //弘则投研公众号秘钥 WxId = "gh_5dc508325c6f" //弘则投研公众号原始ID } HeadimgurlDefault = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202202/20220225/XFBBOUmDC5AXkfxnHiuqKpPtoofH.png" //日志配置 { LogPath = config["log_path"] LogFile = config["log_file"] LogDataPath = config["log_data_path"] LogDataFile = config["log_data_file"] BinLogPath = config["binlog_path"] BinLogFile = config["binlog_file"] ApiLogPath = config["apilog_path"] ApiLogFile = config["apilog_file"] logMaxDaysStr := config["log_max_day"] LogMaxDays, _ = strconv.Atoi(logMaxDaysStr) } } //http://webapi.brilliantstart.cn/api/ //http://webapi.brilliantstart.cn/swagger/ //http://139.196.122.219:8603/swagger/