From 7a213f4b4d64b3d82c55e6122f8c4d8b300935f4 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Wed, 16 Nov 2022 16:38:41 +0700 Subject: [PATCH 1/2] nats model campaign admin --- client/social_post.go | 24 ++++++++++++++++++++++++ model/social_post_request.go | 5 +++++ model/social_post_response.go | 11 +++++++++++ subject/social_post.go | 6 ++++-- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/client/social_post.go b/client/social_post.go index bae985d..e6d9395 100644 --- a/client/social_post.go +++ b/client/social_post.go @@ -39,3 +39,27 @@ func (s SocialPost) GetListSocialPostAppInfoByIDs(p model.GetListSocialPostAppBy } 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 +} diff --git a/model/social_post_request.go b/model/social_post_request.go index 179e378..72cd803 100644 --- a/model/social_post_request.go +++ b/model/social_post_request.go @@ -6,3 +6,8 @@ import "go.mongodb.org/mongo-driver/bson/primitive" type GetListSocialPostAppByIDsRequest struct { SocialPostIDs []primitive.ObjectID `json:"socialPostIDs"` } + +// GetBriefDetailSocialPostAdminByIDsRequest ... +type GetBriefDetailSocialPostAdminByIDsRequest struct { + SocialPostIDs []primitive.ObjectID `json:"socialPostIDs"` +} diff --git a/model/social_post_response.go b/model/social_post_response.go index cb6469b..94371f5 100644 --- a/model/social_post_response.go +++ b/model/social_post_response.go @@ -47,3 +47,14 @@ type SocialPostSellerInfo struct { Logo *FilePhoto `json:"logo"` IsMine bool `json:"isMine"` } + +// ResponseDetailSocialPostAdminInfo ... +type ResponseDetailSocialPostAdminInfo struct { + SocialPosts SocialPostAdminInfo `json:"socialPosts"` +} + +type SocialPostAdminInfo struct { + ID primitive.ObjectID `json:"_id"` + Title string `json:"title"` + Status string `json:"status"` +} diff --git a/subject/social_post.go b/subject/social_post.go index ff585c9..a90106a 100644 --- a/subject/social_post.go +++ b/subject/social_post.go @@ -9,7 +9,9 @@ func getSocialPostValue(val string) string { // SocialPost ... var SocialPost = struct { - GetListSocialPostAppInfoByIDs string + GetListSocialPostAppInfoByIDs string + GetBriefDetailSocialPostAdminByIDs string }{ - GetListSocialPostAppInfoByIDs: getSocialPostValue("get_list_social_post_app_info_by_ids"), + GetListSocialPostAppInfoByIDs: getSocialPostValue("get_list_social_post_app_info_by_ids"), + GetBriefDetailSocialPostAdminByIDs: getSocialPostValue("get_brief_detail_social_post_admin_by_ids"), } From 6e21f72ac00bc7cd94bd73338adeaf01a72fb023 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Wed, 16 Nov 2022 17:21:37 +0700 Subject: [PATCH 2/2] fix name func --- client/social_post.go | 4 ++-- model/social_post_request.go | 4 ++-- subject/social_post.go | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/social_post.go b/client/social_post.go index e6d9395..9e614c0 100644 --- a/client/social_post.go +++ b/client/social_post.go @@ -41,8 +41,8 @@ func (s SocialPost) GetListSocialPostAppInfoByIDs(p model.GetListSocialPostAppBy } // GetBriefDetailSocialPostAdminByIDsRequest ... -func (s SocialPost) GetBriefDetailSocialPostAdminByIDsRequest(p model.GetBriefDetailSocialPostAdminByIDsRequest) (*model.ResponseDetailSocialPostAdminInfo, error) { - msg, err := natsio.GetServer().Request(subject.SocialPost.GetBriefDetailSocialPostAdminByIDs, toBytes(p)) +func (s SocialPost) GetBriefDetailSocialPostAdminByIDsRequest(p model.GetBriefInfoSocialPostAdminByIDsRequest) (*model.ResponseDetailSocialPostAdminInfo, error) { + msg, err := natsio.GetServer().Request(subject.SocialPost.GetBriefInfoSocialPostAdminByIDs, toBytes(p)) if err != nil { return nil, err diff --git a/model/social_post_request.go b/model/social_post_request.go index 72cd803..efeb983 100644 --- a/model/social_post_request.go +++ b/model/social_post_request.go @@ -7,7 +7,7 @@ type GetListSocialPostAppByIDsRequest struct { SocialPostIDs []primitive.ObjectID `json:"socialPostIDs"` } -// GetBriefDetailSocialPostAdminByIDsRequest ... -type GetBriefDetailSocialPostAdminByIDsRequest struct { +// GetBriefInfoSocialPostAdminByIDsRequest ... +type GetBriefInfoSocialPostAdminByIDsRequest struct { SocialPostIDs []primitive.ObjectID `json:"socialPostIDs"` } diff --git a/subject/social_post.go b/subject/social_post.go index a90106a..029f876 100644 --- a/subject/social_post.go +++ b/subject/social_post.go @@ -9,9 +9,9 @@ func getSocialPostValue(val string) string { // SocialPost ... var SocialPost = struct { - GetListSocialPostAppInfoByIDs string - GetBriefDetailSocialPostAdminByIDs string + GetListSocialPostAppInfoByIDs string + GetBriefInfoSocialPostAdminByIDs string }{ - GetListSocialPostAppInfoByIDs: getSocialPostValue("get_list_social_post_app_info_by_ids"), - GetBriefDetailSocialPostAdminByIDs: getSocialPostValue("get_brief_detail_social_post_admin_by_ids"), + GetListSocialPostAppInfoByIDs: getSocialPostValue("get_list_social_post_app_info_by_ids"), + GetBriefInfoSocialPostAdminByIDs: getSocialPostValue("get_brief_info_social_post_admin_by_ids"), }