feat(private-room): migrate to album APIs

This commit is contained in:
2026-07-14 12:30:22 +08:00
parent 9612a28b3c
commit 538af6d45f
48 changed files with 1529 additions and 2092 deletions
+5 -5
View File
@@ -84,12 +84,12 @@ export class ApiPath {
static readonly chatUnlockHistory = `${ApiPath._chat}/unlock-history`;
// ============ 私密空间相关 ============
/** 获取私密空间动态列表 */
static readonly privateRoomMoments = `${ApiPath._privateRoom}/moments`;
/** 获取私密图片包列表 */
static readonly privateRoomAlbums = `${ApiPath._privateRoom}/albums`;
/** 解锁私密空间动态 */
static privateRoomMomentUnlock(momentId: string): string {
return `${ApiPath.privateRoomMoments}/${encodeURIComponent(momentId)}/unlock`;
/** 解锁私密图片包 */
static privateRoomAlbumUnlock(albumId: string): string {
return `${ApiPath.privateRoomAlbums}/${encodeURIComponent(albumId)}/unlock`;
}
// ============ 数据看板相关 ============
+15 -17
View File
@@ -1,48 +1,46 @@
import {
PrivateRoomMomentsResponse,
PrivateRoomUnlockResponse,
UnlockPrivateRoomMomentRequest,
PrivateAlbumsResponse,
PrivateAlbumUnlockResponse,
UnlockPrivateAlbumRequest,
} from "@/data/dto/private-room";
import { ApiPath } from "./api_path";
import { httpClient } from "./http_client";
import { type ApiEnvelope, unwrap } from "./response_helper";
export interface GetPrivateRoomMomentsInput {
export interface GetPrivateAlbumsInput {
character?: string;
limit?: number;
cursor?: string | null;
}
export class PrivateRoomApi {
async getMoments(
input: GetPrivateRoomMomentsInput = {},
): Promise<PrivateRoomMomentsResponse> {
async getAlbums(
input: GetPrivateAlbumsInput = {},
): Promise<PrivateAlbumsResponse> {
const env = await httpClient<ApiEnvelope<unknown>>(
ApiPath.privateRoomMoments,
ApiPath.privateRoomAlbums,
{
query: {
character: input.character ?? "elio",
limit: input.limit ?? 20,
...(input.cursor ? { cursor: input.cursor } : {}),
},
},
);
return PrivateRoomMomentsResponse.fromJson(unwrap(env));
return PrivateAlbumsResponse.fromJson(unwrap(env));
}
async unlockMoment(
momentId: string,
body: UnlockPrivateRoomMomentRequest,
): Promise<PrivateRoomUnlockResponse> {
async unlockAlbum(
albumId: string,
body: UnlockPrivateAlbumRequest,
): Promise<PrivateAlbumUnlockResponse> {
const env = await httpClient<ApiEnvelope<unknown>>(
ApiPath.privateRoomMomentUnlock(momentId),
ApiPath.privateRoomAlbumUnlock(albumId),
{
method: "POST",
body: body.toJson(),
},
);
return PrivateRoomUnlockResponse.fromJson(unwrap(env));
return PrivateAlbumUnlockResponse.fromJson(unwrap(env));
}
}