Files
doneit-web/src/app/module/chat/domain/mapper/messageMapper.ts
T

34 lines
1.1 KiB
TypeScript
Raw Normal View History

import { MessageInputDTO } from "../../data/dto/message/messageInputDtO";
import { MessageOutPutDataDTO } from "../../data/dto/message/messageOutputDTO";
import { MessageEntity } from "../entity/message";
2024-08-09 10:50:32 +01:00
import { attachments } from '../../../../../../../../../Downloads/equilibriumito-gabinete-digital-fo-23cf0fc4cbaa/equilibriumito-gabinete-digital-fo-23cf0fc4cbaa/src/app/models/beast-orm';
export class MessageMapper {
static toDomain(DTO: MessageOutPutDataDTO) : MessageEntity {
return DTO as MessageEntity
}
static fromDomain(entity:MessageEntity, requestId): MessageInputDTO {
2024-08-15 16:34:07 +01:00
return {
canEdit: entity.canEdit,
message: entity.message,
messageType: entity.messageType,
oneShot: entity.oneShot,
requireUnlock: entity.requireUnlock,
roomId: entity.roomId,
senderId: entity.sender.wxUserId,
2024-08-09 10:50:32 +01:00
requestId: requestId,
2024-08-15 16:34:07 +01:00
attachment: entity.attachments.map((e)=>({
fileType:e.fileType,
source: e.source,
file: e.file,
fileName: e.fileName,
2024-08-16 14:21:01 +01:00
applicationId: e.applicationId || 0,
docId: Number(e.docId) || 0,
2024-08-15 16:34:07 +01:00
mimeType: e.mimeType
}))[0]
}
}
}