Lint errors
Signed-off-by: Rodrigo Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
9742d62ba2
commit
5acec6b71e
196 files changed
+10885
-6655
No files matched your search
@@ -1,8 +1,9 @@
|
||||
import { Router } from 'express';
|
||||
import { prisma } from '../prismaClient';
|
||||
import { authMiddleware } from '../../middleware/auth';
|
||||
import multer from 'multer';
|
||||
import { NextCloudService } from '../../services/nextcloud';
|
||||
import { Router } from "express";
|
||||
import multer from "multer";
|
||||
|
||||
import { authMiddleware } from "../../middleware/auth";
|
||||
import { NextCloudService } from "../../services/nextcloud";
|
||||
import { prisma } from "../prismaClient";
|
||||
|
||||
const router = Router();
|
||||
const upload = multer({ storage: multer.memoryStorage() });
|
||||
@@ -12,12 +13,12 @@ router.use(authMiddleware);
|
||||
// ...existing routes...
|
||||
|
||||
// Rota para atualizar atendimento com anexos
|
||||
router.patch('/:id', async (req, res) => {
|
||||
router.patch("/:id", async (req, res) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
const { anexos, ...data } = req.body;
|
||||
|
||||
console.log('Atualizando atendimento:', id, { anexos, data }); // Debug log
|
||||
console.log("Atualizando atendimento:", id, { anexos, data }); // Debug log
|
||||
|
||||
const atendimento = await prisma.atendimento.update({
|
||||
where: { id },
|
||||
@@ -30,60 +31,62 @@ router.patch('/:id', async (req, res) => {
|
||||
nome: anexo.nome,
|
||||
url: anexo.url,
|
||||
tipo: anexo.tipo,
|
||||
tamanho: anexo.tamanho
|
||||
}))
|
||||
}
|
||||
}
|
||||
})
|
||||
tamanho: anexo.tamanho,
|
||||
})),
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
include: {
|
||||
anexos: true,
|
||||
cliente: true
|
||||
}
|
||||
cliente: true,
|
||||
},
|
||||
});
|
||||
|
||||
console.log('Atendimento atualizado:', atendimento); // Debug log
|
||||
console.log("Atendimento atualizado:", atendimento); // Debug log
|
||||
res.json(atendimento);
|
||||
} catch (error) {
|
||||
console.error('Erro ao atualizar atendimento:', error);
|
||||
res.status(500).json({ error: 'Erro ao atualizar atendimento' });
|
||||
console.error("Erro ao atualizar atendimento:", error);
|
||||
res.status(500).json({ error: "Erro ao atualizar atendimento" });
|
||||
}
|
||||
});
|
||||
|
||||
// Nova rota para upload de arquivo via proxy
|
||||
router.post('/upload', upload.single('file'), async (req, res) => {
|
||||
router.post("/upload", upload.single("file"), async (req, res) => {
|
||||
try {
|
||||
if (!req.file || !req.body.clienteNome) {
|
||||
return res.status(400).json({ error: 'Arquivo e nome do cliente são obrigatórios' });
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Arquivo e nome do cliente são obrigatórios" });
|
||||
}
|
||||
|
||||
// Enviar para o NextCloud usando a estrutura de pastas correta
|
||||
const buffer = req.file.buffer;
|
||||
Object.defineProperty(buffer, 'name', {
|
||||
Object.defineProperty(buffer, "name", {
|
||||
value: req.file.originalname,
|
||||
writable: true,
|
||||
enumerable: true
|
||||
enumerable: true,
|
||||
});
|
||||
|
||||
const filePath = await NextCloudService.uploadFile(
|
||||
buffer,
|
||||
req.body.clienteNome,
|
||||
'atendimento',
|
||||
req.body.protocolo
|
||||
"atendimento",
|
||||
req.body.protocolo,
|
||||
);
|
||||
|
||||
res.json({ url: filePath });
|
||||
} catch (error) {
|
||||
console.error('Erro no upload:', error);
|
||||
res.status(500).json({ error: 'Erro no upload do arquivo' });
|
||||
console.error("Erro no upload:", error);
|
||||
res.status(500).json({ error: "Erro no upload do arquivo" });
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/:id', async (req, res) => {
|
||||
router.get("/:id", async (req, res) => {
|
||||
try {
|
||||
const atendimento = await prisma.atendimento.findUnique({
|
||||
where: {
|
||||
id: req.params.id
|
||||
where: {
|
||||
id: req.params.id,
|
||||
},
|
||||
include: {
|
||||
cliente: true,
|
||||
@@ -93,20 +96,20 @@ router.get('/:id', async (req, res) => {
|
||||
id: true,
|
||||
nome: true,
|
||||
oab: true,
|
||||
oabUF: true
|
||||
}
|
||||
}
|
||||
}
|
||||
oabUF: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!atendimento) {
|
||||
return res.status(404).json({ error: 'Atendimento não encontrado' });
|
||||
return res.status(404).json({ error: "Atendimento não encontrado" });
|
||||
}
|
||||
|
||||
res.json(atendimento);
|
||||
} catch (error) {
|
||||
console.error('Erro ao buscar atendimento:', error);
|
||||
res.status(500).json({ error: 'Erro ao buscar atendimento' });
|
||||
console.error("Erro ao buscar atendimento:", error);
|
||||
res.status(500).json({ error: "Erro ao buscar atendimento" });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user