66 lines
1.5 KiB
Go
66 lines
1.5 KiB
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
|
|
}
|
|
|
|
// GetBriefDetailSocialPostAdminByIDsRequest ...
|
|
func (s SocialPost) GetBriefDetailSocialPostAdminByIDsRequest(p model.GetBriefDetailSocialPostAdminByIDsRequest) (*model.ResponseDetailSocialPostAdminInfo, error) {
|
|
msg, err := natsio.GetServer().Request(subject.SocialPost.GetBriefDetailSocialPostAdminByIDs, toBytes(p))
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var r struct {
|
|
Data *model.ResponseDetailSocialPostAdminInfo `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
|
|
}
|