Bỏ qua nội dung

Xem public profile và tin công khai của user

Feature URL
Module
user
Status
in-development
Priority
P2
Platforms
fe · be
AC progress
10 / 12
Last reviewed
2026-05-29

Mục tiêu

Cho phép web hiển thị profile công khai của một user và danh sách tin đang active của user đó mà không lộ thông tin riêng tư. Flow này phục vụ listing detail, owner/agent card và trang public profile.

Phạm vi

Trong phạm vi (In scope):

  • API public GET /api/v1/users/{id} trả thông tin cơ bản của user.
  • API public GET /api/v1/users/{id}/listings trả listings ACTIVE của user.
  • Hỗ trợ filter type dạng comma-separated cho listing type.
  • Hỗ trợ pagination/sort mặc định theo createdAt DESC.
  • FE page/card public profile dùng name, avatarUrl, createdAt và danh sách tin active.

Ngoài phạm vi (Out of scope):

  • Hiển thị email, phone hoặc field private của user.
  • Contact owner/broker qua chat/call form.
  • Quản lý tin của chính user, xem module listing/customer listings.
  • Admin xem full user detail.

User Stories

  • khách xem listing, tôi muốn xem profile công khai của người đăng để đánh giá độ tin cậy.
  • khách đang xem profile owner/agent, tôi muốn xem các tin active khác của họ để khám phá thêm lựa chọn.
  • hệ thống, tôi muốn public profile không lộ email/phone riêng tư.

Luồng chức năng

sequenceDiagram
    actor Visitor
    participant Web
    participant BE
    participant Listing as ListingService

    Visitor->>Web: Mở public profile/user card
    Web->>BE: GET /api/v1/users/{id}
    BE->>BE: Tìm user theo id
    BE-->>Web: PublicUserResponse
    Web->>BE: GET /api/v1/users/{id}/listings?type=SALE&page=0&size=20
    BE->>BE: Validate type filter
    BE->>Listing: Query ACTIVE listings của user
    Listing-->>BE: PageResponse<UserListingResponse>
    BE-->>Web: Danh sách tin công khai
    Web->>Visitor: Render public profile + listings

Acceptance Criteria

  • AC-1: Backend có GET /api/v1/users/{id} không yêu cầu auth.
  • AC-2: Nếu user không tồn tại, API trả not found.
  • AC-3: PublicUserResponse chỉ gồm id, name, avatarUrl, createdAt.
  • AC-4: Public profile không trả email, phone, roles, status hoặc auth provider.
  • AC-5: Backend có GET /api/v1/users/{id}/listings không yêu cầu auth.
  • AC-6: API listings kiểm tra user tồn tại trước khi query listings.
  • AC-7: API listings chỉ trả listings public/active thông qua ListingService.
  • AC-8: Query param type hỗ trợ nhiều listing type, phân tách bằng dấu phẩy.
  • AC-9: Nếu type không hợp lệ, backend trả bad request với lỗi safe message.
  • AC-10: Pagination mặc định size 20, sort createdAt DESC.
  • AC-11: FE cần page/card public profile sử dụng API này.
  • AC-12: FE cần xử lý empty state khi user chưa có listing active.

Quy tắc nghiệp vụ

  • Public profile là subset an toàn, không dùng UserProfileResponse.
  • User private fields như emailphone không được trả về public endpoint.
  • User listings endpoint chỉ trả listings active/public; các trạng thái draft/revoked/inactive không hiển thị.
  • Filter listing type không được phản chiếu raw input nguy hiểm trong safe error message.
  • Listing module sở hữu query listing; user module chỉ điều phối theo owner id.

Dữ liệu & Trạng thái

Entity nghiệp vụ:

  • User: nguồn public projection.
  • PublicUserResponse: public profile an toàn.
  • UserListingResponse: card listing công khai của user.
  • PageResponse<UserListingResponse>: pagination contract cho danh sách tin.
  • ListingTypeEnum: enum validate filter type.

Trạng thái user-facing:

  • public-profile-loading — đang tải profile public.
  • public-profile-ready — có thông tin user.
  • public-profile-not-found — user không tồn tại.
  • listings-loading — đang tải danh sách tin.
  • listings-empty — user không có listing active.
  • invalid-type-filter — filter loại tin không hợp lệ.

Liên quan