feat(api): public photo feed with stable cursor pagination
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -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),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user