feat: mail config and mail send
This commit is contained in:
@@ -9,6 +9,11 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
Open = 1
|
||||
Close = 2
|
||||
)
|
||||
|
||||
type CustomerService struct {
|
||||
}
|
||||
|
||||
@@ -57,6 +62,31 @@ func (c *CustomerService) Update(param *models.CustomerUpdateParam) int {
|
||||
return response.ErrCodeSuccess
|
||||
}
|
||||
|
||||
// 发送邮件给客户
|
||||
func (c *CustomerService) SendMail(param *models.CustomerSendMailParam) int {
|
||||
var mc models.MailConfig
|
||||
err := global.Db.Model(&models.MailConfig{}).Where("creator = ?", param.Uid).First(&mc).Error
|
||||
if err != nil {
|
||||
return response.ErrCodeMailSendFailed
|
||||
}
|
||||
if mc.Status == Close {
|
||||
return response.ErrCodeMailSendUnEnable
|
||||
}
|
||||
mailParam := models.MailParam{
|
||||
Smtp: mc.Stmp,
|
||||
Port: mc.Port,
|
||||
AuthCode: mc.AuthCode,
|
||||
Sender: mc.Email,
|
||||
Subject: param.Subject,
|
||||
Content: param.Content,
|
||||
Receiver: param.Receiver,
|
||||
}
|
||||
if err := common.SendMailToCustomer(mailParam); err != nil {
|
||||
return response.ErrCodeMailSendFailed
|
||||
}
|
||||
return response.ErrCodeSuccess
|
||||
}
|
||||
|
||||
// 删除客户
|
||||
func (c *CustomerService) Delete(param *models.CustomerDeleteParam) int {
|
||||
if err := global.Db.Delete(&models.Customer{}, param.Ids).Error; err != nil {
|
||||
|
||||
Reference in New Issue
Block a user