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
+8 -2
View File
@@ -75,6 +75,8 @@ func TestBusinessHTTPListWithSystemOnlyAndCompleteDatabase(t *testing.T) {
c.Next()
})
router.RegisterBusiness(engine.Group(""), handler.NewBusiness(prefs, accounts, bindings))
promotes := handler.NewBusinessPromote(businessservice.NewBusinessPromoteService(businessbiz.NewBusinessPromoteUsecase(businessdata.NewBusinessPromoteRepo(provider), accountUsecase)))
engine.GET("/sw/business/:userId/promotes", promotes.List)
server := httptest.NewServer(engine)
defer server.Close()
requestList := func() map[string]any {
@@ -106,10 +108,10 @@ func TestBusinessHTTPListWithSystemOnlyAndCompleteDatabase(t *testing.T) {
if rows[2].(map[string]any)["promoteCount"] != float64(0) {
t.Fatal("无绑定账号的直属渠道应明确为零")
}
if err := db.Exec("CREATE TABLE tab_promote(id INTEGER,source_db TEXT,busier_id INTEGER,promote_level INTEGER)").Error; err != nil {
if err := db.Exec("CREATE TABLE tab_promote(id INTEGER,source_db TEXT,busier_id INTEGER,promote_level INTEGER,account TEXT)").Error; err != nil {
t.Fatal(err)
}
if err := db.Exec("INSERT INTO tab_promote VALUES(1,'lx',9,1),(2,'lx',9,2),(1,'hw',9,1)").Error; err != nil {
if err := db.Exec("INSERT INTO tab_promote VALUES(1,'lx',9,1,'测试渠道'),(2,'lx',9,2,'下级渠道'),(1,'hw',9,1,'其他平台')").Error; err != nil {
t.Fatal(err)
}
data = requestList()
@@ -137,6 +139,10 @@ func TestBusinessHTTPListWithSystemOnlyAndCompleteDatabase(t *testing.T) {
return value
}
created := call("POST", "/sw/business", `{"userName":"http_child","realName":"接口测试","password":"abc123"}`, "")["data"].(map[string]any)
channels := call("GET", "/sw/business/2/promotes", "", "")["data"].(map[string]any)
if channels["total"] != float64(1) || channels["rows"].([]any)[0].(map[string]any)["promoteName"] != "测试渠道" {
t.Fatalf("HTTP 旗下渠道范围错误: %+v", channels)
}
if created["userId"] != float64(4) || created["level"] != float64(1) || created["authorityId"] != float64(901) {
t.Fatalf("HTTP 新增层级或角色不正确: %+v", created)
}
+7 -2
View File
@@ -82,11 +82,15 @@ func wireApp(configServer *config.Server, store *config.Store, logger *slog.Logg
auditRecorderUsecase := system2.NewAuditRecorderUsecase(auditRecordRepo)
auditRecorder := system3.NewAuditRecorder(auditRecorderUsecase)
registry := taskRegistry()
businessPromoteRepo := business.NewBusinessPromoteRepo(dataData)
accountRepo := business.NewAccountRepo(dataData)
accountUsecase := business2.NewAccountUsecase(accountRepo)
businessPromoteUsecase := business2.NewBusinessPromoteUsecase(businessPromoteRepo, accountUsecase)
businessPromoteService := business3.NewBusinessPromoteService(businessPromoteUsecase)
businessPromote := handler.NewBusinessPromote(businessPromoteService)
userPreferenceRepo := business.NewUserPreferenceRepo(dataData)
userPreferenceUsecase := business2.NewUserPreferenceUsecase(userPreferenceRepo)
userPreferenceService := business3.NewUserPreferenceService(userPreferenceUsecase)
accountRepo := business.NewAccountRepo(dataData)
accountUsecase := business2.NewAccountUsecase(accountRepo)
accountService := business3.NewAccountService(accountUsecase)
bindingRepo := business.NewBindingRepo(dataData)
platformAccountRepo := business.NewPlatformAccountRepo(dataData)
@@ -197,6 +201,7 @@ func wireApp(configServer *config.Server, store *config.Store, logger *slog.Logg
integrationConfigService := integration2.NewIntegrationConfigService(integrationConfigUsecase)
integrationConfig := handler.NewIntegrationConfig(integrationConfigService)
set := &handler.Set{
BusinessPromote: businessPromote,
Business: handlerBusiness,
BusinessPassword: businessPassword,
SMS: handlerSMS,