config.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package config
  2. import (
  3. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/resource"
  4. "github.com/zeromicro/go-zero/core/conf"
  5. "github.com/zeromicro/go-zero/core/discov"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. "github.com/zeromicro/go-zero/zrpc"
  8. "userCenter/entity"
  9. )
  10. type Config struct {
  11. zrpc.RpcServerConf
  12. FileSystemConf zrpc.RpcClientConf
  13. CalleeId string // 服务名字
  14. ResourceEtcdConf zrpc.RpcClientConf //资源中台
  15. Node int // 节点
  16. Mysql Mysql
  17. BaseMysql Mysql
  18. Logx logx.LogConf
  19. IsRun bool //定时任务是否开启
  20. CheckEntIsExpire string //
  21. DoMain string
  22. RedisAddrees []string
  23. RedisOutTime int64
  24. InternalTime int64
  25. Mongo struct {
  26. Main *MongoStruct
  27. }
  28. BigMemberOff bool
  29. CommonlySize int64 //常用功能设置数量
  30. ManagerUserIds []string
  31. UserRolePower []string
  32. }
  33. type MongoStruct struct {
  34. Address string `json:"address"`
  35. Size int `json:"size"`
  36. DbName string `json:"dbName"`
  37. UserName string `json:"userName,optional"`
  38. Password string `json:"password,optional"`
  39. Collection string `json:"collection,optional"`
  40. CollectionBack string `json:"collectionBack,optional"`
  41. MaxOpenConns int `json:"maxOpenConns,optional"`
  42. MaxIdleConns int `json:"maxIdleConns,optional"`
  43. }
  44. var (
  45. ConfigJson Config
  46. ManagerUserIdsMap = map[string]bool{}
  47. )
  48. type Mysql struct {
  49. DbName string `json:"dbName"`
  50. Address string `json:"address"`
  51. UserName string `json:"userName"`
  52. PassWord string `json:"passWord"`
  53. MaxOpenConns int `json:"maxOpenConns"`
  54. MaxIdleConns int `json:"maxIdleConns"`
  55. }
  56. func init() {
  57. conf.MustLoad("etc/usercenter.yaml", &ConfigJson)
  58. //初始化资源中台相关
  59. resourceClient := zrpc.MustNewClient(zrpc.RpcClientConf{
  60. Etcd: discov.EtcdConf{
  61. Hosts: ConfigJson.ResourceEtcdConf.Etcd.Hosts,
  62. Key: ConfigJson.ResourceEtcdConf.Etcd.Key,
  63. },
  64. })
  65. entity.ResourceLib = resource.NewResource(resourceClient)
  66. //
  67. if len(ConfigJson.ManagerUserIds) > 0 {
  68. for _, v := range ConfigJson.ManagerUserIds {
  69. ManagerUserIdsMap[v] = true
  70. }
  71. }
  72. }