修复平台账户审计时间与联系电话展示

This commit is contained in:
czl231
2026-08-17 20:08:21 +08:00
parent 877b184de1
commit 80013e8c55
6 changed files with 84 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ func platformAccountView(account models.PlatformAccount) map[string]any {
"identity": account.Identity, "username": account.Username,
"display_name": account.DisplayName, "avatar": account.Avatar, "phone": account.Phone,
"platform_role_code": account.PlatformRoleCode, "status": account.Status,
"created_at": account.CreatedAt, "updated_at": account.UpdatedAt,
}
}

View File

@@ -0,0 +1,33 @@
// Package platform 测试平台账户管理的对外展示契约。
package platform
import (
"testing"
"time"
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
)
// TestPlatformAccountViewIncludesAuditTimes 验证账户详情返回真实审计时间且保留空联系电话。
func TestPlatformAccountViewIncludesAuditTimes(t *testing.T) {
createdAt := time.Date(2026, 8, 17, 9, 30, 0, 0, time.UTC)
updatedAt := createdAt.Add(time.Hour)
account := models.PlatformAccount{
Entity: models.Entity{
Identity: "019fcdb4-5c7d-720b-8e20-4850f4ce52b0",
CreatedAt: createdAt,
UpdatedAt: updatedAt,
Status: 1,
},
Username: "root", DisplayName: "平台根管理员",
PlatformRoleCode: "root", Phone: "",
}
view := platformAccountView(account)
if view["created_at"] != createdAt || view["updated_at"] != updatedAt {
t.Fatalf("平台账户审计时间未完整返回: %#v", view)
}
if phone, ok := view["phone"].(string); !ok || phone != "" {
t.Fatalf("空联系电话应原样返回给展示层: %#v", view["phone"])
}
}