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}/listingstrả listingsACTIVEcủa user. - Hỗ trợ filter
typedạ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,createdAtvà 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
- Là khách xem listing, tôi muốn xem profile công khai của người đăng để đánh giá độ tin cậy.
- Là 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.
- Là 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 + listingsAcceptance 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:
PublicUserResponsechỉ gồmid,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}/listingskhô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
typehỗ trợ nhiều listing type, phân tách bằng dấu phẩy. - AC-9: Nếu
typekhông hợp lệ, backend trả bad request với lỗi safe message. - AC-10: Pagination mặc định size
20, sortcreatedAt 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ư
emailvàphonekhô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 filtertype.
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
- Phụ thuộc: Chưa có
- Ảnh hưởng: listing-crawl-external-sources, user-profile-update-web, user-avatar-update-web