refactor-location #134

Closed
trunglam wants to merge 270 commits from refactor-location into master
1 changed files with 20 additions and 28 deletions
Showing only changes of commit 17dace7edf - Show all commits

View File

@ -1,13 +1,5 @@
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 ...
type Email struct{}
@ -16,23 +8,23 @@ func GetEmail() Email {
return Email{}
}
func (s Email) Send(p model.GetEmailRequest) ([]*model.ResponseEmailInfo, error) {
msg, err := natsio.GetServer().Request(subject.Email.GetListEmailInfo, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Data []*model.ResponseEmailInfo `json:"data"`
Error string `json:"error"`
}
if err := json.Unmarshal(msg.Data, &r); err != nil {
return nil, err
}
if r.Error != "" {
return nil, errors.New(r.Error)
}
return r.Data, nil
}
// func (s Email) Send(p model.GetEmailRequest) ([]*model.ResponseEmailInfo, error) {
// msg, err := natsio.GetServer().Request(subject.Email.GetListEmailInfo, toBytes(p))
// if err != nil {
// return nil, err
// }
//
// var r struct {
// Data []*model.ResponseEmailInfo `json:"data"`
// Error string `json:"error"`
// }
//
// if err := json.Unmarshal(msg.Data, &r); err != nil {
// return nil, err
// }
// if r.Error != "" {
// return nil, errors.New(r.Error)
// }
//
// return r.Data, nil
// }