feat(private-room): connect moments feed
Docker Image / Build and Push Docker Image (push) Successful in 9m29s
Docker Image / Build and Push Docker Image (push) Successful in 9m29s
This commit is contained in:
@@ -6,9 +6,11 @@ export * from "./auth_repository";
|
||||
export * from "./chat_repository";
|
||||
export * from "./metrics_repository";
|
||||
export * from "./payment_repository";
|
||||
export * from "./private_room_repository";
|
||||
export * from "./user_repository";
|
||||
export * from "./interfaces/iauth_repository";
|
||||
export * from "./interfaces/ichat_repository";
|
||||
export * from "./interfaces/imetrics_repository";
|
||||
export * from "./interfaces/ipayment_repository";
|
||||
export * from "./interfaces/iprivate_room_repository";
|
||||
export * from "./interfaces/iuser_repository";
|
||||
|
||||
@@ -6,4 +6,5 @@ export * from "./iauth_repository";
|
||||
export * from "./ichat_repository";
|
||||
export * from "./imetrics_repository";
|
||||
export * from "./ipayment_repository";
|
||||
export * from "./iprivate_room_repository";
|
||||
export * from "./iuser_repository";
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import type {
|
||||
PrivateRoomMomentsResponse,
|
||||
PrivateRoomUnlockResponse,
|
||||
} from "@/data/dto/private-room";
|
||||
import type { Result } from "@/utils/result";
|
||||
|
||||
export interface GetPrivateRoomMomentsInput {
|
||||
character?: string;
|
||||
limit?: number;
|
||||
cursor?: string | null;
|
||||
}
|
||||
|
||||
export interface IPrivateRoomRepository {
|
||||
getMoments(
|
||||
input?: GetPrivateRoomMomentsInput,
|
||||
): Promise<Result<PrivateRoomMomentsResponse>>;
|
||||
|
||||
unlockMoment(
|
||||
momentId: string,
|
||||
expectedCost: number,
|
||||
): Promise<Result<PrivateRoomUnlockResponse>>;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
UnlockPrivateRoomMomentRequest,
|
||||
type PrivateRoomMomentsResponse,
|
||||
type PrivateRoomUnlockResponse,
|
||||
} from "@/data/dto/private-room";
|
||||
import {
|
||||
PrivateRoomApi,
|
||||
privateRoomApi,
|
||||
} from "@/data/services/api/private_room_api";
|
||||
import type {
|
||||
GetPrivateRoomMomentsInput,
|
||||
IPrivateRoomRepository,
|
||||
} from "@/data/repositories/interfaces";
|
||||
import { Result } from "@/utils/result";
|
||||
|
||||
import { createLazySingleton } from "./lazy_singleton";
|
||||
|
||||
export class PrivateRoomRepository implements IPrivateRoomRepository {
|
||||
constructor(private readonly api: PrivateRoomApi) {}
|
||||
|
||||
getMoments(
|
||||
input: GetPrivateRoomMomentsInput = {},
|
||||
): Promise<Result<PrivateRoomMomentsResponse>> {
|
||||
return Result.wrap(() => this.api.getMoments(input));
|
||||
}
|
||||
|
||||
unlockMoment(
|
||||
momentId: string,
|
||||
expectedCost: number,
|
||||
): Promise<Result<PrivateRoomUnlockResponse>> {
|
||||
return Result.wrap(() =>
|
||||
this.api.unlockMoment(
|
||||
momentId,
|
||||
UnlockPrivateRoomMomentRequest.from({ expectedCost }),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const getPrivateRoomRepository =
|
||||
createLazySingleton<IPrivateRoomRepository>(
|
||||
() => new PrivateRoomRepository(privateRoomApi),
|
||||
);
|
||||
Reference in New Issue
Block a user