config.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package config
  2. import (
  3. "userCenter/entity"
  4. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/resource"
  5. "github.com/zeromicro/go-zero/core/conf"
  6. "github.com/zeromicro/go-zero/core/discov"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. "github.com/zeromicro/go-zero/zrpc"
  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 Mongodb struct {
  49. DbName string `json:"dbName"`
  50. Size int `json:"size"`
  51. Address string `json:"address"`
  52. }
  53. type Mysql struct {
  54. DbName string `json:"dbName"`
  55. Address string `json:"address"`
  56. UserName string `json:"userName"`
  57. PassWord string `json:"passWord"`
  58. MaxOpenConns int `json:"maxOpenConns"`
  59. MaxIdleConns int `json:"maxIdleConns"`
  60. }
  61. func init() {
  62. conf.MustLoad("etc/usercenter.yaml", &ConfigJson)
  63. //初始化资源中台相关
  64. resourceClient := zrpc.MustNewClient(zrpc.RpcClientConf{
  65. Etcd: discov.EtcdConf{
  66. Hosts: ConfigJson.ResourceEtcdConf.Etcd.Hosts,
  67. Key: ConfigJson.ResourceEtcdConf.Etcd.Key,
  68. },
  69. })
  70. entity.ResourceLib = resource.NewResource(resourceClient)
  71. //
  72. if len(ConfigJson.ManagerUserIds) > 0 {
  73. for _, v := range ConfigJson.ManagerUserIds {
  74. ManagerUserIdsMap[v] = true
  75. }
  76. }
  77. }