add metods to update room name

This commit is contained in:
Peter Maquiran
2024-06-11 13:48:44 +01:00
parent 4c1ad6d648
commit 540cbbc911
7 changed files with 44 additions and 14 deletions
@@ -11,6 +11,7 @@ import { RoomByIdInputDTO, RoomByIdInputDTOSchema } from '../../dto/room/roomByI
import { RoomByIdOutputDTO, RoomByIdOutputDTOSchema } from '../../dto/room/roomByIdOutputDTO';
import { APIReturn } from 'src/app/services/decorators/api-validate-schema.decorator';
import { UserRemoveListInputDTO, UserRemoveListInputDTOSchema } from '../../dto/room/userRemoveListInputDTO';
import { RoomUpdateInputDTO } from '../../dto/room/roomUpdateInputDTO';
@Injectable({
providedIn: 'root'
@@ -40,8 +41,12 @@ export class RoomRemoteDataSourceService {
return await this.httpService.get(`${this.baseUrl}/Room/${id}`);
}
async updateRoom(id: string, room: any): Promise<Result<any ,any>> {
return await this.httpService.put<any>(`${this.baseUrl}/Room/${id}`, room);
@ValidateSchema(AddMemberToRoomInputDTOSchema)
//@APIReturn(RoomByIdOutputDTOSchema,'update/Room/${id}')
async updateRoom(data: RoomUpdateInputDTO): Promise<DataSourceReturn<RoomUpdateInputDTO>> {
const id = data.roomId
delete data.roomId
return await this.httpService.put<any>(`${this.baseUrl}/Room/${id}`, data);
}
async deleteRoom(id: string): Promise<Result<any ,any>> {
@@ -0,0 +1,9 @@
import { z } from "zod";
export const RoomUpdateInputDTOSchema = z.object({
roomName: z.string(),
roomId: z.string(),
roomType: z.number(),
});
export type RoomUpdateInputDTO = z.infer<typeof RoomUpdateInputDTOSchema>
@@ -0,0 +1,8 @@
import { z } from "zod";
export const RoomUpdateOutputDTOSchema = z.object({
roomName: z.string(),
roomType: z.number(),
});
export type RoomUpdateOutputDTO = z.infer<typeof RoomUpdateOutputDTOSchema>
@@ -10,6 +10,7 @@ import { roomListDetermineChanges } from '../async/rooms/roomListChangeDetector'
import { UserRemoveListInputDTO } from '../dto/room/userRemoveListInputDTO';
import { roomMemberListDetermineChanges } from '../async/rooms/roomMembersChangeDetector';
import { captureAndReraiseAsync } from 'src/app/services/decorators/captureAndReraiseAsync';
import { RoomUpdateInputDTO } from '../dto/room/roomUpdateInputDTO';
@Injectable({
providedIn: 'root'
@@ -53,6 +54,11 @@ export class RoomRepositoryService {
}
@captureAndReraiseAsync('RoomRepositoryService/updateRoomBy')
async updateRoomBy(data: RoomUpdateInputDTO) {
this.roomRemoteDataSourceService.updateRoom(data)
}
@captureAndReraiseAsync('RoomRepositoryService/getRoomById')
async getRoomById(id: RoomByIdInputDTO) {
const result = await this.roomRemoteDataSourceService.getRoom(id)