update
This commit is contained in:
@@ -20,3 +20,7 @@ type SendEmailRequest struct {
|
||||
CC []string `json:"cc"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type EmailResponse struct {
|
||||
Email []string `json:"email"`
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"email-notification/middleware"
|
||||
"email-notification/model"
|
||||
"email-notification/query"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -40,9 +41,11 @@ func Route(db *gorm.DB, mux *http.ServeMux) {
|
||||
return
|
||||
}
|
||||
|
||||
var responseEmailData []string
|
||||
|
||||
for _, v := range *data {
|
||||
fmt.Println("Birthday", v.Fullname)
|
||||
|
||||
responseEmailData = append(responseEmailData, v.Email)
|
||||
sendTo := []string{v.Email}
|
||||
|
||||
type Data struct {
|
||||
@@ -64,8 +67,20 @@ func Route(db *gorm.DB, mux *http.ServeMux) {
|
||||
}(v)
|
||||
}
|
||||
|
||||
log.Printf("%+v %+v response %+v", sessionID, module, "success")
|
||||
w.Write([]byte("success"))
|
||||
responseData := model.EmailResponse{
|
||||
Email: responseEmailData,
|
||||
}
|
||||
|
||||
resData, err := json.Marshal(responseData)
|
||||
if err != nil {
|
||||
log.Printf("%+v %+v response %+v", sessionID, module, err.Error())
|
||||
w.WriteHeader(500)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("%+v %+v response %+v", sessionID, module, responseData)
|
||||
w.Write(resData)
|
||||
}))
|
||||
|
||||
mux.HandleFunc("/workanniversary-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -93,9 +108,11 @@ func Route(db *gorm.DB, mux *http.ServeMux) {
|
||||
|
||||
subject := "Work Anniversary 🎉"
|
||||
|
||||
var responseEmailData []string
|
||||
|
||||
for _, v := range *data {
|
||||
fmt.Println("Workanniversary", v.Fullname)
|
||||
|
||||
responseEmailData = append(responseEmailData, v.Email)
|
||||
sendTo := []string{v.Email}
|
||||
|
||||
type Data struct {
|
||||
@@ -121,8 +138,20 @@ func Route(db *gorm.DB, mux *http.ServeMux) {
|
||||
}(v)
|
||||
}
|
||||
|
||||
log.Printf("%+v %+v response %+v", sessionID, module, "success")
|
||||
w.Write([]byte("success"))
|
||||
responseData := model.EmailResponse{
|
||||
Email: responseEmailData,
|
||||
}
|
||||
|
||||
resData, err := json.Marshal(responseData)
|
||||
if err != nil {
|
||||
log.Printf("%+v %+v response %+v", sessionID, module, err.Error())
|
||||
w.WriteHeader(500)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("%+v %+v response %+v", sessionID, module, responseData)
|
||||
w.Write(resData)
|
||||
}))
|
||||
|
||||
mux.HandleFunc("/server-down-notification", middleware.ResponseTimeMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user