config.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. package utils
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/core/logs"
  5. "github.com/beego/beego/v2/server/web"
  6. "github.com/rdlucklib/rdluck_tools/cache"
  7. "github.com/rdlucklib/rdluck_tools/log"
  8. )
  9. var (
  10. RunMode string //运行模式
  11. MYSQL_URL string //数据库连接
  12. MYSQL_URL_RDDP string //数据库连接
  13. MYSQL_URL_CYGX string // 查研观向
  14. REDIS_CACHE string //缓存地址
  15. Rc *cache.Cache //redis缓存
  16. Re error //redis错误
  17. )
  18. var ApiLog *log.Log
  19. var (
  20. Bucketname string = "hongze"
  21. Endpoint string
  22. Imghost string = "https://hongze.oss-accelerate.aliyuncs.com/"
  23. Upload_dir string = "static/images/"
  24. Upload_Audio_Dir string = "static/audio/"
  25. AccessKeyId string = "LTAIFMZYQhS2BTvW"
  26. AccessKeySecret string = "12kk1ptCHoGWedhBnKRVW5hRJzq9Fq"
  27. ResearchReportUrl = "" //旧版报告的跳转地址
  28. NewResearchReportUrl = "" //新版报告的跳转地址
  29. ReportAppid string
  30. ReportSecret string
  31. YIDONG_HONGZE_KEY string //易董加密的盐值
  32. )
  33. // 全时会议账号信息
  34. var (
  35. QsAppID string
  36. QsSecretKey string
  37. QsUserId int64
  38. QsUserName string
  39. )
  40. var EnPolicyReportUrl string
  41. // 经济数据库
  42. var (
  43. EDB_LIB_URL string
  44. )
  45. func init() {
  46. tmpRunMode, err := web.AppConfig.String("run_mode")
  47. if err != nil {
  48. panic("配置文件读取run_mode错误 " + err.Error())
  49. }
  50. RunMode = tmpRunMode
  51. fmt.Println("RunMode:", RunMode)
  52. if RunMode == "" {
  53. localIp, err := GetLocalIP()
  54. fmt.Println("localIp:", localIp)
  55. if localIp == "10.0.0.123" {
  56. RunMode = "debug"
  57. } else {
  58. RunMode = "release"
  59. }
  60. fmt.Println("RunMode:", RunMode)
  61. configPath := `/home/code/config/hongze_open_api/conf/app.conf`
  62. fmt.Println("configPath:", configPath)
  63. err = web.LoadAppConfig("ini", configPath)
  64. if err != nil {
  65. fmt.Println("web.LoadAppConfig Err:" + err.Error())
  66. }
  67. }
  68. fmt.Println(RunMode, "模式")
  69. config, err := web.AppConfig.GetSection(RunMode)
  70. if err != nil {
  71. panic("配置文件读取错误 " + err.Error())
  72. }
  73. logs.Info(RunMode + " 模式")
  74. MYSQL_URL = config["mysql_url"]
  75. MYSQL_URL_RDDP = config["mysql_url_rddp"]
  76. MYSQL_URL_CYGX = config["mysql_url_cygx"]
  77. // 初始化redis
  78. REDIS_CACHE = config["beego_cache"]
  79. if len(REDIS_CACHE) <= 0 {
  80. panic("redis链接参数没有配置")
  81. }
  82. Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
  83. if Re != nil {
  84. fmt.Println(Re)
  85. panic(Re)
  86. }
  87. //日志类
  88. if RunMode == "release" {
  89. logDir := `/data/rdlucklog/hongze_open_api`
  90. ApiLog = log.Init("20060102.api", logDir)
  91. ResearchReportUrl = "https://details.hzinsights.com/"
  92. NewResearchReportUrl = "https://details.hzinsights.com/"
  93. ReportAppid = "CQWx3EqDLNk7bVHo" //Appid
  94. ReportSecret = "vRVFCk182Hpv8CyrHsxaHhA3CgGhh4Uu" //AppSecret
  95. YIDONG_HONGZE_KEY = "YIDONG20220816VshIcFonYccA" //易董加密的盐值
  96. EnPolicyReportUrl = "https://en.hzinsights.com/v2api/"
  97. EDB_LIB_URL = "http://172.19.173.232:8300/edbapi/"
  98. } else {
  99. ApiLog = log.Init("20060102.api")
  100. ResearchReportUrl = "http://advisoryadmin.brilliantstart.cn/xcx_h5/"
  101. NewResearchReportUrl = "http://xcxh5test.hzinsights.com/xcx_h5/"
  102. ReportAppid = "VH2ou4EKlYZz58Uj" //Appid
  103. ReportSecret = "Q6Y5vwmx1IAA9OPkobl8qWvrnV7dGJ4k" //AppSecret
  104. YIDONG_HONGZE_KEY = "YIDONG20220816QxbNHiYNnnhT" //易董加密的盐值
  105. //EnPolicyReportUrl = "https://beta.internal.hzinsights.com/v2api/"
  106. EnPolicyReportUrl = "https://en.hzinsights.com/v2api/"
  107. EDB_LIB_URL = "http://8.136.199.33:8300/edbapi/"
  108. //EDB_LIB_URL = "http://127.0.0.1:8900/edbapi/"
  109. }
  110. //初始化系统用户角色map集合
  111. initRoleType()
  112. //初始化全时开放api配置
  113. initQsOpenApiConfig()
  114. }
  115. type RoleType struct {
  116. RoleId int `json:"role_id"`
  117. RoleName string `json:"role_name"`
  118. RoleType string `json:"role_type"`
  119. RoleTypeCode string `json:"role_type_code"`
  120. Role string `json:"role"`
  121. DepartmentId int `json:"department_id"`
  122. DepartmentName string `json:"department_name"`
  123. GroupId int `json:"group_id"`
  124. GroupName string `json:"group_name"`
  125. }
  126. var RoleTypeMap = map[int]RoleType{}
  127. func initRoleType() {
  128. if RunMode == "release" {
  129. RoleTypeMap[1] = RoleType{
  130. RoleId: 6,
  131. RoleName: "ficc研究员",
  132. RoleType: "ficc研究员",
  133. RoleTypeCode: "researcher",
  134. Role: "researcher",
  135. DepartmentId: 1,
  136. DepartmentName: "FICC研究部",
  137. GroupId: 8,
  138. GroupName: "无",
  139. }
  140. RoleTypeMap[2] = RoleType{
  141. RoleId: 10,
  142. RoleName: "权益研究员",
  143. RoleType: "权益研究员",
  144. RoleTypeCode: "rai_researcher",
  145. Role: "researcher",
  146. DepartmentId: 5,
  147. DepartmentName: "权益销售部",
  148. GroupId: 17,
  149. GroupName: "无",
  150. }
  151. RoleTypeMap[3] = RoleType{
  152. RoleId: 4,
  153. RoleName: "ficc销售",
  154. RoleType: "ficc销售",
  155. RoleTypeCode: "ficc_seller",
  156. Role: "sales",
  157. DepartmentId: 2,
  158. DepartmentName: "ficc销售部",
  159. GroupId: 9,
  160. GroupName: "无",
  161. }
  162. RoleTypeMap[4] = RoleType{
  163. RoleId: 5,
  164. RoleName: "权益销售",
  165. RoleType: "权益销售",
  166. RoleTypeCode: "rai_seller",
  167. Role: "sales",
  168. DepartmentId: 5,
  169. DepartmentName: "权益销售部",
  170. GroupId: 17,
  171. GroupName: "无",
  172. }
  173. } else {
  174. RoleTypeMap[1] = RoleType{
  175. RoleId: 6,
  176. RoleName: "ficc研究员",
  177. RoleType: "ficc研究员",
  178. RoleTypeCode: "researcher",
  179. Role: "researcher",
  180. DepartmentId: 1,
  181. DepartmentName: "FICC研究部",
  182. GroupId: 8,
  183. GroupName: "无",
  184. }
  185. RoleTypeMap[2] = RoleType{
  186. RoleId: 10,
  187. RoleName: "权益研究员",
  188. RoleType: "权益研究员",
  189. RoleTypeCode: "rai_researcher",
  190. Role: "researcher",
  191. DepartmentId: 5,
  192. DepartmentName: "权益销售部-王芳",
  193. GroupId: 17,
  194. GroupName: "无",
  195. }
  196. RoleTypeMap[3] = RoleType{
  197. RoleId: 4,
  198. RoleName: "ficc销售",
  199. RoleType: "ficc销售",
  200. RoleTypeCode: "ficc_seller",
  201. Role: "sales",
  202. DepartmentId: 2,
  203. DepartmentName: "ficc销售部",
  204. GroupId: 9,
  205. GroupName: "无",
  206. }
  207. RoleTypeMap[4] = RoleType{
  208. RoleId: 5,
  209. RoleName: "权益销售",
  210. RoleType: "权益销售",
  211. RoleTypeCode: "rai_seller",
  212. Role: "sales",
  213. DepartmentId: 5,
  214. DepartmentName: "权益销售部-王芳",
  215. GroupId: 17,
  216. GroupName: "无",
  217. }
  218. }
  219. }
  220. // initQsOpenApiConfig 全时开放api配置
  221. func initQsOpenApiConfig() {
  222. QsAppID = "ed1cc7c87c97089263fc899fbab193b0"
  223. QsSecretKey = "d92b91265dbbc5e3af44edfb82503635"
  224. if RunMode == "release" {
  225. QsUserId = 22330940
  226. QsUserName = "1406228535@qq.com"
  227. } else {
  228. QsUserId = 19896481
  229. QsUserName = "pyan@hzinsights.com"
  230. }
  231. }