2022-11-14 07:45:26 +00:00
|
|
|
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 ...
|
2022-11-14 08:11:04 +00:00
|
|
|
func (s SocialPost) GetListSocialPostAppInfoByIDs(p model.GetListSocialPostAppByIDsRequest) (*model.ResponseListSocialPostAppInfo, error) {
|
2022-11-14 07:45:26 +00:00
|
|
|
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
|
|
|
|
}
|