update
This commit is contained in:
@@ -123,6 +123,38 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
RecentPlayReq {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
LeastPlayTime int64 `json:"leastPlayTime"` // Least playtime in seconds to filter by
|
||||
}
|
||||
RecentPlayResp {
|
||||
Players []RecentPlayRespPlayer `json:"players"` // List of players who played in the time range
|
||||
}
|
||||
RecentPlayRespPlayer {
|
||||
SteamID64 string `json:"steamID64"` // Player's SteamID64
|
||||
UserName string `json:"userName"` // Player's username at the time of playing
|
||||
MapName string `json:"mapName"` // Map name where the player played
|
||||
PlayTime int64 `json:"playTime"` // Playtime in seconds during the time range
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
TopPlayTimeReq {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
}
|
||||
TopPlayTimeResp {
|
||||
Players []TopPlayTimeRespPlayer `json:"players"` // List of top players by playtime
|
||||
}
|
||||
TopPlayTimeRespPlayer {
|
||||
SteamID64 string `json:"steamID64"` // Player's SteamID64
|
||||
UserName string `json:"userName"` // Player's username at the time of playing
|
||||
PlayTime int64 `json:"playTime"` // Playtime in seconds during the time range
|
||||
}
|
||||
)
|
||||
|
||||
@server (
|
||||
prefix: /api/server/statistics
|
||||
)
|
||||
@@ -189,5 +221,26 @@ service ServerStatistics {
|
||||
)
|
||||
@handler recentJoinPlayerHandler
|
||||
post /recent-join-player (RecentJoinPlayerReq) returns (RecentJoinPlayerResp)
|
||||
|
||||
@doc (
|
||||
summary: "Get recent chat messages within a specified time range"
|
||||
description: "Get recent chat messages within a specified time range"
|
||||
)
|
||||
@handler recentChatMessageHandler
|
||||
post /recent-chat-message (RecentChatMessageReq) returns (RecentChatMessageResp)
|
||||
|
||||
@doc (
|
||||
summary: "Get recent players who played within a specified time range"
|
||||
description: "Get recent players who played within a specified time range"
|
||||
)
|
||||
@handler recentPlayHandler
|
||||
post /recent-play (RecentPlayReq) returns (RecentPlayResp)
|
||||
|
||||
@doc (
|
||||
summary: "Get top players by playtime within a specified time range"
|
||||
description: "Get top players by playtime within a specified time range"
|
||||
)
|
||||
@handler topPlayTimeHandler
|
||||
post /top-play-time (TopPlayTimeReq) returns (TopPlayTimeResp)
|
||||
}
|
||||
|
||||
|
||||
29
src/internal/handler/recentchatmessagehandler.go
Normal file
29
src/internal/handler/recentchatmessagehandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"src/internal/logic"
|
||||
"src/internal/svc"
|
||||
"src/internal/types"
|
||||
)
|
||||
|
||||
// Get recent chat messages within a specified time range
|
||||
func recentChatMessageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.RecentChatMessageReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewRecentChatMessageLogic(r.Context(), svcCtx)
|
||||
resp, err := l.RecentChatMessage(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/internal/handler/recentplayhandler.go
Normal file
29
src/internal/handler/recentplayhandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"src/internal/logic"
|
||||
"src/internal/svc"
|
||||
"src/internal/types"
|
||||
)
|
||||
|
||||
// Get recent players who played within a specified time range
|
||||
func recentPlayHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.RecentPlayReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewRecentPlayLogic(r.Context(), svcCtx)
|
||||
resp, err := l.RecentPlay(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,18 +20,36 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/ping",
|
||||
Handler: pingHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Get recent chat messages within a specified time range
|
||||
Method: http.MethodPost,
|
||||
Path: "/recent-chat-message",
|
||||
Handler: recentChatMessageHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Get recent players who joined within a specified time range
|
||||
Method: http.MethodPost,
|
||||
Path: "/recent-join-player",
|
||||
Handler: recentJoinPlayerHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Get recent players who played within a specified time range
|
||||
Method: http.MethodPost,
|
||||
Path: "/recent-play",
|
||||
Handler: recentPlayHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Get recent player joins within a specified time range
|
||||
Method: http.MethodPost,
|
||||
Path: "/recent-player-join",
|
||||
Handler: recentPlayerJoinHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Get top players by playtime within a specified time range
|
||||
Method: http.MethodPost,
|
||||
Path: "/top-play-time",
|
||||
Handler: topPlayTimeHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Get total chat message count within a specified time range
|
||||
Method: http.MethodPost,
|
||||
|
||||
29
src/internal/handler/topplaytimehandler.go
Normal file
29
src/internal/handler/topplaytimehandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"src/internal/logic"
|
||||
"src/internal/svc"
|
||||
"src/internal/types"
|
||||
)
|
||||
|
||||
// Get top players by playtime within a specified time range
|
||||
func topPlayTimeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TopPlayTimeReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewTopPlayTimeLogic(r.Context(), svcCtx)
|
||||
resp, err := l.TopPlayTime(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
31
src/internal/logic/recentchatmessagelogic.go
Normal file
31
src/internal/logic/recentchatmessagelogic.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"src/internal/svc"
|
||||
"src/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type RecentChatMessageLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// Get recent chat messages within a specified time range
|
||||
func NewRecentChatMessageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RecentChatMessageLogic {
|
||||
return &RecentChatMessageLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *RecentChatMessageLogic) RecentChatMessage(req *types.RecentChatMessageReq) (resp *types.RecentChatMessageResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
||||
31
src/internal/logic/recentplaylogic.go
Normal file
31
src/internal/logic/recentplaylogic.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"src/internal/svc"
|
||||
"src/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type RecentPlayLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// Get recent players who played within a specified time range
|
||||
func NewRecentPlayLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RecentPlayLogic {
|
||||
return &RecentPlayLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *RecentPlayLogic) RecentPlay(req *types.RecentPlayReq) (resp *types.RecentPlayResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
||||
31
src/internal/logic/topplaytimelogic.go
Normal file
31
src/internal/logic/topplaytimelogic.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"src/internal/svc"
|
||||
"src/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type TopPlayTimeLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// Get top players by playtime within a specified time range
|
||||
func NewTopPlayTimeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TopPlayTimeLogic {
|
||||
return &TopPlayTimeLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *TopPlayTimeLogic) TopPlayTime(req *types.TopPlayTimeReq) (resp *types.TopPlayTimeResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
||||
@@ -42,6 +42,38 @@ type RecentJoinPlayerRespPlayer struct {
|
||||
PlayTime int64 `json:"playTime"` // Playtime in seconds since joining
|
||||
}
|
||||
|
||||
type RecentPlayReq struct {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
LeastPlayTime int64 `json:"leastPlayTime"` // Least playtime in seconds to filter by
|
||||
}
|
||||
|
||||
type RecentPlayResp struct {
|
||||
Players []RecentPlayRespPlayer `json:"players"` // List of players who played in the time range
|
||||
}
|
||||
|
||||
type RecentPlayRespPlayer struct {
|
||||
SteamID64 string `json:"steamID64"` // Player's SteamID64
|
||||
UserName string `json:"userName"` // Player's username at the time of playing
|
||||
MapName string `json:"mapName"` // Map name where the player played
|
||||
PlayTime int64 `json:"playTime"` // Playtime in seconds during the time range
|
||||
}
|
||||
|
||||
type TopPlayTimeReq struct {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
}
|
||||
|
||||
type TopPlayTimeResp struct {
|
||||
Players []TopPlayTimeRespPlayer `json:"players"` // List of top players by playtime
|
||||
}
|
||||
|
||||
type TopPlayTimeRespPlayer struct {
|
||||
SteamID64 string `json:"steamID64"` // Player's SteamID64
|
||||
UserName string `json:"userName"` // Player's username at the time of playing
|
||||
PlayTime int64 `json:"playTime"` // Playtime in seconds during the time range
|
||||
}
|
||||
|
||||
type TotalChatMessageCountReq struct {
|
||||
TimeRangeStart int64 `json:"timeRangeStart"` // Unix timestamp in milliseconds
|
||||
TimeRangeEnd int64 `json:"timeRangeEnd"` // Unix timestamp in milliseconds
|
||||
|
||||
Reference in New Issue
Block a user