merge branch master into 'admin-push-notification-supplier
This commit is contained in:
		
						commit
						25890d58bc
					
				| 
						 | 
				
			
			@ -0,0 +1,65 @@
 | 
			
		|||
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.GetBriefInfoSocialPostAdminByIDsRequest) (*model.ResponseListSocialPostAdminInfo, error) {
 | 
			
		||||
	msg, err := natsio.GetServer().Request(subject.SocialPost.GetBriefInfoSocialPostAdminByIDs, toBytes(p))
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var r struct {
 | 
			
		||||
		Data  *model.ResponseListSocialPostAdminInfo `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
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -12,8 +12,9 @@ type PushNotification struct {
 | 
			
		|||
 | 
			
		||||
// NotificationOptions ...
 | 
			
		||||
type NotificationOptions struct {
 | 
			
		||||
	Title   string `json:"title"`
 | 
			
		||||
	Content string `json:"content"`
 | 
			
		||||
	Title      string `json:"title"`
 | 
			
		||||
	Content    string `json:"content"`
 | 
			
		||||
	CampaignID string `json:"campaignId,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PayloadUpdateSellerAffiliateStatistic ...
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,56 @@
 | 
			
		|||
package model
 | 
			
		||||
 | 
			
		||||
import "go.mongodb.org/mongo-driver/bson/primitive"
 | 
			
		||||
 | 
			
		||||
// FilePhoto ...
 | 
			
		||||
type FilePhoto struct {
 | 
			
		||||
	ID         string          `json:"_id"`
 | 
			
		||||
	Name       string          `json:"name,omitempty"`
 | 
			
		||||
	Dimensions *FileDimensions `json:"dimensions"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FileSize ...
 | 
			
		||||
type FileSize struct {
 | 
			
		||||
	Width  int    `json:"width"`
 | 
			
		||||
	Height int    `json:"height"`
 | 
			
		||||
	URL    string `json:"url"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FileDimensions ...
 | 
			
		||||
type FileDimensions struct {
 | 
			
		||||
	Small  *FileSize `json:"sm"`
 | 
			
		||||
	Medium *FileSize `json:"md"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ListPhoto ...
 | 
			
		||||
type ListPhoto []*FilePhoto
 | 
			
		||||
 | 
			
		||||
// Video ...
 | 
			
		||||
type Video struct {
 | 
			
		||||
	ID             primitive.ObjectID   `json:"_id"`
 | 
			
		||||
	Name           string               `json:"name"`
 | 
			
		||||
	Dimensions     *FileVideoDimensions `json:"dimensions"`
 | 
			
		||||
	VideoExtension string               `json:"ext"`
 | 
			
		||||
	Thumbnail      *FilePhoto           `json:"thumbnail"`
 | 
			
		||||
	Status         string               `json:"status"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FileVideoDimensions ...
 | 
			
		||||
type FileVideoDimensions struct {
 | 
			
		||||
	Dimension480p     *FileVideoSize `json:"size480p"`
 | 
			
		||||
	Dimension720p     *FileVideoSize `json:"size720p"`
 | 
			
		||||
	Dimension1080p    *FileVideoSize `json:"size1080p"`
 | 
			
		||||
	DimensionOriginal *FileVideoSize `json:"original"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FileVideoSize ...
 | 
			
		||||
type FileVideoSize struct {
 | 
			
		||||
	Name   string `json:"name"`
 | 
			
		||||
	Width  int    `json:"width"`
 | 
			
		||||
	Height int    `json:"height"`
 | 
			
		||||
	Size   string `json:"size"`
 | 
			
		||||
	URL    string `json:"url"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ListVideo ...
 | 
			
		||||
type ListVideo []Video
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
package model
 | 
			
		||||
 | 
			
		||||
import "go.mongodb.org/mongo-driver/bson/primitive"
 | 
			
		||||
 | 
			
		||||
// GetListSocialPostAppByIDsRequest ...
 | 
			
		||||
type GetListSocialPostAppByIDsRequest struct {
 | 
			
		||||
	SocialPostIDs []primitive.ObjectID `json:"socialPostIDs"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetBriefInfoSocialPostAdminByIDsRequest ...
 | 
			
		||||
type GetBriefInfoSocialPostAdminByIDsRequest struct {
 | 
			
		||||
	SocialPostIDs []primitive.ObjectID `json:"socialPostIDs"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,61 @@
 | 
			
		|||
package model
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"go.mongodb.org/mongo-driver/bson/primitive"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ResponseListSocialPostAppInfo ...
 | 
			
		||||
type ResponseListSocialPostAppInfo struct {
 | 
			
		||||
	SocialPosts []SocialPostAppInfo `json:"socialPosts"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SocialPostAppInfo ...
 | 
			
		||||
type SocialPostAppInfo struct {
 | 
			
		||||
	ID          primitive.ObjectID    `json:"_id"`
 | 
			
		||||
	Title       string                `json:"title"`
 | 
			
		||||
	Content     string                `json:"content"`
 | 
			
		||||
	Statistic   SocialPostStatistic   `json:"statistic"`
 | 
			
		||||
	Author      *SocialPostSellerInfo `json:"author"`
 | 
			
		||||
	Photos      ListPhoto             `json:"photos"`
 | 
			
		||||
	PublishedAt time.Time             `json:"publishedAt"`
 | 
			
		||||
	IsLiked     bool                  `json:"isLiked"`
 | 
			
		||||
	IsPin       bool                  `json:"isPin"`
 | 
			
		||||
	Contributor *SocialPostSellerInfo `json:"contributor"`
 | 
			
		||||
	CreatedAt   time.Time             `json:"createdAt"`
 | 
			
		||||
	Status      string                `json:"status"`
 | 
			
		||||
	HasUpdate   bool                  `json:"hasUpdate"`
 | 
			
		||||
	Order       int                   `json:"order"`
 | 
			
		||||
	Videos      ListVideo             `json:"videos"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SocialPostStatistic ...
 | 
			
		||||
type SocialPostStatistic struct {
 | 
			
		||||
	Views        int `json:"views"`
 | 
			
		||||
	UniqueViews  int `json:"uniqueViews"`
 | 
			
		||||
	Likes        int `json:"likes"`
 | 
			
		||||
	Shares       int `json:"shares"`
 | 
			
		||||
	UniqueShares int `json:"uniqueShares"`
 | 
			
		||||
	Comments     int `json:"comments"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SocialPostSellerInfo ...
 | 
			
		||||
type SocialPostSellerInfo struct {
 | 
			
		||||
	ID         primitive.ObjectID   `json:"_id"`
 | 
			
		||||
	Name       string               `json:"name"`
 | 
			
		||||
	Membership SellerMembershipInfo `json:"membership"`
 | 
			
		||||
	Logo       *FilePhoto           `json:"avatar"`
 | 
			
		||||
	IsMine     bool                 `json:"isMine"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ResponseListSocialPostAdminInfo ...
 | 
			
		||||
type ResponseListSocialPostAdminInfo struct {
 | 
			
		||||
	SocialPosts []SocialPostAdminInfo `json:"socialPosts"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SocialPostAdminInfo ...
 | 
			
		||||
type SocialPostAdminInfo struct {
 | 
			
		||||
	ID     primitive.ObjectID `json:"_id"`
 | 
			
		||||
	Title  string             `json:"title"`
 | 
			
		||||
	Status string             `json:"status"`
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -11,6 +11,7 @@ var prefixes = struct {
 | 
			
		|||
	Seller        string
 | 
			
		||||
	SupplierUser  string
 | 
			
		||||
	SupplierRole  string
 | 
			
		||||
	SocialPost    string
 | 
			
		||||
	Staff         string
 | 
			
		||||
	Segment       string
 | 
			
		||||
}{
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +25,7 @@ var prefixes = struct {
 | 
			
		|||
	Seller:        "seller",
 | 
			
		||||
	SupplierUser:  "supplier_user",
 | 
			
		||||
	SupplierRole:  "supplier_role",
 | 
			
		||||
	SocialPost:    "social_post",
 | 
			
		||||
	Staff:         "staff",
 | 
			
		||||
	Segment:       "segment",
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,17 @@
 | 
			
		|||
package subject
 | 
			
		||||
 | 
			
		||||
import "fmt"
 | 
			
		||||
 | 
			
		||||
// getSocialPostValue ...
 | 
			
		||||
func getSocialPostValue(val string) string {
 | 
			
		||||
	return fmt.Sprintf("%s.%s", prefixes.SocialPost, val)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SocialPost ...
 | 
			
		||||
var SocialPost = struct {
 | 
			
		||||
	GetListSocialPostAppInfoByIDs    string
 | 
			
		||||
	GetBriefInfoSocialPostAdminByIDs string
 | 
			
		||||
}{
 | 
			
		||||
	GetListSocialPostAppInfoByIDs:    getSocialPostValue("get_list_social_post_app_info_by_ids"),
 | 
			
		||||
	GetBriefInfoSocialPostAdminByIDs: getSocialPostValue("get_brief_info_social_post_admin_by_ids"),
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue