fix admin bd leader status route

This commit is contained in:
zhx 2026-06-10 15:39:47 +08:00
parent 0dea7c9b43
commit 27ab1317d2
2 changed files with 19 additions and 1 deletions

View File

@ -143,7 +143,12 @@ func (h *Handler) SetBDStatus(c *gin.Context) {
}
func bdRoleFromStatusRoute(c *gin.Context) (string, string) {
if strings.HasPrefix(c.FullPath(), "/admin/bd-leaders/") {
return bdRoleFromStatusPath(c.FullPath())
}
func bdRoleFromStatusPath(fullPath string) (string, string) {
// FullPath 带有外层 /api/v1 分组;只要命中 BD Leader 状态路由片段,就必须走独立的 bd_leader_profiles避免误查普通 bd_profiles。
if strings.Contains(fullPath, "/admin/bd-leaders/") {
return "bd_leader", "bd_leader_profiles"
}
return "bd", "bd_profiles"

View File

@ -12,6 +12,19 @@ func TestNormalizeListQueryAllowsCoinSellerComputedSorts(t *testing.T) {
}
}
// TestBDRoleFromStatusPathUsesLeaderTableWithAPIPrefix 锁定线上真实 FullPath 带 /api/v1 前缀时BD Leader 状态仍然写独立负责人表。
func TestBDRoleFromStatusPathUsesLeaderTableWithAPIPrefix(t *testing.T) {
role, target := bdRoleFromStatusPath("/api/v1/admin/bd-leaders/:user_id/status")
if role != "bd_leader" || target != "bd_leader_profiles" {
t.Fatalf("leader status route must use bd_leader_profiles, got role=%q target=%q", role, target)
}
role, target = bdRoleFromStatusPath("/api/v1/admin/bds/:user_id/status")
if role != "bd" || target != "bd_profiles" {
t.Fatalf("bd status route must use bd_profiles, got role=%q target=%q", role, target)
}
}
// TestSortCoinSellerListItemsComputedFields 验证 wallet 聚合字段排序只改变展示顺序,不改动币商身份数据。
func TestSortCoinSellerListItemsComputedFields(t *testing.T) {
items := []*CoinSellerListItem{