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 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
} // }