123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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 //查研观向小程序
- 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_cygxzs/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 = "wxb7cb8a15abad5b8e" //查研观向小助手
- WxPublicAppSecret = "f425ba2863084249722af1e2a5cfffd3" //查研观向小助手
- WxId = "gh_ef7675f65027" //查研观向小助手公众号原始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/
|