-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Th0mzzz
committed
Sep 10, 2024
1 parent
fdbc59d
commit 79c0191
Showing
31 changed files
with
284 additions
and
830 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
const { body, validationResult } = require("express-validator"); | ||
const usuariosModel = require("../models/usuariosModel"); | ||
const { removeImg } = require("../util/removeImg"); | ||
const videosModel = require("../models/videosModel"); | ||
|
||
const videoControl = { | ||
validacaoVideo: [ | ||
body("tituloVideo") | ||
.isLength({ min: 3, max: 45 }).withMessage("O título deve ter no minimo 3 caracteres e no máximo 45!") | ||
, | ||
body("descricao") | ||
.isLength({ min: 3, max: 400 }).withMessage("A descrição deve ter entre 3 e 400 caracteres!") | ||
], | ||
postarVideo: async (req, res) => { | ||
let errors = validationResult(req) | ||
let errosMulter = req.session.erroMulter; | ||
|
||
if (!errors.isEmpty() || errosMulter.length > 0) { | ||
|
||
let listaErros = errors.isEmpty() ? { formatter: null, errors: [] } : errors; | ||
|
||
if (errosMulter.length > 0) { | ||
listaErros.errors.push(...errosMulter) | ||
if (req.file) removeImg(`./app/public/img/imagens-servidor/videos/${req.file.filename}`) | ||
} | ||
console.log(listaErros) | ||
|
||
const jsonResult = { | ||
page: "../partial/template-home/pub-pages/videos-pub", | ||
classePagina: "publicar", | ||
erros: listaErros, | ||
valores: req.body, | ||
token: null, | ||
foto: req.session.autenticado ? req.session.autenticado.foto : "perfil-padrao.webp", | ||
|
||
} | ||
res.render("./pages/template-home", jsonResult) | ||
} else { | ||
try { | ||
const capaFile = req.files && req.files.find(file => file.fieldname === 'capaVideo') ? req.files.find(file => file.fieldname === 'capaVideo') : null; | ||
const videoFile = req.files && req.files.find(file => file.fieldname === 'video') ? req.files.find(file => file.fieldname === 'video') : null; | ||
const { titulo, descricao, tags } = req.body | ||
const video = { | ||
NOME_VIDEO: titulo, | ||
DESCR_VIDEO: descricao, | ||
HASHTAG_VIDEO: [tags].toString(), | ||
CAPA_VIDEO: capaFile.filename, | ||
CAMINHO_VIDEO: videoFile.filename, | ||
USUARIOS_ID_USUARIO: req.session.autenticado.id, | ||
} | ||
const resultado = await videosModel.create(video) | ||
console.log(resultado) | ||
res.redirect(`/view-resenha?idResenha=${resultado.insertId}`) | ||
} catch (error) { | ||
console.log(error) | ||
if (req.file) { removeImg(`./app/public/img/imagens-servidor/capaImg/${req.file.filename}`) } | ||
res.render("pages/error-500") | ||
} | ||
|
||
|
||
} | ||
}, | ||
mostrarVideo: async (req, res) => { | ||
let idVideo = req.query.idVideo | ||
// if (!idVideo) { | ||
// const videos = await pool.query("SELECT * FROM VIDEOS LIMIT 10") | ||
// } | ||
|
||
try { | ||
const video = await videosModel.buscarPorId(idVideo) | ||
if (video) { | ||
const autor = await usuariosModel.findUserById(video.USUARIOS_ID_USUARIO) | ||
if (autor) { | ||
|
||
const jsonResult = { | ||
video: { | ||
titulo: video.NOME_VIDEO, | ||
descricao: video.DESCR_VIDEO, | ||
tags: video.HASHTAG_RESENHA.split(","), | ||
video:video.CAMINHO_VIDEO, | ||
autor: autor[0] | ||
}, | ||
} | ||
|
||
res.render("./pages/videos-home", jsonResult) | ||
} else { | ||
res.status(404).render("pages/error-404.ejs"); | ||
} | ||
} else { | ||
res.status(404).render("pages/error-404.ejs"); | ||
} | ||
|
||
} catch (error) { | ||
console.log(error) | ||
res.status(404).render("pages/error-404.ejs"); | ||
} | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
||
module.exports = videoControl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725991058711.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725991090972.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725991093559.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725991094506.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27.7 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725991186632.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725991343752.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725991359867.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725991377231.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725991932030.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725991942916.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725991991192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725992098714.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725992164643.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725992303573.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+74.6 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725992310786.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725992372643.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+118 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725992391340.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
app/public/img/imagens-servidor/capas-img/capaResenha-1725992770429.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.