From 4cf5c09b0f4bad9fb7c0feb61aba2fa71f30d8f0 Mon Sep 17 00:00:00 2001 From: johlanse Date: Sun, 30 Oct 2022 22:41:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9Bbug,?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0pushPlus=E7=BE=A4=E7=BB=84=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/config.go | 1 + push/pushPlus.go | 2 ++ web/controller.go | 32 +++++++++++++++++++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/conf/config.go b/conf/config.go index f361890..2397283 100644 --- a/conf/config.go +++ b/conf/config.go @@ -30,6 +30,7 @@ type Config struct { PushPlus struct { Enable bool `json:"enable" yaml:"enable" mapstructure:"enable"` Token string `json:"token" yaml:"token" mapstructure:"token"` + Topic string `json:"topic" yaml:"topic" mapstructure:"topic"` } `json:"push_plus" yaml:"push_plus" mapstructure:"push_plus"` } `json:"push" yaml:"push" mapstructure:"push"` TG struct { diff --git a/push/pushPlus.go b/push/pushPlus.go index 5d98267..b9252d5 100644 --- a/push/pushPlus.go +++ b/push/pushPlus.go @@ -6,6 +6,7 @@ import ( log "github.com/sirupsen/logrus" + "github.com/johlanse/study_xxqg/conf" "github.com/johlanse/study_xxqg/utils" ) @@ -21,6 +22,7 @@ func (p *PushPlus) Init() func(id string, kind, message string) { "content": data, "template": "markdown", "channel": "wechat", + "topic": conf.GetConfig().Push.PushPlus.Topic, }).Post("http://www.pushplus.plus/send") if err != nil { log.Errorln(err.Error()) diff --git a/web/controller.go b/web/controller.go index 94e8892..07dc6e2 100644 --- a/web/controller.go +++ b/web/controller.go @@ -186,13 +186,31 @@ func getExpiredUser() gin.HandlerFunc { } return } - ctx.JSON(200, Resp{ - Code: 200, - Message: "", - Data: failUser, - Success: true, - Error: "", - }) + level := ctx.GetInt("level") + if level == 1 { + ctx.JSON(200, Resp{ + Code: 200, + Message: "", + Data: failUser, + Success: true, + Error: "", + }) + } else { + var myFaileUser []*model.User + for _, user := range failUser { + if user.Token == ctx.GetString("token") { + myFaileUser = append(myFaileUser, user) + } + } + ctx.JSON(200, Resp{ + Code: 200, + Message: "", + Data: myFaileUser, + Success: true, + Error: "", + }) + } + } }