| | |
| | | import ( |
| | | "log" |
| | | "os" |
| | | "wms/constvar" |
| | | "wms/pkg/logx" |
| | | "wms/pkg/mysqlx" |
| | | |
| | |
| | | |
| | | type ( |
| | | webConf struct { |
| | | Host string // 本机ip地址 |
| | | Port string // 端口号 |
| | | NodeId string // 主账户用户名 |
| | | OssType string // 对象存储类型 |
| | | JWTSecret string |
| | | FileServer string //文件服务器地址 |
| | | ServerId string //服务ID |
| | | GrpcPort string //grpc端口号 |
| | | Host string // 本机ip地址 |
| | | Port string // 端口号 |
| | | NodeId string // 主账户用户名 |
| | | OssType string // 对象存储类型 |
| | | JWTSecret string |
| | | FileServer string //文件服务器地址 |
| | | ServerId string //服务ID |
| | | Env constvar.Env |
| | | GrpcPort string //grpc端口号 |
| | | CompanyName string //公司名 |
| | | } |
| | | |
| | | localConf struct { |
| | | StorePath string // 本地文件存储路径 |
| | | } |
| | | |
| | | grpcServerConf struct { |
| | | ApsAddr string //aps服务grpc地址 |
| | | CrmAddr string //crm服务grpc地址 |
| | | SrmAddr string //srm服务grpc地址 |
| | | } |
| | | |
| | | fileTemplateConf struct { |
| | | InputSelfmadeAddr string //入库自制单模版地址 |
| | | } |
| | | |
| | | dingTalkConf struct { |
| | | AlarmKey string |
| | | AlarmUrl string |
| | | } |
| | | ) |
| | | |
| | | var ( |
| | | WebConf = &webConf{} |
| | | LogConf = &logx.Conf{} |
| | | DbConf = &mysqlx.Conf{} |
| | | LocalConf = &localConf{} |
| | | Viper *viper.Viper |
| | | WebConf = &webConf{} |
| | | LogConf = &logx.Conf{} |
| | | DbConf = &mysqlx.Conf{} |
| | | LocalConf = &localConf{} |
| | | Viper *viper.Viper |
| | | GrpcServerConf = &grpcServerConf{} |
| | | DingTalkConf = &dingTalkConf{} |
| | | ) |
| | | |
| | | func Init() error { |
| | |
| | | } |
| | | read2Conf(Viper) |
| | | |
| | | nodeId := os.Getenv("NODE_ID") // 主账户用户名 |
| | | host := os.Getenv("HOST") // 本机IP地址 |
| | | nodeId := os.Getenv("NODE_ID") // 主账户用户名 |
| | | host := os.Getenv("HOST") // 本机IP地址 |
| | | GrpcPort := os.Getenv("WMS_GRPC") // 只对外提供grpc服务,本服务不用 |
| | | apsAddr := os.Getenv("APS_GRPC") |
| | | crmAddr := os.Getenv("CRM_GRPC") |
| | | srmAddr := os.Getenv("SRM_GRPC") |
| | | companyName := os.Getenv("COMPANY_NAME") |
| | | if len(GrpcPort) > 0 { |
| | | WebConf.GrpcPort = GrpcPort |
| | | } |
| | | if len(nodeId) > 0 { |
| | | WebConf.NodeId = nodeId |
| | | } |
| | | if len(host) > 0 { |
| | | WebConf.Host = host |
| | | } |
| | | if len(apsAddr) > 0 { |
| | | GrpcServerConf.ApsAddr = apsAddr |
| | | } |
| | | if len(crmAddr) > 0 { |
| | | GrpcServerConf.CrmAddr = crmAddr |
| | | } |
| | | if len(srmAddr) > 0 { |
| | | GrpcServerConf.SrmAddr = srmAddr |
| | | } |
| | | if len(companyName) > 0 { |
| | | WebConf.CompanyName = companyName |
| | | } |
| | | |
| | | DBHost := os.Getenv("DB_HOST") |
| | |
| | | _ = v.UnmarshalKey("log", LogConf) |
| | | _ = v.UnmarshalKey("db", DbConf) |
| | | _ = v.UnmarshalKey("local", LocalConf) |
| | | _ = v.UnmarshalKey("grpcServer", GrpcServerConf) |
| | | _ = v.UnmarshalKey("dingTalk", DingTalkConf) |
| | | showConfig() |
| | | } |
| | | |
| | |
| | | log.Printf(" LogConf: %+v", LogConf) |
| | | log.Printf(" DbConf: %+v", DbConf) |
| | | log.Printf(" LocalConf: %+v", LocalConf) |
| | | log.Printf(" GrpcServerConf: %+v", GrpcServerConf) |
| | | log.Printf(" DingTalkConf: %+v", DingTalkConf) |
| | | log.Println("......................................................") |
| | | } |