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)
}