From 85d35efe031611d16d4c411b16f3753e8eaf9835 Mon Sep 17 00:00:00 2001 From: Paulo Endoh Date: Wed, 23 Oct 2024 15:34:36 -0300 Subject: [PATCH] =?UTF-8?q?tag=20voltando:=20quando=20abro=20com=20others,?= =?UTF-8?q?=20movo=20para=20software=20development=20e=20salvo,=20ele=20vo?= =?UTF-8?q?lta=20a=20others=20(mas=20acho=20que=C2=A0s=C3=B3=C2=A0no=C2=A0?= =?UTF-8?q?front)=20[cm269uz130012w30l5txxoyh2]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/domains/relearn/resource/ResourceController.ts | 11 ++++------- .../use-cases/_SaveResource/_SaveResource.ts | 13 +++---------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/domains/relearn/resource/ResourceController.ts b/src/domains/relearn/resource/ResourceController.ts index 5160768..d9dec64 100644 --- a/src/domains/relearn/resource/ResourceController.ts +++ b/src/domains/relearn/resource/ResourceController.ts @@ -8,7 +8,6 @@ import { Param, Post, Put, - QueryParam, } from "routing-controllers" import { In } from "typeorm" import { IdsDto } from "../../../dtos/IdsDto" @@ -21,22 +20,20 @@ import { _SaveResource } from "./use-cases/_SaveResource/_SaveResource" @JsonController() export class ResourceController { constructor( - private resourceRepo = ResourceRepository, - private service = new ResourceService(), - private _saveResource = new _SaveResource() + private readonly resourceRepo = ResourceRepository, + private readonly service = new ResourceService(), + private readonly _saveResource = new _SaveResource() ) {} @Post("/relearn/resource") async saveResource( @CurrentUser({ required: true }) user: User, - @Body() sentResource: Resource, - @QueryParam("returnAll") returnAll?: boolean + @Body() sentResource: Resource ) { return this._saveResource.exec({ sentResource, user, - returnAll, }) } diff --git a/src/domains/relearn/resource/use-cases/_SaveResource/_SaveResource.ts b/src/domains/relearn/resource/use-cases/_SaveResource/_SaveResource.ts index 97ebff4..cf85185 100644 --- a/src/domains/relearn/resource/use-cases/_SaveResource/_SaveResource.ts +++ b/src/domains/relearn/resource/use-cases/_SaveResource/_SaveResource.ts @@ -4,14 +4,10 @@ import { Resource } from "../../../../../entities/relearn/Resource" import ResourceRepository from "../../../../../repositories/relearn/ResourceRepository" export class _SaveResource { - constructor(private resourceRepo = ResourceRepository) {} + constructor(private readonly resourceRepo = ResourceRepository) {} - async exec(params: { - sentResource: Resource - user: User - returnAll?: boolean - }) { - const { sentResource, user, returnAll = true } = params + async exec(params: { sentResource: Resource; user: User }) { + const { sentResource, user } = params if (sentResource.tag === null) { throw new BadRequestError("Resource must have a tag.") } @@ -88,9 +84,6 @@ export class _SaveResource { } const saved = await this.resourceRepo.save({ ...sentResource }) - if (returnAll) { - return this.resourceRepo.findAllResourcesFromUser(user) - } return saved }