Skip to content

Commit

Permalink
tag voltando: quando abro com others, movo para software development …
Browse files Browse the repository at this point in the history
…e salvo, ele volta a others (mas acho que só no front) [cm269uz130012w30l5txxoyh2]
  • Loading branch information
pauloendoh committed Oct 23, 2024
1 parent 2fa274d commit 85d35ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
11 changes: 4 additions & 7 deletions src/domains/relearn/resource/ResourceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Param,
Post,
Put,
QueryParam,
} from "routing-controllers"
import { In } from "typeorm"
import { IdsDto } from "../../../dtos/IdsDto"
Expand All @@ -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,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
Expand Down Expand Up @@ -88,9 +84,6 @@ export class _SaveResource {
}

const saved = await this.resourceRepo.save({ ...sentResource })
if (returnAll) {
return this.resourceRepo.findAllResourcesFromUser(user)
}

return saved
}
Expand Down

0 comments on commit 85d35ef

Please sign in to comment.