fonchain-fiee/pkg/service/artistInfo/functionTest/stomeTest.go

58 lines
1.6 KiB
Go
Raw Normal View History

2025-02-19 06:24:15 +00:00
// Package functionTest -----------------------------
// @file : stomeTest.go
// @author : JJXu
// @contact : wavingbear@163.com
// @time : 2023/9/19 9:14
// -------------------------------------------
package functionTest
import (
"github.com/fonchain_enterprise/fonchain-main/pkg/common/push"
"github.com/fonchain_enterprise/fonchain-main/pkg/e"
"github.com/fonchain_enterprise/fonchain-main/pkg/service"
"github.com/gin-gonic/gin"
)
var Handler = new(handle)
type handle struct {
}
type AppPushRequest struct {
AudienceAlias []string `json:"audienceAlias"`
Title string `json:"title"`
Alert string `json:"alert"`
AndroidIntent string `json:"androidIntent"`
Extras map[string]any `json:"extras"`
}
func (handle) AppPush(c *gin.Context) {
var req AppPushRequest
if err := c.ShouldBindJSON(&req); err != nil {
service.Error(c, e.InvalidParams, err, "无效参数")
return
}
p := push.NewPusher("0b88f8b6eb25182558bdb795", "deeae95db7c05371cb1c0ff5", push.NewIosPlatform("com.fonchain.artist"), push.NewAndroidPlatform("uni.UNID335ADB"))
if req.AudienceAlias != nil {
p.Audience.SetAlias(req.AudienceAlias)
} else {
p.Audience.All()
}
p.Notice.Title = req.Title
p.Notice.Alert = req.Alert
//设置跳转页
if req.AndroidIntent != "" {
p.SetAndroidIntentPage(req.AndroidIntent)
}
////携带参数
if req.Extras != nil {
for k, v := range req.Extras {
p.SetExtrasKeyVale(k, v)
}
}
if err := p.PushNotify(); err != nil {
service.ErrorWithMark(c, e.Failed, err, "AppPushPushNotify", "消息发送失败")
return
}
service.Success(c)
}