Skip to content

Commit

Permalink
feat(vivo status): 添加send、receive、displayc、click数据,vivo添加获取推送后的异步job查…
Browse files Browse the repository at this point in the history
…询消息数据
  • Loading branch information
am6737 committed Mar 14, 2024
1 parent c1cddac commit bb665bc
Show file tree
Hide file tree
Showing 23 changed files with 607 additions and 58 deletions.
1 change: 1 addition & 0 deletions api/http/v1/dto/dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type VivoPushRequestData struct {
Title string `json:"title"`
Content string `json:"content"`
Category string `json:"category,omitempty"`
TaskID string `json:"task_id,omitempty"`
Data map[string]string `json:"data,omitempty"`
ClickAction ClickAction `json:"click_action,omitempty"`
}
Expand Down
8 changes: 8 additions & 0 deletions api/http/v1/dto/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@ type PushStatRequest struct {

// Method 推送方法 http、grpc
Method string `json:"method"`

AppID string `json:"app_id" binding:"required"`

NotifyID string `json:"notify_id" binding:"required"`
}

// PushStat 每个推送平台的推送状态
type PushStat struct {
Total int64 `json:"total"` // 总推送数
Success int64 `json:"success"` // 成功推送数
Failed int64 `json:"failed"` // 失败推送数
Send int64 `json:"send"` // 发送数
Receive int64 `json:"receive"` // 到达数
Display int64 `json:"display"` // 展示数
Click int64 `json:"click"` // 点击数
}

// PushStats 所有推送平台的推送状态
Expand Down
21 changes: 13 additions & 8 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
h "github.com/cossim/hipush/internal/server/http"
"github.com/cossim/hipush/pkg/push"
"github.com/cossim/hipush/pkg/status"
"github.com/go-co-op/gocron/v2"
"github.com/go-logr/zapr"
"go.uber.org/zap"
"log"
Expand Down Expand Up @@ -43,17 +44,21 @@ func main() {

zapLogger := zap.NewExample()
logger := zapr.NewLogger(zapLogger)
scheduler, err := gocron.NewScheduler()
if err != nil {
panic(err)
}

pushServiceFactory := factory.NewPushServiceFactory()
if err := pushServiceFactory.Register(
pushServiceFactory.WithPushService(push.NewAPNsService(cfg, logger)),
pushServiceFactory.WithPushService(push.NewFCMService(cfg, logger)),
pushServiceFactory.WithPushService(push.NewHMSService(cfg, logger)),
pushServiceFactory.WithPushService(push.NewXiaomiService(cfg, logger)),
pushServiceFactory.WithPushService(push.NewOppoService(cfg, logger)),
pushServiceFactory.WithPushService(push.NewVivoService(cfg, logger)),
pushServiceFactory.WithPushService(push.NewMeizuService(cfg, logger)),
pushServiceFactory.WithPushService(push.NewHonorService(cfg, logger)),
//pushServiceFactory.WithPushService(push.NewAPNsService(cfg, logger)),
//pushServiceFactory.WithPushService(push.NewFCMService(cfg, logger)),
//pushServiceFactory.WithPushService(push.NewHMSService(cfg, logger)),
//pushServiceFactory.WithPushService(push.NewXiaomiService(cfg, logger)),
//pushServiceFactory.WithPushService(push.NewOppoService(cfg, logger)),
pushServiceFactory.WithPushService(push.NewVivoService(cfg, logger, scheduler)),
//pushServiceFactory.WithPushService(push.NewMeizuService(cfg, logger)),
//pushServiceFactory.WithPushService(push.NewHonorService(cfg, logger)),
); err != nil {
panic(err)
}
Expand Down
8 changes: 8 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type iOSAppConfig struct {
MaxRetry int `yaml:"max_retry"`
Enabled bool `yaml:"enabled"`
Production bool `yaml:"production"`
AppName string `json:"app_name"`
AppID string `yaml:"app_id"`
KeyPath string `yaml:"key_path"`
KeyType string `yaml:"key_type"`
Expand All @@ -21,6 +22,7 @@ type iOSAppConfig struct {

type HuaweiAppConfig struct {
Enabled bool `yaml:"enabled"`
AppName string `json:"app_name"`
AppID string `yaml:"app_id"`
AppSecret string `yaml:"app_secret"`
AuthUrl string `yaml:"auth_url"`
Expand All @@ -30,6 +32,7 @@ type HuaweiAppConfig struct {

type VivoAppConfig struct {
Enabled bool `yaml:"enabled"`
AppName string `json:"app_name"`
AppID string `yaml:"app_id"`
AppKey string `yaml:"app_key"`
AppSecret string `yaml:"app_secret"`
Expand All @@ -38,6 +41,7 @@ type VivoAppConfig struct {

type OppoAppConfig struct {
Enabled bool `yaml:"enabled"`
AppName string `json:"app_name"`
AppID string `yaml:"app_id"`
AppKey string `yaml:"app_key"`
AppSecret string `yaml:"app_secret"`
Expand All @@ -46,6 +50,7 @@ type OppoAppConfig struct {

type AndroidAppConfig struct {
Enabled bool `yaml:"enabled"`
AppName string `json:"app_name"`
AppID string `yaml:"app_id"`
AppKey string `yaml:"app_key"`
KeyPath string `yaml:"key_path"`
Expand All @@ -54,6 +59,7 @@ type AndroidAppConfig struct {

type XiaomiAppConfig struct {
Enabled bool `yaml:"enabled"`
AppName string `json:"app_name"`
AppID string `yaml:"app_id"`
AppSecret string `yaml:"app_secret"`
Package []string `yaml:"package"`
Expand All @@ -62,13 +68,15 @@ type XiaomiAppConfig struct {

type MeizuAppConfig struct {
Enabled bool `yaml:"enabled"`
AppName string `json:"app_name"`
AppID string `yaml:"app_id"`
AppKey string `yaml:"app_key"`
MaxRetry int `yaml:"max_retry"`
}

type HonorAppConfig struct {
Enabled bool `yaml:"enabled"`
AppName string `json:"app_name"`
AppID string `yaml:"app_id"`
ClientID string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"`
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/cossim/go-meizu-push-sdk v0.0.0-20240308111828-f4255aaae3ac
github.com/cossim/vivo-push v0.0.0-20240312093754-a5c2baaa4799
github.com/gin-gonic/gin v1.9.1
github.com/go-co-op/gocron/v2 v2.2.6
github.com/go-logr/logr v1.4.1
github.com/go-logr/zapr v1.3.0
github.com/golang/protobuf v1.5.4
Expand Down Expand Up @@ -50,6 +51,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/kr/pretty v0.3.1 // indirect
Expand All @@ -58,6 +60,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
Expand All @@ -70,6 +73,7 @@ require (
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sync v0.6.0 // indirect
Expand Down
10 changes: 9 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-co-op/gocron/v2 v2.2.6 h1:sKRt4kemEzY9HnBx9BBnFDPXoOxBy77V4WVtoouhJgg=
github.com/go-co-op/gocron/v2 v2.2.6/go.mod h1:mZx3gMSlFnb97k3hRqX3+GdlG3+DUwTh6B8fnsTScXg=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
Expand Down Expand Up @@ -112,6 +114,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfF
github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=
github.com/googleapis/gax-go/v2 v2.12.2 h1:mhN09QQW1jEWeMF74zGR81R30z4VJzjZsfkUhuHF+DA=
github.com/googleapis/gax-go/v2 v2.12.2/go.mod h1:61M8vcyyXR2kqKFxKrfA22jaA8JGF7Dc8App1U3H6jc=
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
Expand All @@ -138,6 +142,8 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
Expand All @@ -155,7 +161,7 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/thoas/stats v0.0.0-20190407194641-965cb2de1678 h1:kFej3rMKjbzysHYvLmv5iOlbRymDMkNJxbovYb/iP0c=
github.com/thoas/stats v0.0.0-20190407194641-965cb2de1678/go.mod h1:GkZsNBOco11YY68OnXUARbSl26IOXXAeYf6ZKmSZR2M=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
Expand Down Expand Up @@ -193,6 +199,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE=
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down
2 changes: 1 addition & 1 deletion internal/server/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (h *Handler) Push(ctx context.Context, req *v1.PushRequest) (*v1.PushRespon
return nil, err
}

if err := service.Send(ctx, r, &push.SendOptions{
if err := service.Send(ctx, req.AppID, r, &push.SendOptions{
DryRun: req.Option.DryRun,
Retry: int(req.Option.Retry),
}); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/server/http/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (h *Handler) handleAndroidPush(c *gin.Context, req *dto.PushRequest) error
Data: nil,
Apns: nil,
}
if err := service.Send(c, rr, &push.SendOptions{
if err := service.Send(c, req.AppID, rr, &push.SendOptions{
DryRun: req.Option.DryRun,
Retry: req.Option.Retry,
RetryInterval: req.Option.RetryInterval,
Expand Down
2 changes: 1 addition & 1 deletion internal/server/http/honor.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (h *Handler) handleHonorPush(c *gin.Context, req *dto.PushRequest) {
},
NotifyId: r.NotifyId,
}
if err := service.Send(c, rr, &push.SendOptions{
if err := service.Send(c, req.AppID, rr, &push.SendOptions{
DryRun: req.Option.DryRun,
Retry: req.Option.Retry,
RetryInterval: req.Option.RetryInterval,
Expand Down
1 change: 1 addition & 0 deletions internal/server/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (h *Handler) Start(ctx context.Context) error {
r := gin.Default()
r.POST("/api/v1/push", h.pushHandler)
r.GET("/api/v1/push/stat", h.pushStatHandler)
r.GET("/api/v1/message/stat", h.pushMessageStatHandler)

srv := &http.Server{
Addr: h.cfg.HTTP.Addr(),
Expand Down
2 changes: 1 addition & 1 deletion internal/server/http/huawei.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (h *Handler) handleHuaweiPush(c *gin.Context, req *dto.PushRequest) error {
},
},
}
if err := service.Send(c, rr, &push.SendOptions{
if err := service.Send(c, req.AppID, rr, &push.SendOptions{
DryRun: req.Option.DryRun,
Retry: req.Option.Retry,
RetryInterval: req.Option.RetryInterval,
Expand Down
2 changes: 1 addition & 1 deletion internal/server/http/ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (h *Handler) handleIOSPush(c *gin.Context, req *dto.PushRequest) error {
Badge: r.Badge,
Expiration: nil,
}
if err := service.Send(c, rr, &push.SendOptions{
if err := service.Send(c, req.AppID, rr, &push.SendOptions{
DryRun: req.Option.DryRun,
Retry: req.Option.Retry,
RetryInterval: req.Option.RetryInterval,
Expand Down
2 changes: 1 addition & 1 deletion internal/server/http/meizu.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (h *Handler) handleMeizuPush(c *gin.Context, req *dto.PushRequest) error {
ScheduledStartTime: r.ScheduledStartTime,
ScheduledEndTime: r.ScheduledEndTime,
}
if err := service.Send(c, rr, &push.SendOptions{
if err := service.Send(c, req.AppID, rr, &push.SendOptions{
DryRun: req.Option.DryRun,
Retry: req.Option.Retry,
RetryInterval: req.Option.RetryInterval,
Expand Down
2 changes: 1 addition & 1 deletion internal/server/http/oppo.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (h *Handler) handleOppoPush(c *gin.Context, req *dto.PushRequest) error {
Retry: req.Option.Retry,
},
}
if err := service.Send(c, rr, &push.SendOptions{
if err := service.Send(c, req.AppID, rr, &push.SendOptions{
DryRun: req.Option.DryRun,
Retry: req.Option.Retry,
RetryInterval: req.Option.RetryInterval,
Expand Down
63 changes: 62 additions & 1 deletion internal/server/http/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package http

import (
"github.com/cossim/hipush/api/http/v1/dto"
"github.com/cossim/hipush/pkg/consts"
"github.com/cossim/hipush/pkg/notify"
"github.com/cossim/hipush/pkg/status"
"github.com/gin-gonic/gin"
"net/http"
Expand All @@ -14,13 +16,16 @@ func (h *Handler) pushStatHandler(c *gin.Context) {
// c.JSON(http.StatusBadRequest, Response{Code: http.StatusBadRequest, Msg: err.Error(), Data: nil})
// return
//}
//
//h.logger.Info("Received pushStat request", "platform", req.Platform, "method", req.Method)

ps := &dto.PushStats{}
ps.Total = status.StatStorage.GetTotalCount()
ps.Success = status.StatStorage.GetSuccessCount()
ps.Failed = status.StatStorage.GetFailedCount()
ps.Send = status.StatStorage.GetSendCount()
ps.Receive = status.StatStorage.GetReceiveCount()
ps.Display = status.StatStorage.GetDisplayCount()
ps.Click = status.StatStorage.GetClickCount()

ps.HTTP.Total = status.StatStorage.GetHttpTotal()
ps.HTTP.Success = status.StatStorage.GetHttpSuccess()
Expand All @@ -33,34 +38,90 @@ func (h *Handler) pushStatHandler(c *gin.Context) {
ps.IOS.Total = status.StatStorage.GetIosTotal()
ps.IOS.Success = status.StatStorage.GetIosSuccess()
ps.IOS.Failed = status.StatStorage.GetIosFailed()
ps.IOS.Send = status.StatStorage.GetIosSend()
ps.IOS.Receive = status.StatStorage.GetIosReceive()
ps.IOS.Display = status.StatStorage.GetIosDisplay()
ps.IOS.Click = status.StatStorage.GetIosClick()

ps.Android.Total = status.StatStorage.GetAndroidTotal()
ps.Android.Success = status.StatStorage.GetAndroidSuccess()
ps.Android.Failed = status.StatStorage.GetAndroidFailed()
ps.Android.Send = status.StatStorage.GetAndroidSend()
ps.Android.Receive = status.StatStorage.GetAndroidReceive()
ps.Android.Display = status.StatStorage.GetAndroidDisplay()
ps.Android.Click = status.StatStorage.GetAndroidClick()

ps.Huawei.Total = status.StatStorage.GetHuaweiTotal()
ps.Huawei.Success = status.StatStorage.GetHuaweiSuccess()
ps.Huawei.Failed = status.StatStorage.GetHuaweiFailed()
ps.Huawei.Send = status.StatStorage.GetHuaweiSend()
ps.Huawei.Receive = status.StatStorage.GetHuaweiReceive()
ps.Huawei.Display = status.StatStorage.GetHuaweiDisplay()
ps.Huawei.Click = status.StatStorage.GetHuaweiClick()

ps.Xiaomi.Total = status.StatStorage.GetXiaomiTotal()
ps.Xiaomi.Success = status.StatStorage.GetXiaomiSuccess()
ps.Xiaomi.Failed = status.StatStorage.GetXiaomiFailed()
ps.Xiaomi.Send = status.StatStorage.GetXiaomiSend()
ps.Xiaomi.Receive = status.StatStorage.GetXiaomiReceive()
ps.Xiaomi.Display = status.StatStorage.GetXiaomiDisplay()
ps.Xiaomi.Click = status.StatStorage.GetXiaomiClick()

ps.Vivo.Total = status.StatStorage.GetVivoTotal()
ps.Vivo.Success = status.StatStorage.GetVivoSuccess()
ps.Vivo.Failed = status.StatStorage.GetVivoFailed()
ps.Vivo.Send = status.StatStorage.GetVivoSend()
ps.Vivo.Receive = status.StatStorage.GetVivoReceive()
ps.Vivo.Display = status.StatStorage.GetVivoDisplay()
ps.Vivo.Click = status.StatStorage.GetVivoClick()

ps.Oppo.Total = status.StatStorage.GetOppoTotal()
ps.Oppo.Success = status.StatStorage.GetOppoSuccess()
ps.Oppo.Failed = status.StatStorage.GetOppoFailed()
ps.Oppo.Send = status.StatStorage.GetOppoSend()
ps.Oppo.Receive = status.StatStorage.GetOppoReceive()
ps.Oppo.Display = status.StatStorage.GetOppoDisplay()
ps.Oppo.Click = status.StatStorage.GetOppoClick()

ps.Meizu.Total = status.StatStorage.GetMeizuTotal()
ps.Meizu.Success = status.StatStorage.GetMeizuSuccess()
ps.Meizu.Failed = status.StatStorage.GetMeizuFailed()
ps.Meizu.Send = status.StatStorage.GetMeizuSend()
ps.Meizu.Receive = status.StatStorage.GetMeizuReceive()
ps.Meizu.Display = status.StatStorage.GetMeizuDisplay()
ps.Meizu.Click = status.StatStorage.GetMeizuClick()

ps.Honor.Total = status.StatStorage.GetHonorTotal()
ps.Honor.Success = status.StatStorage.GetHonorSuccess()
ps.Honor.Failed = status.StatStorage.GetHonorFailed()
ps.Honor.Send = status.StatStorage.GetHonorSend()
ps.Honor.Receive = status.StatStorage.GetHonorReceive()
ps.Honor.Display = status.StatStorage.GetHonorDisplay()
ps.Honor.Click = status.StatStorage.GetHonorClick()

c.JSON(http.StatusOK, Response{Code: http.StatusOK, Msg: "Get push stat success", Data: ps})
}

func (h *Handler) pushMessageStatHandler(c *gin.Context) {
req := &dto.PushStatRequest{}
if err := c.ShouldBindJSON(req); err != nil {
h.logger.Error(err, "failed to bind request")
c.JSON(http.StatusBadRequest, Response{Code: http.StatusBadRequest, Msg: err.Error(), Data: nil})
return
}

h.logger.Info("Received pushMessageStat request", "appid", req.AppID)

service, err := h.factory.GetPushService(consts.Platform(req.Platform).String())
if err != nil {
c.JSON(http.StatusBadRequest, Response{Code: http.StatusBadRequest, Msg: err.Error(), Data: nil})
return
}

vps := &notify.VivoPushStats{}
if err := service.GetNotifyStatus(c, req.AppID, req.NotifyID, vps); err != nil {
c.JSON(http.StatusBadRequest, Response{Code: http.StatusBadRequest, Msg: err.Error(), Data: nil})
return
}
c.JSON(http.StatusOK, Response{Code: http.StatusOK, Msg: "Get push message stat success", Data: vps})
}
Loading

0 comments on commit bb665bc

Please sign in to comment.