feat: 迁移渠道列表新增和游戏累计分布

This commit is contained in:
Yvan
2026-11-03 21:32:51 +08:00
parent 5e58c6bcf3
commit 075d94a51e
39 changed files with 2216 additions and 12 deletions
+2 -1
View File
@@ -26,6 +26,7 @@ func NewGinEngine(runtime *config.Store, access *systemservice.AccessControlServ
func emptyHandlers() *handler.Set {
return &handler.Set{
Channel: &handler.Channel{},
Activation: &handler.Activation{},
AlertRecord: &handler.AlertRecord{},
AlertRule: &handler.AlertRule{},
@@ -102,7 +103,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":229`) {
if !strings.Contains(text, `"msg":"router register success"`) || !strings.Contains(text, `"route_count":233`) {
t.Fatalf("startup route summary is missing: %s", text)
}
}
+61
View File
@@ -0,0 +1,61 @@
package handler
import (
"github.com/gin-gonic/gin"
"github.com/go-kratos/kratos/v3/errors"
"kra/internal/service/business"
"kra/internal/service/dto"
"net/http"
)
type Channel struct{ service *business.ChannelService }
func NewChannel(service *business.ChannelService) *Channel { return &Channel{service: service} }
func (h *Channel) List(c *gin.Context) {
var req dto.ChannelQuery
if c.ShouldBindQuery(&req) != nil {
Fail(c, "渠道查询参数不正确")
return
}
result, err := h.service.List(c.Request.Context(), &req)
if err != nil {
Fail(c, errors.FromError(err).Message)
return
}
OKWithData(c, result)
}
func (h *Channel) Bindings(c *gin.Context) {
result, err := h.service.BindOptions(c.Request.Context(), c.Query("sourceDb"))
if err != nil {
Fail(c, errors.FromError(err).Message)
return
}
OKWithData(c, result)
}
func (h *Channel) Create(c *gin.Context) {
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, 1<<20)
var req dto.ChannelCreateRequest
if c.ShouldBindJSON(&req) != nil {
Fail(c, "渠道参数不正确")
return
}
result, err := h.service.Create(c.Request.Context(), &req)
if err != nil {
Fail(c, errors.FromError(err).Message)
return
}
Write(c, CodeSuccess, result, "添加成功,数据同步到列表可能有延迟")
}
func (h *Channel) Games(c *gin.Context) {
var req dto.ChannelGameQuery
if c.ShouldBindQuery(&req) != nil {
Fail(c, "渠道查询参数不正确")
return
}
result, err := h.service.Games(c.Request.Context(), &req)
if err != nil {
Fail(c, errors.FromError(err).Message)
return
}
OKWithData(c, result)
}
+1
View File
@@ -11,6 +11,7 @@ var ProviderSet = wire.NewSet(
NewAlertRule,
NewAlertRecord,
NewActivation,
NewChannel,
NewAuthority, NewMenu, NewAPI, NewPermission, NewOrganization,
NewAnnouncement, NewEmail, NewPayment, NewTask, NewMedia, NewAudit,
NewExport, NewVersion, NewDictionary, NewParameter, NewAPIToken,
+1
View File
@@ -1,6 +1,7 @@
package handler
type Set struct {
Channel *Channel
Activation *Activation
AlertRecord *AlertRecord
AlertRule *AlertRule
+14
View File
@@ -0,0 +1,14 @@
package router
import (
"github.com/gin-gonic/gin"
"kra/internal/server/handler"
)
func RegisterChannel(private *gin.RouterGroup, h *handler.Channel) {
g := private.Group("/sw/promote")
g.GET("/list", h.List)
g.GET("/bindOptions", h.Bindings)
g.GET("/game-distribution", h.Games)
g.POST("", h.Create)
}
+1
View File
@@ -20,6 +20,7 @@ func (r *Routes) RegisterRoutes(public, private *gin.RouterGroup, engine *gin.En
return
}
registrations := []func(){
func() { RegisterChannel(private, r.handlers.Channel) },
func() {
private.GET("/sw/promoteActivePool/bindList", r.handlers.Activation.List)
private.GET("/sw/promoteActivePool/bindSpendDetail", r.handlers.Activation.SpendDetail)