refactor: removing the workspace type entirely
This commit is contained in:
@@ -6,13 +6,11 @@ import { TMWorkspace } from "../entities/workspace.entity";
|
||||
import { CreateWorkspaceDto } from "../dto/workspace/create-workspace.dto";
|
||||
import { UpdateWorkspaceDto } from "../dto/workspace/update-workspace.dto";
|
||||
import { User } from "../../users/entities/user.entity";
|
||||
import { WorkspaceTypeRepository } from "../repositories/workspace-type.repository";
|
||||
|
||||
@Injectable()
|
||||
export class WorkspaceService {
|
||||
constructor(
|
||||
private readonly workspaceRepository: WorkspaceRepository,
|
||||
private readonly workspaceTypeRepository: WorkspaceTypeRepository,
|
||||
@InjectRepository(User)
|
||||
private readonly userRepository: Repository<User>,
|
||||
) {}
|
||||
@@ -28,10 +26,7 @@ export class WorkspaceService {
|
||||
}
|
||||
|
||||
async create(dto: CreateWorkspaceDto): Promise<TMWorkspace> {
|
||||
const { userIds, workspaceTypeId, ...rest } = dto;
|
||||
|
||||
const workspaceType = await this.workspaceTypeRepository.findOneById(workspaceTypeId);
|
||||
if (!workspaceType) throw new NotFoundException(`WorkSpaceType #${workspaceTypeId} not found!`);
|
||||
const { userIds, ...rest } = dto;
|
||||
|
||||
const workspace = this.workspaceRepository.create(rest);
|
||||
|
||||
@@ -44,12 +39,7 @@ export class WorkspaceService {
|
||||
|
||||
async update(id: string, dto: UpdateWorkspaceDto): Promise<TMWorkspace> {
|
||||
const workspace = await this.findOneOrFail(id);
|
||||
const { userIds, workspaceTypeId, ...rest } = dto;
|
||||
|
||||
if (workspaceTypeId) {
|
||||
const workspaceType = await this.workspaceTypeRepository.findOneById(workspaceTypeId);
|
||||
if (!workspaceType) throw new NotFoundException(`WorkSpaceType #${workspaceTypeId} not found!`);
|
||||
}
|
||||
const { userIds, ...rest } = dto;
|
||||
|
||||
Object.assign(workspace, rest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user