From 6d31da1874165c7ed7a68e1734448d470ae3503b Mon Sep 17 00:00:00 2001 From: yml2213 Date: Wed, 16 Sep 2026 14:46:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin-order):=20=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=B1=95=E7=A4=BA=E5=AE=8C=E6=95=B4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=89=8B=E6=9C=BA=E5=8F=B7=E4=BE=BF=E4=BA=8E=E5=AE=A2?= =?UTF-8?q?=E6=9C=8D=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - backend: AdminOrderListItemDTO 不再脱敏 owner_phone/renter_phone,移除 order 包内已无用的 maskPhone - frontend: 同步 AdminOrderListItem 类型注释 - tests: 更新后台列表用例为断言完整手机号,并继续校验不泄露账号快照 --- backend/internal/modules/order/dto.go | 2 +- backend/internal/modules/order/presenter.go | 11 ++--------- backend/internal/modules/order/presenter_test.go | 9 ++++++--- frontend/src/features/orders/api/orders.ts | 2 +- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/backend/internal/modules/order/dto.go b/backend/internal/modules/order/dto.go index 4d3fb4c..cab9fa4 100644 --- a/backend/internal/modules/order/dto.go +++ b/backend/internal/modules/order/dto.go @@ -106,7 +106,7 @@ type UserOrderListItemDTO struct { CreatedAt time.Time `json:"created_at"` } -// AdminOrderListItemDTO 是后台订单表格的最小展示数据,敏感详情仅由详情接口按权限获取。 +// AdminOrderListItemDTO 是后台订单表格的最小展示数据;手机号按客服需要返回完整值,其余敏感详情仅由详情接口按权限获取。 type AdminOrderListItemDTO struct { ID uint64 `json:"id"` OrderNo string `json:"order_no"` diff --git a/backend/internal/modules/order/presenter.go b/backend/internal/modules/order/presenter.go index 7a9f958..6782ef2 100644 --- a/backend/internal/modules/order/presenter.go +++ b/backend/internal/modules/order/presenter.go @@ -205,8 +205,8 @@ func (row orderRow) toAdminListItem() AdminOrderListItemDTO { OrderNo: row.OrderNo, ListingID: row.ListingID, ListingNo: row.ListingNo, - OwnerPhone: maskPhone(row.OwnerPhone), - RenterPhone: maskPhone(row.RenterPhone), + OwnerPhone: row.OwnerPhone, + RenterPhone: row.RenterPhone, Title: row.Title, ServerRegion: row.ServerRegion, LoginPlatform: row.LoginPlatform, @@ -221,13 +221,6 @@ func (row orderRow) toAdminListItem() AdminOrderListItemDTO { } } -func maskPhone(phone string) string { - if len(phone) < 7 { - return "" - } - return phone[:3] + "****" + phone[len(phone)-4:] -} - func effectiveHandoffMode(order model.RentalOrder) string { if order.HandoffMode != "" { return order.HandoffMode diff --git a/backend/internal/modules/order/presenter_test.go b/backend/internal/modules/order/presenter_test.go index 4b4b558..a5a38de 100644 --- a/backend/internal/modules/order/presenter_test.go +++ b/backend/internal/modules/order/presenter_test.go @@ -72,7 +72,7 @@ func TestUserOrderListItemDoesNotSerializeDetailFields(t *testing.T) { } } -func TestAdminOrderListItemMasksPhonesAndOmitsSnapshot(t *testing.T) { +func TestAdminOrderListItemShowsPhonesAndOmitsSnapshot(t *testing.T) { row := orderRow{ RentalOrder: model.RentalOrder{ID: 1, OrderNo: "ORD-001", Status: orderStatusPendingPayment}, OwnerPhone: "13800001234", @@ -83,8 +83,11 @@ func TestAdminOrderListItemMasksPhonesAndOmitsSnapshot(t *testing.T) { t.Fatalf("Marshal() error = %v", err) } text := string(raw) - if strings.Contains(text, "13800001234") || strings.Contains(text, "13900005678") { - t.Fatalf("list response contains full phone number: %s", text) + // 后台订单列表需要展示完整手机号,方便客服定位用户。 + for _, phone := range []string{"13800001234", "13900005678"} { + if !strings.Contains(text, phone) { + t.Fatalf("list response should contain full phone %q: %s", phone, text) + } } if strings.Contains(text, "account_snapshot") { t.Fatalf("list response contains account snapshot: %s", text) diff --git a/frontend/src/features/orders/api/orders.ts b/frontend/src/features/orders/api/orders.ts index 38ef07e..8a1ade3 100644 --- a/frontend/src/features/orders/api/orders.ts +++ b/frontend/src/features/orders/api/orders.ts @@ -98,7 +98,7 @@ export interface UserOrderListItem { created_at: string } -// 后台订单列表使用脱敏后的表格数据,敏感字段仅在详情接口中按权限返回。 +// 后台订单列表返回客服需要的完整用户手机号,其余敏感字段仅在详情接口中按权限返回。 export interface AdminOrderListItem { id: number order_no: string