浏览代码

关注未绑定

Jianghan 9 月之前
父节点
当前提交
d83fcee603
共有 5 个文件被更改,包括 94 次插入0 次删除
  1. 81 0
      pushUnbinding/config.go
  2. 1 0
      pushUnbinding/config.json
  3. 1 0
      pushUnbinding/main.go
  4. 1 0
      pushUnbinding/task.go
  5. 10 0
      pushUnbinding/task.json

+ 81 - 0
pushUnbinding/config.go

@@ -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)
+	}
+}

+ 1 - 0
pushUnbinding/config.json

@@ -0,0 +1 @@
+package main

+ 1 - 0
pushUnbinding/main.go

@@ -0,0 +1 @@
+package pushUnbinding

+ 1 - 0
pushUnbinding/task.go

@@ -0,0 +1 @@
+package main

+ 10 - 0
pushUnbinding/task.json

@@ -0,0 +1,10 @@
+{
+  "compilerOptions": {
+    "target": "es2016",
+    "module": "commonjs",
+    "esModuleInterop": true,
+    "forceConsistentCasingInFileNames": true,
+    "strict": true,
+    "skipLibCheck": true
+  }
+}