From dbf8ad502f061c3ff19226bafd0ff3665c1cce3b Mon Sep 17 00:00:00 2001 From: Nguyen Minh Date: Wed, 23 Nov 2022 16:54:31 +0700 Subject: [PATCH 1/2] fix --- model/social_post_response.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/social_post_response.go b/model/social_post_response.go index e0765f5..85a2445 100644 --- a/model/social_post_response.go +++ b/model/social_post_response.go @@ -44,7 +44,7 @@ type SocialPostSellerInfo struct { ID primitive.ObjectID `json:"_id"` Name string `json:"name"` Membership SellerMembershipInfo `json:"membership"` - Logo *FilePhoto `json:"logo"` + Logo *FilePhoto `json:"avatar"` IsMine bool `json:"isMine"` } From e3e498ed23713b3cf4f016c5f6965f124925e7d5 Mon Sep 17 00:00:00 2001 From: tuannt20 <105765641+tuannt20@users.noreply.github.com> Date: Thu, 24 Nov 2022 09:06:48 +0700 Subject: [PATCH 2/2] add nasts campaign transaction --- client/campaign.go | 31 ++++++++++++++++++++++++++++++ model/campaign_request.go | 14 ++++++++++++++ model/campaign_response.go | 39 ++++++++++++++++++++++++++++++++++++++ subject/campaign.go | 15 +++++++++++++++ subject/config.go | 2 ++ 5 files changed, 101 insertions(+) create mode 100644 client/campaign.go create mode 100644 model/campaign_request.go create mode 100644 model/campaign_response.go create mode 100644 subject/campaign.go diff --git a/client/campaign.go b/client/campaign.go new file mode 100644 index 0000000..7a210e6 --- /dev/null +++ b/client/campaign.go @@ -0,0 +1,31 @@ +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" +) + +// Campaign ... +type Campaign struct{} + +// GetCampaignTransaction ... +func (c Campaign) GetCampaignTransaction(p model.GetCampaignTransactionsRequest) (*model.ResponseCampaignTransactionAll, error) { + msg, err := natsio.GetServer().Request(subject.Campaign.GetListCampaignTransactionAdminInfoByIDs, toBytes(p)) + if err != nil { + return nil, err + } + var r struct { + Data *model.ResponseCampaignTransactionAll `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/campaign_request.go b/model/campaign_request.go new file mode 100644 index 0000000..71227e4 --- /dev/null +++ b/model/campaign_request.go @@ -0,0 +1,14 @@ +package model + +import "time" + +// GetCampaignTransactionsRequest ... +type GetCampaignTransactionsRequest struct { + Campaign string `json:"campaign"` + Keyword string `json:"keyword"` + Status string `json:"status"` + FromAt time.Time `json:"fromAt"` + ToAt time.Time `json:"toAt"` + Page int64 `json:"page"` + Limit int64 `json:"limit"` +} diff --git a/model/campaign_response.go b/model/campaign_response.go new file mode 100644 index 0000000..7482099 --- /dev/null +++ b/model/campaign_response.go @@ -0,0 +1,39 @@ +package model + +// ResponseCampaignTransactionAll ... +type ResponseCampaignTransactionAll struct { + List []ResponseNatsCampaignTransaction `json:"list"` + Total int64 `json:"total"` + Limit int64 `json:"limit"` +} + +// ResponseNatsCampaignTransaction ... +type ResponseNatsCampaignTransaction struct { + ID string `json:"_id"` + Cash float64 `json:"cash"` + Campaign ResponseCampaignShortInfo `json:"campaign"` + Seller ResponseSellerInfo `json:"seller"` + Type string `json:"type"` + RejectedReason string `json:"rejectedReason"` + CreatedAt string `json:"createdAt"` + UpdatedAt string `json:"updatedAt"` + Item *ResponseCampaignItemShortInfo `json:"item"` + ApprovedBy *ResponseStaffInfo `json:"approvedBy,omitempty"` + RejectedBy *ResponseStaffInfo `json:"rejectedBy,omitempty"` + ApprovedAt string `json:"approvedAt,omitempty"` + RejectedAt string `json:"rejectedAt,omitempty"` +} + +// ResponseCampaignShortInfo ... +type ResponseCampaignShortInfo struct { + ID string `json:"_id"` + Name string `json:"name"` + Status string `json:"status"` +} + +// ResponseCampaignItemShortInfo ... +type ResponseCampaignItemShortInfo struct { + ID string `json:"_id"` + Name string `json:"name"` + Status string `json:"status"` +} diff --git a/subject/campaign.go b/subject/campaign.go new file mode 100644 index 0000000..8c7ddac --- /dev/null +++ b/subject/campaign.go @@ -0,0 +1,15 @@ +package subject + +import "fmt" + +// getCampaignValue ... +func getCampaignValue(val string) string { + return fmt.Sprintf("%s.%s", prefixes.Campaign, val) +} + +// Campaign ... +var Campaign = struct { + GetListCampaignTransactionAdminInfoByIDs string +}{ + GetListCampaignTransactionAdminInfoByIDs: getCampaignValue("get_list_campaign_transaction_admin_info_by_ids"), +} diff --git a/subject/config.go b/subject/config.go index 2a2f743..9d9b655 100644 --- a/subject/config.go +++ b/subject/config.go @@ -13,6 +13,7 @@ var prefixes = struct { SupplierRole string SocialPost string Staff string + Campaign string }{ Communication: "communication", Order: "order", @@ -26,4 +27,5 @@ var prefixes = struct { SupplierRole: "supplier_role", SocialPost: "social_post", Staff: "staff", + Campaign: "campaign", }