123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- package utils
- import (
- "fmt"
- beeLogger "github.com/beego/bee/v2/logger"
- "github.com/beego/beego/v2/server/web"
- "github.com/rdlucklib/rdluck_tools/cache"
- )
- var (
- RunMode string //运行模式
- MYSQL_URL string //数据库连接
- REDIS_CACHE string //缓存地址
- Rc *cache.Cache //redis缓存
- Re error //redis错误
- )
- //微信配置信息
- var (
- WxId string //微信原始ID
- WxAppId string
- WxAppSecret string
- //内部员工公众号(弘则部门)
- AdminWxAppId string
- AdminWxAppSecret string
- //微信列表
- WxAppList map[string]string
- )
- // LibreOfficePath LibreOfficePath的地址
- var LibreOfficePath 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"
- }
- fmt.Println("RunMode:", RunMode)
- configPath := `/home/code/config/hongze_public_api/conf/app.conf`
- fmt.Println("configPath:", configPath)
- err = web.LoadAppConfig("ini", configPath)
- if err != nil {
- fmt.Println("web.LoadAppConfig Err:" + err.Error())
- }
- WxRelease()
- }
- config, err := web.AppConfig.GetSection(RunMode)
- if err != nil {
- panic("配置文件读取错误 " + err.Error())
- }
- MYSQL_URL = config["mysql_url"]
- 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)
- }
- tmpLibreOfficePath, err := web.AppConfig.String("libreOfficePath")
- if err != nil {
- panic("配置文件读取libreOfficePath错误 " + err.Error())
- }
- LibreOfficePath = tmpLibreOfficePath
- beeLogger.Log.Info(RunMode + " 模式")
- if RunMode == "release" {
- } else {
- WxDebug()
- }
- }
- //测试环境模板消息
- func WxDebug() {
- WxAppId = "wx9b5d7291e581233a"
- WxAppSecret = "f4d52e34021eee262dce9682b31f8861"
- WxId = "gh_5dc508325c6f"
- //内部员工公众号(弘则部门)
- AdminWxAppId = "wx1392111da5426e9e"
- AdminWxAppSecret = "30eceb7cf29bf2f046031155ab55d7b4"
- WxAppList = make(map[string]string)
- WxAppList[AdminWxAppId] = AdminWxAppSecret
- }
- //生产环境模板消息
- func WxRelease() {
- WxAppId = "wx4a844c734d8c8e56"
- WxAppSecret = "26c586e7ccb3c575433f0f37797b3eeb"
- WxId = "gh_b67e0049fb8c"
- //内部员工公众号(弘则部门)
- AdminWxAppId = "wx1392111da5426e9e"
- AdminWxAppSecret = "30eceb7cf29bf2f046031155ab55d7b4"
- WxAppList = make(map[string]string)
- WxAppList[AdminWxAppId] = AdminWxAppSecret
- }
|