mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
|
|
import { Injectable } from '@angular/core';
|
||
|
|
import { create } from 'domain';
|
||
|
|
import { SessionStore } from 'src/app/store/session.service';
|
||
|
|
import { RoomRemoteDataSourceService } from '../../data/repository/room-remote-repository.service';
|
||
|
|
import { captureAndReraiseAsync } from 'src/app/services/decorators/captureAndReraiseAsync';
|
||
|
|
import { RoomInputDTO } from '../../data/dto/room/roomInputDTO';
|
||
|
|
import { RoomLocalRepository } from '../../data/repository/room-local-repository.service';
|
||
|
|
|
||
|
|
@Injectable({
|
||
|
|
providedIn: 'root'
|
||
|
|
})
|
||
|
|
export class CreateRoomUseCaseService {
|
||
|
|
|
||
|
|
constructor(
|
||
|
|
private roomRemoteDataSourceService: RoomRemoteDataSourceService,
|
||
|
|
private roomLocalDataSourceService: RoomLocalRepository,
|
||
|
|
) { }
|
||
|
|
|
||
|
|
|
||
|
|
@captureAndReraiseAsync('RoomRepositoryService/create')
|
||
|
|
async execute(data: RoomInputDTO) {
|
||
|
|
|
||
|
|
const result = await this.roomRemoteDataSourceService.createRoom(data)
|
||
|
|
if(result.isOk()) {
|
||
|
|
|
||
|
|
if(!result.value.data.createdBy) {
|
||
|
|
|
||
|
|
let dataObject;
|
||
|
|
|
||
|
|
result.value.data.createdBy = {
|
||
|
|
wxeMail: SessionStore.user.Email,
|
||
|
|
wxFullName: SessionStore.user.FullName,
|
||
|
|
wxUserId: SessionStore.user.UserId,
|
||
|
|
}
|
||
|
|
|
||
|
|
dataObject = result.value.data
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
const localResult = await this.roomLocalDataSourceService.createRoom(result.value.data)
|
||
|
|
return localResult.map(e => result.value)
|
||
|
|
}
|
||
|
|
|
||
|
|
return result
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|