mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
add interface
This commit is contained in:
@@ -16,14 +16,14 @@ import { ListenMessageDeleteByRoomIdService } from './use-case/message/listene-m
|
||||
import { ListenMessageUpdateByRoomIdUseCase } from './use-case/message/listen-message-update-by-roomId.service';
|
||||
import { GetRoomByIdUseCaseService } from './use-case/room/room-get-by-id-use-case.service';
|
||||
import { DeleteRoomUseCaseService } from './use-case/room/room-delete-by-id-use-case.service';
|
||||
import { CreateRoomUseCaseService } from './use-case/room/room-create-use-case.service';
|
||||
import { RoomLeaveUseCase } from './use-case/room/room-leave-by-id-use-case.service';
|
||||
import { CreateRoomInputDTO, CreateRoomUseCaseService } from './use-case/room/room-create-use-case.service';
|
||||
import { RoomLeaveUseCase, UserRemoveListInputDTO } from './use-case/room/room-leave-by-id-use-case.service';
|
||||
import { SyncAllRoomMessagesService } from './use-case/message/sync-all-room-messages.service';
|
||||
import { ListenSendMessageUseCase } from './use-case/message/listen-send-message.service'
|
||||
import { SendLocalMessagesUseCaseService } from './use-case/message/messages-send-offline-use-case.service'
|
||||
import { RemoveMemberUseCaseService } from './use-case/member/-use-case.service'
|
||||
import { AddMemberUseCaseService } from './use-case/member/member-add-use-case.service'
|
||||
import { UpdateRoomByIdUseCaseService } from './use-case/room/room-update-by-id-use-case.service'
|
||||
import { RoomUpdateInputDTO, UpdateRoomByIdUseCaseService } from './use-case/room/room-update-by-id-use-case.service'
|
||||
import { SocketConnectUseCaseService } from './use-case/socket-connect-use-case.service'
|
||||
import { MessageMarkAsReadUseCaseService } from './use-case/message/message-mark-as-read-use-case.service'
|
||||
import { MessageMarkAllMessageAsReadByRoomIdInputSchema, MessageMarkAllMessageAsReadByRoomIdService } from './use-case/message/message-mark-all-message-as-read-by-room-id.service'
|
||||
@@ -33,10 +33,7 @@ import { filter } from 'rxjs/operators';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { MessageEntity } from '../../../core/chat/entity/message';
|
||||
import { MessageAttachmentByMessageIdInput, MessageAttachmentByMessageIdUseCase } from './use-case/message/message-attachment-by-message-id.service';
|
||||
import { RoomInputDTO } from '../data/dto/room/roomInputDTO';
|
||||
import { UserRemoveListInputDTO } from '../data/dto/room/userRemoveListInputDTO';
|
||||
import { AddMemberToRoomInputDTO, AddMemberToRoomInputDTOSchema } from '../domain/use-case/member/member-add-use-case.service';
|
||||
import { RoomUpdateInputDTO } from '../data/dto/room/roomUpdateInputDTO';
|
||||
import { RoomType } from "src/app/core/chat/entity/group";
|
||||
import { HttpListenToMessageLoadHistoryAdapter } from './adapter'
|
||||
import { HttpListenToMessageLoadHistoryUseCaseInput } from 'src/app/core/chat/usecase/message/http-listen-to-message-load-history-use-case';
|
||||
@@ -203,7 +200,7 @@ export class ChatServiceService {
|
||||
return this.DeleteRoomUseCaseService.execute(id)
|
||||
}
|
||||
|
||||
createRoom(data: RoomInputDTO) {
|
||||
createRoom(data: CreateRoomInputDTO) {
|
||||
return this.CreateRoomUseCaseService.execute(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
import { MemberTable } from "src/app/infra/database/dexie/instance/chat/schema/members";
|
||||
import { RoomByIdMemberItemOutputDTO } from "../../data/dto/room/roomByIdOutputDTO";
|
||||
import { RoomByIdMemberItemOutputDTO } from "../use-case/room/room-get-by-id-use-case.service";
|
||||
|
||||
export function MemberListMapper(outputDto: RoomByIdMemberItemOutputDTO, roomId: string): MemberTable {
|
||||
return {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { MessageInputDTO } from "../../data/dto/message/messageInputDtO";
|
||||
import { MessageOutPutDataDTO } from "../../data/dto/message/messageOutputDTO";
|
||||
import { MessageInputDTO } from "src/app/core/chat/repository/dto/messageInputDtO";
|
||||
import { MessageEntity } from "../../../../core/chat/entity/message";
|
||||
import { MessageOutPutDataDTO } from "src/app/core/chat/repository/dto/messageOutputDTO";
|
||||
|
||||
export class MessageMapper {
|
||||
static toDomain(DTO: MessageOutPutDataDTO) : MessageEntity {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { captureAndReraiseAsync } from 'src/app/services/decorators/captureAndReraiseAsync';
|
||||
import { UserRemoveListInputDTO } from '../../../data/dto/room/userRemoveListInputDTO';
|
||||
import { RoomRemoteDataSourceService } from '../../../data/repository/room/room-remote-repository.service';
|
||||
import { MemberListRemoteRepository } from '../../../data/repository/member/member-list-remote-repository.service';
|
||||
import { UserRemoveListInputDTO } from '../room/room-leave-by-id-use-case.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -9,13 +10,13 @@ import { RoomRemoteDataSourceService } from '../../../data/repository/room/room-
|
||||
export class RemoveMemberUseCaseService {
|
||||
|
||||
constructor(
|
||||
private roomRemoteDataSourceService: RoomRemoteDataSourceService,
|
||||
private memberRemoteDataSourceService: MemberListRemoteRepository,
|
||||
) { }
|
||||
|
||||
|
||||
@captureAndReraiseAsync('RoomRepositoryService/removeMemberToRoom')
|
||||
async execute(data: UserRemoveListInputDTO) {
|
||||
const result = await this.roomRemoteDataSourceService.removeMemberFromRoom(data)
|
||||
const result = await this.memberRemoteDataSourceService.removeMemberFromRoom(data)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { captureAndReraiseAsync } from 'src/app/services/decorators/captureAndReraiseAsync';
|
||||
import { RoomRemoteDataSourceService } from '../../../data/repository/room/room-remote-repository.service';
|
||||
import { z } from 'zod';
|
||||
import { MemberListRemoteRepository } from '../../../data/repository/member/member-list-remote-repository.service';
|
||||
|
||||
|
||||
export const AddMemberToRoomInputDTOSchema = z.object({
|
||||
@@ -18,7 +19,7 @@ export type AddMemberToRoomInputDTO = z.infer<typeof AddMemberToRoomInputDTOSche
|
||||
export class AddMemberUseCaseService {
|
||||
|
||||
constructor(
|
||||
private roomRemoteDataSourceService: RoomRemoteDataSourceService,
|
||||
private memberRemoteDataSourceService: MemberListRemoteRepository,
|
||||
) { }
|
||||
|
||||
|
||||
@@ -28,7 +29,7 @@ export class AddMemberUseCaseService {
|
||||
|
||||
// return this.roomLiveSignalRDataSourceService.addMemberToRoom(data)
|
||||
|
||||
const result = await this.roomRemoteDataSourceService.addMemberToRoom(data)
|
||||
const result = await this.memberRemoteDataSourceService.addMemberToRoom(data)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { z } from "zod";
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { RoomRemoteDataSourceService } from '../../../data/repository/room/room-remote-repository.service';
|
||||
import { MemberListRemoteRepository } from '../../../data/repository/member/member-list-remote-repository.service';
|
||||
|
||||
// Define the schema for the entire response
|
||||
const MemberSetAdminDTOSchema = z.object({
|
||||
@@ -18,7 +19,7 @@ export type MemberSetAdminDTO = z.infer<typeof MemberSetAdminDTOSchema>
|
||||
export class MemberAdminUseCaseService {
|
||||
|
||||
constructor(
|
||||
public repository: RoomRemoteDataSourceService
|
||||
public repository: MemberListRemoteRepository
|
||||
) { }
|
||||
|
||||
@ValidateSchema(MemberSetAdminDTOSchema)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MessageEntity, MessageEntitySchema, } from '../../../../../core/chat/entity/message';
|
||||
import { MessageAttachmentSource, MessageEntity, MessageEntitySchema, } from '../../../../../core/chat/entity/message';
|
||||
import { AttachmentLocalDataSource } from "src/app/module/chat/data/repository/attachment/attachment-local-repository.service";
|
||||
import { z } from 'zod';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
@@ -7,7 +7,6 @@ import { InstanceId } from '../../chat-service.service';
|
||||
import { createDataURL } from 'src/app/utils/ToBase64';
|
||||
import { zodSafeValidation } from 'src/app/utils/zodValidation';
|
||||
import { Logger } from 'src/app/services/logger/main/service';
|
||||
import { MessageAttachmentSource, MessageOutPutDataDTO } from '../../../data/dto/message/messageOutputDTO';
|
||||
import { MessageLocalDataSourceService } from '../../../data/repository/message/message-local-data-source.service';
|
||||
import { MessageSocketRepositoryService } from '../../../data/repository/message/message-live-signalr-data-source.service';
|
||||
import { err, Result } from 'neverthrow';
|
||||
@@ -17,7 +16,7 @@ import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelem
|
||||
import { MemberListLocalRepository } from 'src/app/module/chat/data/repository/member/member-list-local-repository.service'
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { MessageTable } from 'src/app/infra/database/dexie/instance/chat/schema/message';
|
||||
import { MessageAttachmentFileType } from 'src/app/core/chat/repository/dto/messageOutputDTO';
|
||||
import { MessageAttachmentFileType, MessageOutPutDataDTO } from 'src/app/core/chat/repository/dto/messageOutputDTO';
|
||||
|
||||
|
||||
export enum MessageEnum {
|
||||
|
||||
+1
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { z } from 'zod';
|
||||
import { MessageSocketRepositoryService } from '../../../data/repository/message/message-live-signalr-data-source.service';
|
||||
import { XTracerAsync, TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
|
||||
export const MessageDeleteInputDTOSchema = z.object({
|
||||
requestId: z.string().optional(),
|
||||
roomId: z.string(),
|
||||
|
||||
+1
-1
@@ -10,8 +10,8 @@ import { MemberListLocalRepository } from 'src/app/module/chat/data/repository/m
|
||||
import { Result } from 'neverthrow';
|
||||
import { RoomType } from 'src/app/core/chat/entity/group';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { MessageOutPutDataDTO } from '../../../data/dto/message/messageOutputDTO';
|
||||
import { MessageTable } from 'src/app/infra/database/dexie/instance/chat/schema/message';
|
||||
import { MessageOutPutDataDTO } from 'src/app/core/chat/repository/dto/messageOutputDTO';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
||||
@@ -13,10 +13,23 @@ export const CreateRoomInputDTOSchema = z.object({
|
||||
expirationDate: z.string().nullable().optional(),
|
||||
members: z.array(z.number())
|
||||
});
|
||||
|
||||
|
||||
export type CreateRoomInputDTO = z.infer<typeof CreateRoomInputDTOSchema>
|
||||
|
||||
|
||||
export const RoomOutPutDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: z.any().nullable(),
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(),
|
||||
roomType: z.any()
|
||||
})
|
||||
});
|
||||
export type RoomOutPutDTO = z.infer<typeof RoomOutPutDTOSchema>
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { captureAndReraiseAsync } from 'src/app/services/decorators/captureAndReraiseAsync';
|
||||
import { isHttpResponse } from 'src/app/services/http.service';
|
||||
import { RoomByIdInputDTO } from '../../../data/dto/room/roomByIdInputDTO';
|
||||
import { RoomRemoteDataSourceService } from '../../../data/repository/room/room-remote-repository.service';
|
||||
import { RoomLocalRepository } from '../../../data/repository/room/room-local-repository.service';
|
||||
import { z } from "zod";
|
||||
|
||||
export const DeleteRoomByIdInputDTOSchema = z.string()
|
||||
export type DeleteRoomByIdInputDTO = z.infer<typeof DeleteRoomByIdInputDTOSchema>
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -18,7 +22,7 @@ export class DeleteRoomUseCaseService {
|
||||
|
||||
|
||||
@captureAndReraiseAsync('RoomRepositoryService/deleteRoomById')
|
||||
async execute(id: RoomByIdInputDTO) {
|
||||
async execute(id: DeleteRoomByIdInputDTO) {
|
||||
const result = await this.roomRemoteDataSourceService.deleteRoom(id)
|
||||
|
||||
if(result.isOk()) {
|
||||
|
||||
@@ -8,6 +8,45 @@ import { RoomLocalRepository } from '../../../data/repository/room/room-local-re
|
||||
import { MemberListLocalRepository } from '../../../data/repository/member/member-list-local-repository.service';
|
||||
import { MemberListMapper } from '../../mapper/memberLIstMapper';
|
||||
import { captureAndReraiseAsync } from 'src/app/services/decorators/captureAndReraiseAsync';
|
||||
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(),
|
||||
isAdmin: z.boolean()
|
||||
});
|
||||
|
||||
export const RoomByIdOutputDTOSchema = z.object({
|
||||
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 RoomByIdMemberItemOutputDTO = z.infer<typeof MemberSchema>
|
||||
export type RoomByIdOutputDTO = z.infer<typeof RoomByIdOutputDTOSchema>
|
||||
|
||||
|
||||
|
||||
export const RoomByIdInputDTOSchema = z.string()
|
||||
|
||||
|
||||
export type RoomByIdInputDTO = z.infer<typeof RoomByIdInputDTOSchema>
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
||||
@@ -4,6 +4,42 @@ import { RoomRemoteDataSourceService } from '../../../data/repository/room/room-
|
||||
import { RoomLocalRepository } from '../../../data/repository/room/room-local-repository.service';
|
||||
import { captureAndReraiseAsync } from 'src/app/services/decorators/captureAndReraiseAsync';
|
||||
import { CronJobService } from 'src/app/utils/task-scheduler'
|
||||
import { z } from "zod";
|
||||
|
||||
|
||||
const CreatedBySchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string().email(),
|
||||
userPhoto: z.string().nullable()// api check
|
||||
});
|
||||
|
||||
const RoomListItemOutPutDTOSchema = z.object({
|
||||
|
||||
chatRoom: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: CreatedBySchema,
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(), // api check
|
||||
roomType: z.number()
|
||||
}),
|
||||
joinAt: z.string()
|
||||
})
|
||||
|
||||
|
||||
// Define the schema for the entire response
|
||||
export const RoomListOutPutDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.array(RoomListItemOutPutDTOSchema),
|
||||
});
|
||||
|
||||
export type RoomListItemOutPutDTO = z.infer<typeof RoomListItemOutPutDTOSchema>
|
||||
|
||||
export type RoomListOutPutDTO = z.infer<typeof RoomListOutPutDTOSchema>
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { UserRemoveListInputDTO } from '../../../data/dto/room/userRemoveListInputDTO';
|
||||
import { isHttpResponse } from 'src/app/services/http.service';
|
||||
import { RoomRemoteDataSourceService } from '../../../data/repository/room/room-remote-repository.service';
|
||||
import { RoomLocalRepository } from '../../../data/repository/room/room-local-repository.service';
|
||||
import { MemberListRemoteRepository } from '../../../data/repository/member/member-list-remote-repository.service';
|
||||
import { z } from "zod";
|
||||
|
||||
// Define the schema for the entire response
|
||||
export const UserRemoveListInputDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
members: z.array(z.number())
|
||||
});
|
||||
|
||||
export type UserRemoveListInputDTO = z.infer<typeof UserRemoveListInputDTOSchema>
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -10,14 +19,14 @@ import { RoomLocalRepository } from '../../../data/repository/room/room-local-re
|
||||
export class RoomLeaveUseCase {
|
||||
|
||||
constructor(
|
||||
private roomRemoteDataSourceService: RoomRemoteDataSourceService,
|
||||
private memberRemoteDataSourceService: MemberListRemoteRepository,
|
||||
private roomLocalDataSourceService: RoomLocalRepository,
|
||||
) { }
|
||||
|
||||
|
||||
|
||||
async execute(data: UserRemoveListInputDTO) {
|
||||
const result = await this.roomRemoteDataSourceService.removeMemberFromRoom(data)
|
||||
const result = await this.memberRemoteDataSourceService.removeMemberFromRoom(data)
|
||||
|
||||
if(result.isOk()) {
|
||||
this.roomLocalDataSourceService.delete(data.id)
|
||||
|
||||
@@ -1,8 +1,45 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { captureAndReraiseAsync } from 'src/app/services/decorators/captureAndReraiseAsync';
|
||||
import { RoomUpdateInputDTO } from '../../../data/dto/room/roomUpdateInputDTO';
|
||||
import { RoomRemoteDataSourceService } from '../../../data/repository/room/room-remote-repository.service';
|
||||
import { RoomLocalRepository } from '../../../data/repository/room/room-local-repository.service';
|
||||
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>
|
||||
|
||||
|
||||
|
||||
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({
|
||||
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>
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
||||
+1
-1
@@ -1,11 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MessageLocalDataSourceService } from '../../../data/repository/message/message-local-data-source.service';
|
||||
import { MessageOutPutDataDTO, MessageOutPutDataDTOSchema } from '../../../data/dto/message/messageOutputDTO';
|
||||
import { ParamsValidation, SafeValidateSchema, ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { MessageEntitySchema } from 'src/app/core/chat/entity/message';
|
||||
import { z } from 'zod';
|
||||
import { MessageTable } from 'src/app/infra/database/dexie/instance/chat/schema/message';
|
||||
import { MessageOutPutDataDTOSchema } from 'src/app/core/chat/repository/dto/messageOutputDTO';
|
||||
|
||||
|
||||
const SocketMessageUpdateOutputSchema = MessageEntitySchema.pick({
|
||||
|
||||
Reference in New Issue
Block a user