package main import ( "fmt" "go.uber.org/zap" "jygit.jydev.jianyu360.cn/data_processing/common_utils/log" "net/http" ) // getUniqueFields 获取切片中标题和项目名称的唯一值 func getUniqueFields(slice []map[string]interface{}) (map[string]bool, map[string]bool) { titles := make(map[string]bool) projects := make(map[string]bool) for _, item := range slice { title, titleExists := item["title"].(string) project, projectExists := item["projectname"].(string) if titleExists { titles[title] = true } if projectExists { projects[project] = true } } return titles, projects } // countMatches 统计切片A中的元素在切片B中存在的数量和总数量 func countMatches(sliceA []map[string]interface{}, titlesInB, projectsInB map[string]bool) int { count := 0 for _, itemA := range sliceA { title, titleExists := itemA["title"].(string) project, projectExists := itemA["projectname"].(string) if titleExists && titlesInB[title] { count++ } else if projectExists && projectsInB[project] { count++ } } return count } //SendMail 发送邮件 func SendMail(title, content string) { url := fmt.Sprintf("%s?to=%s&title=%s&body=%s", GF.Email.Api, GF.Email.To, title, content) fmt.Println("url=>", url) res, err := http.Get(url) if err != nil { log.Info("SendMail", zap.Any("err", err)) } else { log.Info("SendMail", zap.Any("res", res)) } }