feat: 迁移商务旗下渠道查询和抽屉

This commit is contained in:
Yvan
2026-11-03 19:20:42 +08:00
parent 8048dfb514
commit cd42a1d3f0
29 changed files with 409 additions and 20 deletions
@@ -0,0 +1,51 @@
package business
import (
"context"
"kra/internal/biz/business"
"kra/internal/service/dto"
)
type BusinessPromoteUsecase interface {
List(context.Context, business.BusinessPromoteFilter, ...business.ListOption) (*business.BusinessPromotePage, error)
}
type BusinessPromoteService struct{ uc BusinessPromoteUsecase }
func NewBusinessPromoteService(uc *business.BusinessPromoteUsecase) *BusinessPromoteService {
return &BusinessPromoteService{uc: uc}
}
func (s *BusinessPromoteService) List(ctx context.Context, id uint, req *dto.BusinessPromoteQuery) (*dto.BusinessPromotePage, error) {
if req == nil || id == 0 {
return nil, business.ErrAccountInput
}
filter := business.BusinessPromoteFilter{UserID: id, BusierID: req.PlatformBusierID}
if req.SourceDB != "" {
source, err := business.NormalizePlatform(req.SourceDB)
if err != nil {
return nil, err
}
filter.SourceDB = source
}
page, size := req.Page, req.PageSize
if page < 1 {
page = 1
}
if size < 1 {
size = 10
}
if size > 500 {
size = 500
}
if page > int(^uint(0)>>1)/size {
return nil, business.ErrAccountInput
}
result, err := s.uc.List(ctx, filter, business.ListOffset((page-1)*size), business.ListLimit(size))
if err != nil {
return nil, err
}
out := &dto.BusinessPromotePage{Rows: make([]*dto.BusinessPromoteResponse, 0, len(result.Rows)), Total: result.Total, Available: result.Available}
for _, row := range result.Rows {
out.Rows = append(out.Rows, &dto.BusinessPromoteResponse{PromoteID: row.ID, PromoteName: row.Account, SourceDB: row.SourceDB, PlatformName: business.PlatformName(row.SourceDB), PlatformBusierID: row.BusierID})
}
return out, nil
}
+20
View File
@@ -0,0 +1,20 @@
package dto
type BusinessPromoteQuery struct {
Page int `form:"pageNum"`
PageSize int `form:"pageSize"`
SourceDB string `form:"sourceDb"`
PlatformBusierID uint64 `form:"platformBusierId"`
}
type BusinessPromoteResponse struct {
PromoteID uint64 `json:"promoteId"`
PromoteName string `json:"promoteName"`
SourceDB string `json:"sourceDb"`
PlatformName string `json:"platformName"`
PlatformBusierID uint64 `json:"platformBusierId"`
}
type BusinessPromotePage struct {
Rows []*BusinessPromoteResponse `json:"rows"`
Total int64 `json:"total"`
Available bool `json:"available"`
}
+1
View File
@@ -16,6 +16,7 @@ var ProviderSet = wire.NewSet(
businessservice.NewAccountService,
businessservice.NewBindingService,
businessservice.NewPasswordResetService,
businessservice.NewBusinessPromoteService,
systemservice.ProviderSet,
paymentservice.ProviderSet,
integrationservice.ProviderSet,