feat: 迁移渠道与游戏统计及全量汇总
This commit is contained in:
@@ -26,6 +26,7 @@ func NewGinEngine(runtime *config.Store, access *systemservice.AccessControlServ
|
||||
|
||||
func emptyHandlers() *handler.Set {
|
||||
return &handler.Set{
|
||||
Analytics: &handler.Analytics{},
|
||||
Ledger: &handler.Ledger{},
|
||||
ChannelPortrait: &handler.ChannelPortrait{},
|
||||
BusinessPortrait: &handler.BusinessPortrait{},
|
||||
@@ -106,7 +107,7 @@ func TestGinStartupLogsEveryRegisteredRoute(t *testing.T) {
|
||||
if got, want := strings.Count(text, `"msg":"router registered"`), len(engine.Routes()); got != want {
|
||||
t.Fatalf("registered route log count = %d, want %d", got, want)
|
||||
}
|
||||
if !strings.Contains(text, `"msg":"router register success"`) || !strings.Contains(text, `"route_count":241`) {
|
||||
if !strings.Contains(text, `"msg":"router register success"`) || !strings.Contains(text, `"route_count":243`) {
|
||||
t.Fatalf("startup route summary is missing: %s", text)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-kratos/kratos/v3/errors"
|
||||
"kra/internal/service/business"
|
||||
"kra/internal/service/dto"
|
||||
)
|
||||
|
||||
type Analytics struct{ service *business.AnalyticsService }
|
||||
|
||||
func NewAnalytics(service *business.AnalyticsService) *Analytics { return &Analytics{service: service} }
|
||||
func (h *Analytics) Channels(c *gin.Context) {
|
||||
var req dto.AnalyticsQuery
|
||||
if c.ShouldBindQuery(&req) != nil {
|
||||
Fail(c, "统计查询参数不正确")
|
||||
return
|
||||
}
|
||||
data, err := h.service.Channels(c.Request.Context(), &req)
|
||||
if err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OKWithData(c, data)
|
||||
}
|
||||
func (h *Analytics) Games(c *gin.Context) {
|
||||
var req dto.AnalyticsQuery
|
||||
if c.ShouldBindQuery(&req) != nil {
|
||||
Fail(c, "统计查询参数不正确")
|
||||
return
|
||||
}
|
||||
data, err := h.service.Games(c.Request.Context(), &req)
|
||||
if err != nil {
|
||||
Fail(c, errors.FromError(err).Message)
|
||||
return
|
||||
}
|
||||
OKWithData(c, data)
|
||||
}
|
||||
@@ -15,6 +15,7 @@ var ProviderSet = wire.NewSet(
|
||||
NewBusinessPortrait,
|
||||
NewChannelPortrait,
|
||||
NewLedger,
|
||||
NewAnalytics,
|
||||
NewAuthority, NewMenu, NewAPI, NewPermission, NewOrganization,
|
||||
NewAnnouncement, NewEmail, NewPayment, NewTask, NewMedia, NewAudit,
|
||||
NewExport, NewVersion, NewDictionary, NewParameter, NewAPIToken,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
type Set struct {
|
||||
Analytics *Analytics
|
||||
Ledger *Ledger
|
||||
ChannelPortrait *ChannelPortrait
|
||||
BusinessPortrait *BusinessPortrait
|
||||
|
||||
@@ -20,6 +20,10 @@ func (r *Routes) RegisterRoutes(public, private *gin.RouterGroup, engine *gin.En
|
||||
return
|
||||
}
|
||||
registrations := []func(){
|
||||
func() {
|
||||
private.GET("/sw/channelData/list", r.handlers.Analytics.Channels)
|
||||
private.GET("/sw/gameData/list", r.handlers.Analytics.Games)
|
||||
},
|
||||
func() { RegisterLedger(private, r.handlers.Ledger) },
|
||||
func() { private.GET("/sw/promote/portrait", r.handlers.ChannelPortrait.Portrait) },
|
||||
func() {
|
||||
|
||||
Reference in New Issue
Block a user