Skip to content

Commit 3f89147

Browse files
committed
adicionando o campo imagem em jogos
1 parent 5e4b037 commit 3f89147

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/controllers/jogo.controller.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Jogo } from "./../models/jogo.model";
22
import { Request, Response } from "express";
33

4-
export default class TarefaController {
4+
export default class JogoController {
55
async GetJogos(req: Request, res: Response) {
66
try {
77
const jogos = await Jogo.find();
@@ -23,9 +23,7 @@ export default class TarefaController {
2323

2424
async GetJogosbyUsuarios(req: Request, res: Response): Promise<any> {
2525
try {
26-
const jogos = await Jogo.find({ usuario: req.params.id }).populate(
27-
"usuario",
28-
);
26+
const jogos = await Jogo.find({ usuario: req.params.id }).populate("usuario");
2927
if (!jogos) {
3028
return res.status(404).json({ message: "Nenhum jogo encontrado." });
3129
}
@@ -41,6 +39,7 @@ export default class TarefaController {
4139
nome,
4240
descricao,
4341
status,
42+
imagem,
4443
dataLancamento,
4544
genero,
4645
plataforma,
@@ -52,6 +51,7 @@ export default class TarefaController {
5251
nome,
5352
descricao,
5453
status,
54+
imagem,
5555
dataLancamento,
5656
genero,
5757
plataforma,
@@ -73,6 +73,7 @@ export default class TarefaController {
7373
nome,
7474
descricao,
7575
status,
76+
imagem,
7677
dataLancamento,
7778
genero,
7879
plataforma,
@@ -86,6 +87,7 @@ export default class TarefaController {
8687
nome,
8788
descricao,
8889
status,
90+
imagem,
8991
dataLancamento,
9092
genero,
9193
plataforma,

src/models/jogo.model.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ interface IJogo extends Document {
44
nome: string;
55
descricao: string;
66
status: string;
7+
imagem: string;
78
dataLancamento: Date;
89
genero: string;
9-
plataforma: string;
10+
plataforma: string[];
1011
desenvolvedor: string;
1112
publicador: string;
1213
usuario: Schema.Types.ObjectId;
@@ -16,9 +17,10 @@ const JogoSchema: Schema<IJogo> = new Schema({
1617
nome: { type: String, required: true },
1718
descricao: { type: String, required: true },
1819
status: { type: String, required: true },
20+
imagem: { type: String },
1921
dataLancamento: { type: Date, required: true },
2022
genero: { type: String, required: true },
21-
plataforma: { type: String, required: true },
23+
plataforma: [{ type: String, required: true }],
2224
desenvolvedor: { type: String, required: true },
2325
publicador: { type: String, required: true },
2426
usuario: { type: Schema.Types.ObjectId, ref: "Usuario", required: true },

src/routes/jogo.routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class JogoRoutes {
103103
* type: string
104104
* status:
105105
* type: string
106+
* imagem:
107+
* type: string
106108
* dataLancamento:
107109
* type: string
108110
* format: date

0 commit comments

Comments
 (0)