-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
102 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package user | ||
|
||
import ( | ||
. "gin_bbs/app/controllers" | ||
"gin_bbs/app/helpers" | ||
"gin_bbs/app/viewmodels" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
// ActivedIndex 活跃用户列表 | ||
func ActivedIndex(c *gin.Context) { | ||
activeUsersVM := make([]map[string]interface{}, 0) | ||
activeUsers := helpers.NewActiveUser().GetActiveUsers() | ||
for _, v := range activeUsers { | ||
activeUsersVM = append(activeUsersVM, viewmodels.NewUserAPISerializer(v)) | ||
} | ||
|
||
SendOKResponse(c, ListData{ | ||
List: activeUsersVM, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package helpers | ||
|
||
import ( | ||
"gin_bbs/config" | ||
|
||
jpushclient "github.com/ylywyn/jpush-api-go-client" | ||
) | ||
|
||
var ( | ||
// JpushClient - | ||
JpushClient *JPush | ||
) | ||
|
||
// JPush 极光推送 | ||
type JPush struct { | ||
Key string | ||
Secret string | ||
} | ||
|
||
// NewJPush - | ||
func NewJPush() *JPush { | ||
return &JPush{ | ||
Key: config.AppConfig.JPushKey, | ||
Secret: config.AppConfig.JPushSecret, | ||
} | ||
} | ||
|
||
// Send - | ||
func (j *JPush) Send(content string, pushids []string) { | ||
var pf jpushclient.Platform | ||
pf.All() | ||
|
||
var ad jpushclient.Audience | ||
ad.SetID(pushids) | ||
|
||
var msg jpushclient.Message | ||
msg.Content = content | ||
|
||
payload := jpushclient.NewPushPayLoad() | ||
payload.SetPlatform(&pf) | ||
payload.SetAudience(&ad) | ||
payload.SetMessage(&msg) | ||
|
||
bytes, _ := payload.ToBytes() | ||
c := jpushclient.NewPushClient(j.Secret, j.Key) | ||
c.Send(bytes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,8 @@ WEIXIN: | |
APP_ID: | ||
APP_SECRET: | ||
REDIRECT_URL: # OAuth 授权后的跳转链接,默认为 APP.URL | ||
|
||
# 极光推送 | ||
JPUSH: | ||
KEY: | ||
SECRET: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters