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