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: "", + }) + } + } }