feat: add total player count and total playtime logic
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 1m27s
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 1m27s
- Implemented TotalPlayerCountLogic to retrieve the total number of unique players within a specified time range. - Implemented TotalPlayTimeLogic to calculate the total playtime of players within a specified time range. - Created ServiceContext to manage database connections and initialize necessary tables. - Added types for total player count and total playtime requests and responses. - Set up the main server file to start the application with the necessary configurations. - Updated go.mod and go.sum for new dependencies.
This commit is contained in:
29
app/internal/handler/pinghandler.go
Normal file
29
app/internal/handler/pinghandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// Ping the server to check if it's alive
|
||||
func pingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.PingReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewPingLogic(r.Context(), svcCtx)
|
||||
resp, err := l.Ping(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/internal/handler/recentchatmessagehandler.go
Normal file
29
app/internal/handler/recentchatmessagehandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// 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
app/internal/handler/recentjoinplayerhandler.go
Normal file
29
app/internal/handler/recentjoinplayerhandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// Get recent players who joined within a specified time range
|
||||
func recentJoinPlayerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.RecentJoinPlayerReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewRecentJoinPlayerLogic(r.Context(), svcCtx)
|
||||
resp, err := l.RecentJoinPlayer(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/internal/handler/recentplayerjoinhandler.go
Normal file
29
app/internal/handler/recentplayerjoinhandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// Get recent player joins within a specified time range
|
||||
func recentPlayerJoinHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TotalPlayerJoinReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewRecentPlayerJoinLogic(r.Context(), svcCtx)
|
||||
resp, err := l.RecentPlayerJoin(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/internal/handler/recentplayhandler.go
Normal file
29
app/internal/handler/recentplayhandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
104
app/internal/handler/routes.go
Normal file
104
app/internal/handler/routes.go
Normal file
@@ -0,0 +1,104 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.8.4
|
||||
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// Get the list of monitored game servers
|
||||
Method: http.MethodGet,
|
||||
Path: "/list",
|
||||
Handler: ServerListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Ping the server to check if it's alive
|
||||
Method: http.MethodGet,
|
||||
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 kill count within a specified time range
|
||||
Method: http.MethodPost,
|
||||
Path: "/top-killer",
|
||||
Handler: topKillerHandler(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,
|
||||
Path: "/total-chat-message-count",
|
||||
Handler: totalChatMessageCountHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Get total connect count within a specified time range
|
||||
Method: http.MethodPost,
|
||||
Path: "/total-connect-count",
|
||||
Handler: totalConnectCountHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Get total damage count within a specified time range
|
||||
Method: http.MethodPost,
|
||||
Path: "/total-damage-count",
|
||||
Handler: totalDamageCountHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Get total kill count within a specified time range
|
||||
Method: http.MethodPost,
|
||||
Path: "/total-kill-count",
|
||||
Handler: totalKillCountHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Get total playtime within a specified time range
|
||||
Method: http.MethodPost,
|
||||
Path: "/total-play-time",
|
||||
Handler: totalPlayTimeHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// Get total player count within a specified time range
|
||||
Method: http.MethodPost,
|
||||
Path: "/total-player-count",
|
||||
Handler: totalPlayerCountHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/server/statistics"),
|
||||
)
|
||||
}
|
||||
29
app/internal/handler/serverlisthandler.go
Normal file
29
app/internal/handler/serverlisthandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// Get the list of monitored game servers
|
||||
func ServerListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ServerListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewServerListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.ServerList(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/internal/handler/topkillerhandler.go
Normal file
29
app/internal/handler/topkillerhandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// Get top players by kill count within a specified time range
|
||||
func topKillerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TopKillerReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewTopKillerLogic(r.Context(), svcCtx)
|
||||
resp, err := l.TopKiller(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/internal/handler/topplaytimehandler.go
Normal file
29
app/internal/handler/topplaytimehandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/internal/handler/totalchatmessagecounthandler.go
Normal file
29
app/internal/handler/totalchatmessagecounthandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// Get total chat message count within a specified time range
|
||||
func totalChatMessageCountHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TotalChatMessageCountReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewTotalChatMessageCountLogic(r.Context(), svcCtx)
|
||||
resp, err := l.TotalChatMessageCount(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/internal/handler/totalconnectcounthandler.go
Normal file
29
app/internal/handler/totalconnectcounthandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// Get total connect count within a specified time range
|
||||
func totalConnectCountHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TotalConnectCountReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewTotalConnectCountLogic(r.Context(), svcCtx)
|
||||
resp, err := l.TotalConnectCount(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/internal/handler/totaldamagecounthandler.go
Normal file
29
app/internal/handler/totaldamagecounthandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// Get total damage count within a specified time range
|
||||
func totalDamageCountHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TotalDamageCountReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewTotalDamageCountLogic(r.Context(), svcCtx)
|
||||
resp, err := l.TotalDamageCount(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/internal/handler/totalkillcounthandler.go
Normal file
29
app/internal/handler/totalkillcounthandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// Get total kill count within a specified time range
|
||||
func totalKillCountHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TotalKillCountReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewTotalKillCountLogic(r.Context(), svcCtx)
|
||||
resp, err := l.TotalKillCount(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/internal/handler/totalplayercounthandler.go
Normal file
29
app/internal/handler/totalplayercounthandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// Get total player count within a specified time range
|
||||
func totalPlayerCountHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TotalPlayerCountReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewTotalPlayerCountLogic(r.Context(), svcCtx)
|
||||
resp, err := l.TotalPlayerCount(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/internal/handler/totalplaytimehandler.go
Normal file
29
app/internal/handler/totalplaytimehandler.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/logic"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/svc"
|
||||
"git.cialloo.com/CiallooWeb/ServerStatistics/app/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
// Get total playtime within a specified time range
|
||||
func totalPlayTimeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TotalPlayTimeReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewTotalPlayTimeLogic(r.Context(), svcCtx)
|
||||
resp, err := l.TotalPlayTime(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user