mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
change room name
This commit is contained in:
+4
-3
@@ -11,7 +11,8 @@ 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';
|
||||
import { RoomUpdateInputDTO, RoomUpdateInputDTOSchema } from '../../dto/room/roomUpdateInputDTO';
|
||||
import { RoomUpdateOutputDTO } from '../../dto/room/roomUpdateOutputDTO';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -41,9 +42,9 @@ export class RoomRemoteDataSourceService {
|
||||
return await this.httpService.get(`${this.baseUrl}/Room/${id}`);
|
||||
}
|
||||
|
||||
@ValidateSchema(AddMemberToRoomInputDTOSchema)
|
||||
@ValidateSchema(RoomUpdateInputDTOSchema)
|
||||
//@APIReturn(RoomByIdOutputDTOSchema,'update/Room/${id}')
|
||||
async updateRoom(data: RoomUpdateInputDTO): Promise<DataSourceReturn<RoomUpdateInputDTO>> {
|
||||
async updateRoom(data: RoomUpdateInputDTO): Promise<DataSourceReturn<RoomUpdateOutputDTO>> {
|
||||
const id = data.roomId
|
||||
delete data.roomId
|
||||
return await this.httpService.put<any>(`${this.baseUrl}/Room/${id}`, data);
|
||||
|
||||
@@ -1,8 +1,30 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const UserSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string().nullable(),
|
||||
});
|
||||
|
||||
const MemberSchema = z.object({
|
||||
id: z.string(),
|
||||
user: UserSchema,
|
||||
joinAt: z.string(),
|
||||
});
|
||||
|
||||
export const RoomUpdateOutputDTOSchema = z.object({
|
||||
roomName: z.string(),
|
||||
roomType: z.number(),
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: UserSchema,
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(),
|
||||
roomType: z.number(),
|
||||
members: z.array(MemberSchema),
|
||||
}),
|
||||
});
|
||||
|
||||
export type RoomUpdateOutputDTO = z.infer<typeof RoomUpdateOutputDTOSchema>
|
||||
|
||||
@@ -28,17 +28,11 @@ export class RoomRepositoryService {
|
||||
async list() {
|
||||
const result = await this.roomRemoteDataSourceService.getRoomList()
|
||||
|
||||
if(result.isOk()) {
|
||||
console.log(result.value)
|
||||
}
|
||||
|
||||
const localList = await this.roomLocalDataSourceService.getRoomList()
|
||||
|
||||
if(result.isOk()) {
|
||||
const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges(result.value.data, localList)
|
||||
|
||||
console.log({roomsToDelete, roomsToInsert, roomsToUpdate})
|
||||
|
||||
for( const roomData of roomsToInsert) {
|
||||
this.roomLocalDataSourceService.createRoom(roomData)
|
||||
}
|
||||
@@ -54,10 +48,22 @@ export class RoomRepositoryService {
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@captureAndReraiseAsync('RoomRepositoryService/updateRoomBy')
|
||||
async updateRoomBy(data: RoomUpdateInputDTO) {
|
||||
this.roomRemoteDataSourceService.updateRoom(data)
|
||||
|
||||
const result = await this.roomRemoteDataSourceService.updateRoom(data)
|
||||
|
||||
if(result.isOk()) {
|
||||
const localList = await this.roomLocalDataSourceService.getRoomList()
|
||||
const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges([result.value.data], localList)
|
||||
|
||||
for( const roomData of roomsToUpdate) {
|
||||
this.roomLocalDataSourceService.updateRoom(roomData)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@captureAndReraiseAsync('RoomRepositoryService/getRoomById')
|
||||
|
||||
Reference in New Issue
Block a user