|
@@ -0,0 +1,81 @@
|
|
|
+package config
|
|
|
+
|
|
|
+import (
|
|
|
+ "log"
|
|
|
+ "time"
|
|
|
+
|
|
|
+ util "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/mail"
|
|
|
+ "github.com/zeromicro/go-zero/core/discov"
|
|
|
+ "github.com/zeromicro/go-zero/zrpc"
|
|
|
+)
|
|
|
+
|
|
|
+type config struct {
|
|
|
+ Duration int64 `json:"duration"`
|
|
|
+ MailFrom string
|
|
|
+ EtcdHosts []string `json:"etcdHosts"`
|
|
|
+ MessageKey string `json:"messageKey"`
|
|
|
+ TestPhones []string `json:"testPhones"`
|
|
|
+ TestMails []string `json:"testMails"`
|
|
|
+ KeCheng struct {
|
|
|
+ DeptId int64 `json:"deptId"`
|
|
|
+ ReTryTime time.Duration `json:"reTryTime"`
|
|
|
+ MaxTime time.Duration `json:"maxTime"`
|
|
|
+ Title string `json:"title"`
|
|
|
+ Mail struct {
|
|
|
+ Table string `json:"table"`
|
|
|
+ Content string `json:"content"`
|
|
|
+ ServiceList string `json:"serviceList"`
|
|
|
+ } `json:"mail"`
|
|
|
+ Message string `json:"message"`
|
|
|
+ MessageServiceList string `json:"messageServiceList"`
|
|
|
+ } `json:"keCheng"`
|
|
|
+ Mails []*pushMail `json:"mails"`
|
|
|
+}
|
|
|
+
|
|
|
+type pushMail struct {
|
|
|
+ Addr string `json:"addr"`
|
|
|
+ Port int `json:"port"`
|
|
|
+ Pwd string `json:"pwd"`
|
|
|
+ User string `json:"user"`
|
|
|
+ MailPoolSize int `json:"mailPoolSize"`
|
|
|
+ MailReTry int `json:"mailReTry"`
|
|
|
+}
|
|
|
+
|
|
|
+type taskConfig struct {
|
|
|
+ OrderEachTime string `json:"orderEachTime"`
|
|
|
+}
|
|
|
+
|
|
|
+var (
|
|
|
+ Gmails []*mail.GmailAuth
|
|
|
+ Config *config
|
|
|
+ TaskConfig *taskConfig
|
|
|
+ MessageClient zrpc.Client
|
|
|
+)
|
|
|
+
|
|
|
+func init() {
|
|
|
+ util.ReadConfig("./config.json", &Config)
|
|
|
+ util.ReadConfig("./task.json", &TaskConfig)
|
|
|
+ //
|
|
|
+ Gmails = make([]*mail.GmailAuth, len(Config.Mails))
|
|
|
+ for k, v := range Config.Mails {
|
|
|
+ Gmails[k] = &mail.GmailAuth{
|
|
|
+ SmtpHost: v.Addr,
|
|
|
+ SmtpPort: v.Port,
|
|
|
+ User: v.User,
|
|
|
+ Pwd: v.Pwd,
|
|
|
+ PoolSize: v.MailPoolSize,
|
|
|
+ ReTry: v.MailReTry,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var err error
|
|
|
+ MessageClient, err = zrpc.NewClient(zrpc.RpcClientConf{
|
|
|
+ Etcd: discov.EtcdConf{
|
|
|
+ Hosts: Config.EtcdHosts,
|
|
|
+ Key: Config.MessageKey,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ log.Fatalln(err)
|
|
|
+ }
|
|
|
+}
|