mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
set member to admin
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RoomListItemOutPutDTO, RoomListOutPutDTO } from '../../dto/room/roomListOutputDTO';
|
||||
import { Dexie, EntityTable, liveQuery, Observable } from 'Dexie';
|
||||
import { z } from 'zod';
|
||||
import { DexieRepository } from 'src/app/infra/repository/dexie/dexie-repository.service';
|
||||
|
||||
|
||||
const TableMemberListSchema = z.object({
|
||||
$roomIdUserId: z.string().optional(),
|
||||
id: z.string(),
|
||||
roomId: z.string(),
|
||||
user: z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string().nullable(),
|
||||
}),
|
||||
joinAt: z.string(),
|
||||
status: z.string()
|
||||
})
|
||||
|
||||
export type ITableMemberList = z.infer<typeof TableMemberListSchema>
|
||||
|
||||
type ITableMemberListSchema = EntityTable<ITableMemberList, '$roomIdUserId'>
|
||||
// Database declaration (move this to its own module also)
|
||||
export const roomMemberList = new Dexie('roomMemberList') as Dexie & {
|
||||
memberList: EntityTable<ITableMemberList, '$roomIdUserId'>;
|
||||
};
|
||||
|
||||
roomMemberList.version(1).stores({
|
||||
memberList: '$roomIdUserId, id, user, joinAt, roomId, status',
|
||||
});
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MemberListLocalDataSourceService extends DexieRepository<ITableMemberListSchema, ITableMemberList> {
|
||||
|
||||
constructor() {
|
||||
super(roomMemberList.memberList);
|
||||
|
||||
// messageDataSource.message.hook('creating', (primKey, obj, trans) => {
|
||||
// // const newMessage = await trans.table('message').get(primKey);
|
||||
// this.messageSubject.next(obj);
|
||||
// // return newMessage
|
||||
// })
|
||||
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Result } from 'neverthrow';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { HttpService } from 'src/app/services/http.service';
|
||||
import { DataSourceReturn } from 'src/app/services/Repositorys/type';
|
||||
import { AddMemberToRoomInputDTOSchema, AddMemberToRoomInputDTO } from '../../dto/room/addMemberToRoomInputDto';
|
||||
import { UserRemoveListInputDTOSchema, UserRemoveListInputDTO } from '../../dto/room/userRemoveListInputDTO';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MemberListRemoteDataSourceService {
|
||||
|
||||
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2/Chat'; // Your base URL
|
||||
|
||||
constructor(private httpService: HttpService) { }
|
||||
|
||||
|
||||
@ValidateSchema(AddMemberToRoomInputDTOSchema)
|
||||
async addMemberToRoom(data: AddMemberToRoomInputDTO): DataSourceReturn<AddMemberToRoomInputDTO> {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Room/${data.id}/Member`, { members:data.members });
|
||||
}
|
||||
|
||||
|
||||
@ValidateSchema(UserRemoveListInputDTOSchema)
|
||||
async removeMemberFromRoom(data: UserRemoveListInputDTO): Promise<Result<any ,any>> {
|
||||
return await this.httpService.delete<any>(`${this.baseUrl}/Room/${data.id}/Member`, {members:data.members});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user