remove err method email

This commit is contained in:
Sinh 2022-11-18 10:24:06 +07:00
parent 23df6da6bf
commit 17dace7edf
1 changed files with 20 additions and 28 deletions

View File

@ -1,13 +1,5 @@
package client package client
import (
"encoding/json"
"errors"
"git.selly.red/Selly-Modules/natsio"
"git.selly.red/Selly-Modules/natsio/model"
"git.selly.red/Selly-Modules/natsio/subject"
)
// Email ... // Email ...
type Email struct{} type Email struct{}
@ -16,23 +8,23 @@ func GetEmail() Email {
return Email{} return Email{}
} }
func (s Email) Send(p model.GetEmailRequest) ([]*model.ResponseEmailInfo, error) { // func (s Email) Send(p model.GetEmailRequest) ([]*model.ResponseEmailInfo, error) {
msg, err := natsio.GetServer().Request(subject.Email.GetListEmailInfo, toBytes(p)) // msg, err := natsio.GetServer().Request(subject.Email.GetListEmailInfo, toBytes(p))
if err != nil { // if err != nil {
return nil, err // return nil, err
} // }
//
var r struct { // var r struct {
Data []*model.ResponseEmailInfo `json:"data"` // Data []*model.ResponseEmailInfo `json:"data"`
Error string `json:"error"` // Error string `json:"error"`
} // }
//
if err := json.Unmarshal(msg.Data, &r); err != nil { // if err := json.Unmarshal(msg.Data, &r); err != nil {
return nil, err // return nil, err
} // }
if r.Error != "" { // if r.Error != "" {
return nil, errors.New(r.Error) // return nil, errors.New(r.Error)
} // }
//
return r.Data, nil // return r.Data, nil
} // }