42 lines
919 B
Go
42 lines
919 B
Go
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"
|
|
)
|
|
|
|
// SocialPost ...
|
|
type SocialPost struct{}
|
|
|
|
// GetSocialPost ...
|
|
func GetSocialPost() SocialPost {
|
|
return SocialPost{}
|
|
}
|
|
|
|
// GetListSocialPostAppInfoByIDs ...
|
|
func (s SocialPost) GetListSocialPostAppInfoByIDs(p model.GetListSocialPostAppByIDsRequest) (*model.ResponseListSocialPostAppInfo, error) {
|
|
msg, err := natsio.GetServer().Request(subject.SocialPost.GetListSocialPostAppInfoByIDs, toBytes(p))
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var r struct {
|
|
Data *model.ResponseListSocialPostAppInfo `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
|
|
}
|