feat(api): public photo feed with stable cursor pagination

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-17 23:39:50 +08:00
parent 6863c736c3
commit 1f1c8ce191
3 changed files with 526 additions and 0 deletions
@@ -16,10 +16,12 @@ import {
} from '@nestjs/common';
import { ErrorCodes } from '@photo/contracts';
import { ApiException } from '../api-exception';
import { parseCursor } from '../albums/albums.controller';
import {
DEFAULT_PUBLIC_PHOTO_PAGE_SIZE,
MAX_PUBLIC_PHOTO_PAGE_SIZE,
type PublicAlbumResponse,
type PublicPhotoListResponse,
PublicService,
} from './public.service';
@@ -58,4 +60,24 @@ export class PublicController {
): Promise<PublicAlbumResponse> {
return this.publicService.getPublicAlbum(token, locale);
}
/**
* 公开照片列表:仅 published;(publishedAt,id) 稳定倒序键集游标;category
* 限本册分类;locale 不校验取值(非法值静默回退语义,Task 5 决策)。
*/
@Get(':token/photos')
listPublicPhotos(
@Param('token') token: string,
@Query('category') category: string | undefined,
@Query('locale') locale: string | undefined,
@Query('cursor') cursor: string | undefined,
@Query('limit') limit: string | undefined,
): Promise<PublicPhotoListResponse> {
return this.publicService.listPublicPhotos(token, {
category,
// locale 仅保证「不因非法值报 400」,列表无语言敏感字段,不向下传。
cursor: parseCursor(cursor),
limit: parsePublicPhotoLimit(limit),
});
}
}