config.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package config
  2. import (
  3. "bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/powercheck"
  4. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/resource"
  5. "bp.jydev.jianyu360.cn/BaseService/userCenter/entity"
  6. "github.com/zeromicro/go-zero/core/conf"
  7. "github.com/zeromicro/go-zero/core/discov"
  8. "github.com/zeromicro/go-zero/zrpc"
  9. )
  10. func init() {
  11. conf.MustLoad("etc/usercenter.yaml", &entity.ConfigJson)
  12. //初始化资源中台相关
  13. resourceClient := zrpc.MustNewClient(zrpc.RpcClientConf{
  14. Etcd: discov.EtcdConf{
  15. Hosts: entity.ConfigJson.ResourceEtcdConf.Etcd.Hosts,
  16. Key: entity.ConfigJson.ResourceEtcdConf.Etcd.Key,
  17. },
  18. })
  19. entity.ResourceLib = resource.NewResource(resourceClient)
  20. //初始化权益中台相关
  21. powersClient := zrpc.MustNewClient(zrpc.RpcClientConf{
  22. Etcd: discov.EtcdConf{
  23. Hosts: entity.ConfigJson.PowersEtcdConf.Etcd.Hosts,
  24. Key: entity.ConfigJson.PowersEtcdConf.Etcd.Key,
  25. },
  26. })
  27. entity.PowerCheck = powercheck.NewPowerCheck(powersClient)
  28. //菜单表 外网
  29. if entity.ConfigJson.WorkTableOut == "" {
  30. entity.ConfigJson.WorkTableOut = "work_menu"
  31. }
  32. //菜单表 内网
  33. if entity.ConfigJson.WorkTableInside == "" {
  34. entity.ConfigJson.WorkTableInside = "work_menu"
  35. }
  36. if len(entity.ConfigJson.PopupIds) > 0 {
  37. for _, id := range entity.ConfigJson.PopupIds {
  38. entity.PopupIdMap[id] = true
  39. }
  40. }
  41. }