feat: 迁移区服分析与游戏区服查询
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package business
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kra/internal/biz/business"
|
||||
"kra/internal/service/dto"
|
||||
)
|
||||
|
||||
type ServerAnalysisUsecase interface {
|
||||
List(context.Context, business.ServerAnalysisFilter, int, int) (*business.ServerAnalysisPage, error)
|
||||
Servers(context.Context, []string, []string, string, int) ([]*business.ServerOption, error)
|
||||
}
|
||||
type ServerAnalysisService struct{ uc ServerAnalysisUsecase }
|
||||
|
||||
func NewServerAnalysisService(uc *business.ServerAnalysisUsecase) *ServerAnalysisService {
|
||||
return &ServerAnalysisService{uc: uc}
|
||||
}
|
||||
func serverAnalysisResponse(row *business.ServerAnalysisRow, summary bool) *dto.ServerAnalysisRow {
|
||||
out := &dto.ServerAnalysisRow{SourceDB: row.SourceDB, SourceDBLabel: business.PlatformName(row.SourceDB), GameName: row.GameName, ServerOptionResponse: dto.ServerOptionResponse{Number: row.ServerNum, Name: row.ServerName, OpenTime: row.OpenTime}, Register: row.Counts.Register, Active: row.Counts.Active, PayUsers: row.Counts.Pay, Pay: row.Pay, ARPU: row.ARPU}
|
||||
if !summary {
|
||||
out.GameID = &row.GameID
|
||||
}
|
||||
return out
|
||||
}
|
||||
func (s *ServerAnalysisService) List(ctx context.Context, req *dto.ServerAnalysisQuery) (*dto.ServerAnalysisPage, error) {
|
||||
if req == nil {
|
||||
return nil, business.ErrAnalyticsInput
|
||||
}
|
||||
f, err := analyticsRequest(&dto.AnalyticsQuery{Sources: req.Sources, GameNames: req.GameNames, BeginTime: req.BeginTime, EndTime: req.EndTime, SortField: req.SortField, SortOrder: req.SortOrder})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
page, err := s.uc.List(ctx, business.ServerAnalysisFilter{AnalyticsFilter: f, ServerNum: req.ServerNum}, req.Page, req.PageSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := &dto.ServerAnalysisPage{Rows: []*dto.ServerAnalysisRow{}, Total: page.Total, Begin: page.Begin, End: page.End, Available: page.Available}
|
||||
for _, row := range page.Rows {
|
||||
out.Rows = append(out.Rows, serverAnalysisResponse(row, false))
|
||||
}
|
||||
if page.Summary != nil {
|
||||
out.Summary = serverAnalysisResponse(page.Summary, true)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
func (s *ServerAnalysisService) Servers(ctx context.Context, req *dto.ServerOptionQuery) ([]*dto.ServerOptionResponse, error) {
|
||||
if req == nil {
|
||||
return nil, business.ErrAnalyticsInput
|
||||
}
|
||||
sources, err := normalizePlatforms(req.Sources)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rows, err := s.uc.Servers(ctx, sources, splitQueryValues(req.GameNames), req.Keyword, req.Limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make([]*dto.ServerOptionResponse, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
out = append(out, &dto.ServerOptionResponse{Number: row.Number, Name: row.Name, OpenTime: row.OpenTime})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package dto
|
||||
|
||||
type ServerAnalysisQuery struct {
|
||||
Page int `form:"pageNum"`
|
||||
PageSize int `form:"pageSize"`
|
||||
Sources []string `form:"sourceDb"`
|
||||
GameNames []string `form:"gameName"`
|
||||
ServerNum string `form:"serverNum"`
|
||||
BeginTime string `form:"beginTime"`
|
||||
EndTime string `form:"endTime"`
|
||||
SortField string `form:"sortField"`
|
||||
SortOrder string `form:"sortOrder"`
|
||||
}
|
||||
type ServerOptionQuery struct {
|
||||
Sources []string `form:"sourceDb"`
|
||||
GameNames []string `form:"gameName"`
|
||||
Keyword string `form:"keyword"`
|
||||
Limit int `form:"limit"`
|
||||
}
|
||||
type ServerOptionResponse struct {
|
||||
Number string `json:"serverNum"`
|
||||
Name string `json:"serverName"`
|
||||
OpenTime *int64 `json:"openTime"`
|
||||
}
|
||||
type ServerAnalysisRow struct {
|
||||
SourceDB string `json:"sourceDb"`
|
||||
SourceDBLabel string `json:"sourceDbLabel"`
|
||||
GameID *int64 `json:"gameId"`
|
||||
GameName string `json:"gameName"`
|
||||
ServerOptionResponse
|
||||
Register int64 `json:"newRegisterCount"`
|
||||
Active int64 `json:"activeCount"`
|
||||
PayUsers int64 `json:"payUserCount"`
|
||||
Pay string `json:"totalPay"`
|
||||
ARPU string `json:"arpu"`
|
||||
}
|
||||
type ServerAnalysisPage struct {
|
||||
Rows []*ServerAnalysisRow `json:"rows"`
|
||||
Total int64 `json:"total"`
|
||||
Summary *ServerAnalysisRow `json:"summary"`
|
||||
Begin string `json:"beginTime"`
|
||||
End string `json:"endTime"`
|
||||
Available bool `json:"available"`
|
||||
}
|
||||
@@ -25,6 +25,7 @@ var ProviderSet = wire.NewSet(
|
||||
businessservice.NewChannelPortraitService,
|
||||
businessservice.NewLedgerService,
|
||||
businessservice.NewAnalyticsService,
|
||||
businessservice.NewServerAnalysisService,
|
||||
systemservice.ProviderSet,
|
||||
paymentservice.ProviderSet,
|
||||
integrationservice.ProviderSet,
|
||||
|
||||
Reference in New Issue
Block a user