-
Venha mostrar para o mundo o profissional que você é.
+
+
+
Venha mostrar para o mundo o profissional que você é.
+
Nossa missão é intermediar o processo de comunicação entre aluno, escola e empresa, de forma
que
facilite a introdução do aluno ao mercado de trabalho.Nossa missão é intermediar o processo
@@ -35,6 +38,7 @@ import Footer from '../../components/Footer.vue';
import Slides from '../../components/Slides.vue';
import Cards from '../../components/Cards.vue';
import ChatComponent from '../../components/ChatComponent.vue';
+import imgHome from '../../assets/imgs/imageMain.png';
export default {
name: 'Home',
@@ -45,10 +49,15 @@ export default {
ContactUs,
Footer,
ChatComponent
+ },
+ setup() {
+ return {
+ imgHome
+ }
}
}
\ No newline at end of file
diff --git a/client/src/views/shared/NotFound.vue b/client/src/views/shared/NotFound.vue
index bfa260e..365af99 100644
--- a/client/src/views/shared/NotFound.vue
+++ b/client/src/views/shared/NotFound.vue
@@ -42,5 +42,5 @@ export default {
\ No newline at end of file
diff --git a/client/src/views/shared/PerfilAluno.vue b/client/src/views/shared/PerfilAluno.vue
index 4fdb397..e03ead1 100644
--- a/client/src/views/shared/PerfilAluno.vue
+++ b/client/src/views/shared/PerfilAluno.vue
@@ -26,5 +26,5 @@ export default {
\ No newline at end of file
diff --git a/client/src/views/shared/PerfilProfessor.vue b/client/src/views/shared/PerfilProfessor.vue
index 5a2d288..e449799 100644
--- a/client/src/views/shared/PerfilProfessor.vue
+++ b/client/src/views/shared/PerfilProfessor.vue
@@ -26,5 +26,5 @@ export default {
\ No newline at end of file
diff --git a/server/Dockerfile b/server/Dockerfile
index 9dcce8b..7796cfe 100644
--- a/server/Dockerfile
+++ b/server/Dockerfile
@@ -3,13 +3,10 @@ FROM node:latest
WORKDIR /server
COPY package*.json ./
-
RUN npm install
COPY . .
-
RUN npx prisma generate
EXPOSE 3333
-
CMD ["npm","dev"]
\ No newline at end of file
diff --git a/server/src/index.ts b/server/src/index.ts
index c306164..7f2e67d 100644
--- a/server/src/index.ts
+++ b/server/src/index.ts
@@ -32,10 +32,10 @@ app.use((err: Error, request: Request, response: Response, next: NextFunction) =
const httpServer = http.createServer(app);
const io = new Server(httpServer, {
- cors: {
- origin: "http://localhost:5173",
- methods: ["GET", "POST"]
- }
+ cors: {
+ origin: "http://localhost:5173",
+ methods: ["GET", "POST"]
+ }
});
appSocket(io);
diff --git a/server/src/jwt/jwtServices.ts b/server/src/jwt/jwtServices.ts
index f2f7f6f..c098baf 100644
--- a/server/src/jwt/jwtServices.ts
+++ b/server/src/jwt/jwtServices.ts
@@ -2,7 +2,7 @@ import { sign, verify, JwtPayload } from "jsonwebtoken";
import { Aluno, Admin, Professor, Funcionario, Empresa } from "@prisma/client";
export function generateAccessTokenAluno(aluno: Aluno): string {
- return sign({ alunoId: aluno.id}, process.env.JWT_ACCESS_SECRET as string, {
+ return sign({ alunoId: aluno.id }, process.env.JWT_ACCESS_SECRET as string, {
expiresIn: '50m',
});
}
diff --git a/server/src/modules/controllers/adminControllers.ts b/server/src/modules/controllers/adminControllers.ts
index 7f3f66e..6032ec2 100644
--- a/server/src/modules/controllers/adminControllers.ts
+++ b/server/src/modules/controllers/adminControllers.ts
@@ -1,7 +1,6 @@
import { Request, Response } from "express";
import { GetAllProfessorUseCase } from "../services/admin/GetAllProfessorUseCase";
import { GetCoordenadorUseCase } from "../services/admin/GetCoordenadoresUseCase";
-import { GetCursosUseCase } from "../services/admin/GetCursosUseCase";
import { LoginAdminUseCase } from "../services/admin/LoginAdminUseCase";
import { RegisterCoordenadorUseCase } from '../services/admin/RegisterCoordenadorUseCase';
import { RegisterCursosUseCase } from '../services/admin/RegisterCursosUseCase';
@@ -31,17 +30,6 @@ export class GetCoordenadorController {
}
}
-export class GetCursosController {
- async handle(req: Request, res: Response) {
-
- const getCursoUseCase = new GetCursosUseCase();
-
- const result = await getCursoUseCase.execute();
-
- return res.status(201).json(result);
- }
-}
-
export class LoginAdminController {
async handle(req: Request, res: Response) {
const { email, password } = req.body;
diff --git a/server/src/modules/controllers/alunoControllers.ts b/server/src/modules/controllers/alunoControllers.ts
index d585df6..a6992bc 100644
--- a/server/src/modules/controllers/alunoControllers.ts
+++ b/server/src/modules/controllers/alunoControllers.ts
@@ -6,6 +6,7 @@ import { RecoveryAluno } from "../services/aluno/RecoveryAlunoUseCase";
import { ValidateRecoveryUseCase } from "../services/aluno/ValidateRecoveryUseCase";
import { CompleteAlunoUseCase } from "../services/aluno/CompleteRegisterUseCase";
import { UpdateCurriculoUseCase } from "../services/aluno/UpdateCurriculoUseCase";
+import { GetTurmasByCursoUseCase } from "../services/aluno/GetCourseYearUseCase";
export class CreateAlunoController {
async handle(req: Request, res: Response) {
@@ -69,11 +70,12 @@ export class ValidateRecoveryController {
export class CompleteAlunoController {
async handle(req: Request, res: Response) {
- const { email, nascimento, endereco, turma, rm } = req.body;
-
+ const { nascimento, endereco, curso, inicio, rm } = req.body;
+ const email = req.body.entidade.email;
+
const completeAluno = new CompleteAlunoUseCase();
- const result = await completeAluno.execute({ email, nascimento, endereco, turma, rm });
+ const result = await completeAluno.execute({ email, nascimento, endereco, curso, inicio, rm });
return res.status(201).json(result);
}
@@ -87,6 +89,18 @@ export class UpdateCurriculoController {
const result = await updateCurriculo.execute({ email, curriculo });
+ return res.status(201).json(result);
+ }
+}
+
+export class GetCourseYearController {
+ async handle(req: Request, res: Response) {
+ const { curso, turno } = req.body;
+
+ const getTurmasByCursoUseCase = new GetTurmasByCursoUseCase();
+
+ const result = await getTurmasByCursoUseCase.execute({ curso, turno });
+
return res.status(201).json(result);
}
}
\ No newline at end of file
diff --git a/server/src/modules/controllers/empresaControllers.ts b/server/src/modules/controllers/empresaControllers.ts
index b5b3ca0..34c8d3e 100644
--- a/server/src/modules/controllers/empresaControllers.ts
+++ b/server/src/modules/controllers/empresaControllers.ts
@@ -1,5 +1,5 @@
import { Request, Response } from "express";
-import { RegisterEmpresaUseCase } from '../services/empresa/RegisterEmpresaUsecase';
+import { RegisterEmpresaUseCase } from '../services/empresa/RegisterEmpresaUseCase';
import { LoginEmpresaUseCase } from '../services/empresa/LoginEmpresaUseCase'
import { ValidateEmpresaUseCase } from '../services/empresa/ValidateEmpresaUseCase'
import { RecoveryEmpresaUseCase } from '../services/empresa/RecoveryEmpresaUseCase'
diff --git a/server/src/modules/controllers/sharedControllers.ts b/server/src/modules/controllers/sharedControllers.ts
index ddb577d..d390e87 100644
--- a/server/src/modules/controllers/sharedControllers.ts
+++ b/server/src/modules/controllers/sharedControllers.ts
@@ -1,16 +1,33 @@
import { Request, Response } from "express";
import { CreateVinculoUseCase } from "../services/shared/CreateVinculoUseCase";
+import { DeleteVinculoUseCase } from "../services/shared/DeleteVinculoUseCase";
import { AcceptVinculoUseCase } from "../services/shared/AcceptVinculoUseCase";
import { GetVinculosUseCase } from "../services/shared/GetVinculosUseCase";
import { IgnoreVinculoUseCase } from "../services/shared/IgnoreVinculoUseCase";
+import { GetUnlinkedsUseCase } from "../services/shared/GetUnlinkedsUseCase";
+import { GetCursosUseCase } from "../services/shared/GetCursosUseCase";
export class CreateVinculoController {
async handle(req: Request, res: Response) {
const { sender, recipient, senderIdentifier, recipientIdentifier } = req.body;
+ const email = req.body.entidade.email;
const createVinculoUseCase = new CreateVinculoUseCase();
- const result = await createVinculoUseCase.execute({ sender, recipient, senderIdentifier, recipientIdentifier });
+ const result = await createVinculoUseCase.execute({ email, sender, recipient, senderIdentifier, recipientIdentifier });
+
+ return res.status(201).json(result);
+ }
+}
+
+export class DeleteVinculoController {
+ async handle(req: Request, res: Response) {
+ const { sender, recipient, senderIdentifier, recipientIdentifier } = req.body;
+ const email = req.body.entidade.email;
+
+ const deleteVinculoUseCase = new DeleteVinculoUseCase();
+
+ const result = await deleteVinculoUseCase.execute({ email, sender, recipient, senderIdentifier, recipientIdentifier });
return res.status(201).json(result);
}
@@ -54,8 +71,34 @@ export class GetVinculosController {
const identifier = req.body.identifier;
const getVinculosUseCase = new GetVinculosUseCase();
+
const result = await getVinculosUseCase.execute({ email, identifier });
+ return res.status(201).json(result);
+ }
+}
+
+export class GetUnlinkedsController {
+ async handle(req: Request, res: Response) {
+ const email = req.body.entidade.email;
+ const identifier = req.body.identifier;
+
+ const getUnlinkedsUseCase = new GetUnlinkedsUseCase();
+
+ const result = await getUnlinkedsUseCase.execute({ email, identifier });
+
+ return res.status(201).json(result);
+ }
+}
+
+
+export class GetCursosController {
+ async handle(req: Request, res: Response) {
+
+ const getCursoUseCase = new GetCursosUseCase();
+
+ const result = await getCursoUseCase.execute();
+
return res.status(201).json(result);
}
}
\ No newline at end of file
diff --git a/server/src/modules/interfaces/alunoDTOs.ts b/server/src/modules/interfaces/alunoDTOs.ts
index ecc18ed..7b28a37 100644
--- a/server/src/modules/interfaces/alunoDTOs.ts
+++ b/server/src/modules/interfaces/alunoDTOs.ts
@@ -27,13 +27,26 @@ export interface validateRecoveryDTO {
export interface CompleteAlunoDTO {
email: string,
- nascimento: Date,
- turma: string,
- rm: string
+ nascimento: string,
+ curso: string,
+ inicio: string,
+ rm: string,
endereco: string
}
export interface UpdateCurriculoDTO {
email: string,
curriculo: string
+}
+
+export interface GetTurmasByCursoDTO {
+ curso: string,
+ turno: Turno
+}
+
+enum Turno {
+ MANHA = "MANHA",
+ TARDE = "TARDE",
+ NOITE = "NOITE",
+ INTEGRAL = "INTEGRAL"
}
\ No newline at end of file
diff --git a/server/src/modules/interfaces/sharedDTOs.ts b/server/src/modules/interfaces/sharedDTOs.ts
index cca8dbb..0327edb 100644
--- a/server/src/modules/interfaces/sharedDTOs.ts
+++ b/server/src/modules/interfaces/sharedDTOs.ts
@@ -1,4 +1,5 @@
export interface VinculoDTO {
+ email: string,
sender: string,
recipient: string,
senderIdentifier: IdentificadorEnum,
@@ -10,7 +11,7 @@ export enum IdentificadorEnum {
PROFESSOR = "PROFESSOR"
}
-export interface ReagirVinculoDTO{
+export interface ReagirVinculoDTO {
email: string,
sender: string,
recipient: string,
diff --git a/server/src/modules/services/admin/LoginAdminUseCase.ts b/server/src/modules/services/admin/LoginAdminUseCase.ts
index 83487bc..037c21e 100644
--- a/server/src/modules/services/admin/LoginAdminUseCase.ts
+++ b/server/src/modules/services/admin/LoginAdminUseCase.ts
@@ -9,7 +9,7 @@ const bcrypt = require('bcrypt');
export class LoginAdminUseCase {
async execute({ email, password }: LoginAdminDTO): Promise<{ token: string, admin: Pick }> {
- if( !email || !password ){
+ if (!email || !password) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
diff --git a/server/src/modules/services/admin/RegisterCoordenadorUseCase.ts b/server/src/modules/services/admin/RegisterCoordenadorUseCase.ts
index bf456c3..5a3961c 100644
--- a/server/src/modules/services/admin/RegisterCoordenadorUseCase.ts
+++ b/server/src/modules/services/admin/RegisterCoordenadorUseCase.ts
@@ -6,7 +6,7 @@ import { AppError } from "../../../errors/error";
export class RegisterCoordenadorUseCase {
async execute({ name }: RegisterCoordenadorDTO): Promise> {
- if( !name ){
+ if (!name) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
@@ -36,7 +36,7 @@ export class RegisterCoordenadorUseCase {
if (!coordenadorRegister) {
throw new AppError("Erro ao cadastrar professor!");
} else {
- return {
+ return {
name: coordenadorRegister.name
};
}
diff --git a/server/src/modules/services/admin/RegisterCursosUseCase.ts b/server/src/modules/services/admin/RegisterCursosUseCase.ts
index 55528c5..7531978 100644
--- a/server/src/modules/services/admin/RegisterCursosUseCase.ts
+++ b/server/src/modules/services/admin/RegisterCursosUseCase.ts
@@ -6,7 +6,7 @@ import { AppError } from "../../../errors/error";
export class RegisterCursosUseCase {
async execute({ cursoName, turno, duracao, coordenador }: RegisterCursosDTO): Promise> {
- if( !cursoName || !turno || !duracao || !coordenador ){
+ if (!cursoName || !turno || !duracao || !coordenador) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
diff --git a/server/src/modules/services/admin/RegisterFuncionarioUseCase.ts b/server/src/modules/services/admin/RegisterFuncionarioUseCase.ts
index 44836b5..e4f3784 100644
--- a/server/src/modules/services/admin/RegisterFuncionarioUseCase.ts
+++ b/server/src/modules/services/admin/RegisterFuncionarioUseCase.ts
@@ -10,11 +10,11 @@ const bcrypt = require('bcrypt');
export class RegisterFuncionarioUseCase {
async execute({ name, email, cargo }: RegisterFuncionarioDTO): Promise> {
- if( !name || !email || !cargo ){
+ if (!name || !email || !cargo) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
- if( cargo != "GESTAO" && cargo != "ADMINISTRACAO" && cargo != "DIRECAO" && cargo != "ORIENTACAO" ){
+ if (cargo != "GESTAO" && cargo != "ADMINISTRACAO" && cargo != "DIRECAO" && cargo != "ORIENTACAO") {
throw new AppError("Cargo inválido.");
}
@@ -35,7 +35,7 @@ export class RegisterFuncionarioUseCase {
var cargoString = '';
if (cargo == "GESTAO") cargoString = "gestão";
- else if (cargo == "ADMINISTRACAO") cargoString = "administração"
+ else if (cargo == "ADMINISTRACAO") cargoString = "administração"
else if (cargo == "DIRECAO") cargoString = "direção"
else if (cargo == "ORIENTACAO") cargoString = "orientação"
diff --git a/server/src/modules/services/admin/RegisterProfessorUseCase.ts b/server/src/modules/services/admin/RegisterProfessorUseCase.ts
index fe5d1e9..71a98da 100644
--- a/server/src/modules/services/admin/RegisterProfessorUseCase.ts
+++ b/server/src/modules/services/admin/RegisterProfessorUseCase.ts
@@ -8,9 +8,9 @@ import transporter from "../../../mail/config/email";
const bcrypt = require('bcrypt');
export class RegisterProfessorUseCase {
- async execute({ name, email, tituloPrincipal }: RegisterProfessorDTO): Promise> {
+ async execute({ name, email, tituloPrincipal }: RegisterProfessorDTO): Promise> {
- if( !name || !email || !tituloPrincipal ){
+ if (!name || !email || !tituloPrincipal) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
diff --git a/server/src/modules/services/admin/RegisterTurmasUseCase.ts b/server/src/modules/services/admin/RegisterTurmasUseCase.ts
index 3b93671..2db3251 100644
--- a/server/src/modules/services/admin/RegisterTurmasUseCase.ts
+++ b/server/src/modules/services/admin/RegisterTurmasUseCase.ts
@@ -6,7 +6,7 @@ import { AppError } from "../../../errors/error";
export class RegisterTurmasUseCase {
async execute({ inicio, fim, cursoName }: RegisterTurmaDTO): Promise<{ cursoName: string, turma: Pick }> {
- if( !inicio || !fim || !cursoName ){
+ if (!inicio || !fim || !cursoName) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
diff --git a/server/src/modules/services/aluno/CompleteRegisterUseCase.ts b/server/src/modules/services/aluno/CompleteRegisterUseCase.ts
index beea7b8..285054f 100644
--- a/server/src/modules/services/aluno/CompleteRegisterUseCase.ts
+++ b/server/src/modules/services/aluno/CompleteRegisterUseCase.ts
@@ -3,11 +3,16 @@ import { CompleteAlunoDTO } from "../../interfaces/alunoDTOs"
import { AppError } from "../../../errors/error";
export class CompleteAlunoUseCase {
- async execute({ email, nascimento, endereco, turma, rm }: CompleteAlunoDTO) {
+ async execute({ email, nascimento, endereco, curso, inicio, rm }: CompleteAlunoDTO) {
- if (!email || !nascimento || !endereco || !turma || !rm) {
+ if (!email || !nascimento || !endereco || !curso || !inicio || !rm) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
+
+ const [dia, mes, ano] = nascimento.split('/');
+
+ const stringNascimento = new Date(`${ano}-${mes}-${dia}T00:00:00Z`);
+ const nascimentoISO = stringNascimento.toISOString();
const aluno = await prisma.aluno.findUnique({
where: {
@@ -16,26 +21,50 @@ export class CompleteAlunoUseCase {
});
if (aluno) {
- const rmAlreadyExists = await prisma.aluno.findFirst({
+ const rmNull = await prisma.aluno.findFirst({
where: {
- rm
+ rm: null,
+ email: email
}
});
- if (!rmAlreadyExists) {
- prisma.aluno.update({
+ console.log(rmNull);
+
+ if (rmNull) {
+ const cursoExists = await prisma.curso.findFirst({
+ where: {
+ name: curso,
+ }
+ });
+
+ if (!cursoExists) {
+ throw new AppError("Curso não encontrado.");
+ }
+
+ const turma = await prisma.turma.findFirst({
+ where: {
+ cursoId: cursoExists.id,
+ inicio
+ }
+ });
+
+ if (!turma) {
+ throw new AppError("Turma não encontrada para combinação de curso e ano: \n" + curso + " - " + inicio)
+ }
+
+ await prisma.aluno.update({
where: {
email
},
data: {
- dataNascimento: nascimento,
+ dataNascimento: nascimentoISO,
endereco,
- turmas: turma,
- rm
+ turmas: turma.id,
+ rm: rm
}
});
-
- return;
+
+ return "Dados cadastrais atualizados com sucesso!";
} else {
throw new AppError("RM já cadastrado");
}
diff --git a/server/src/modules/services/aluno/CreateAlunoUseCase.ts b/server/src/modules/services/aluno/CreateAlunoUseCase.ts
index 32c0e84..0d46f67 100644
--- a/server/src/modules/services/aluno/CreateAlunoUseCase.ts
+++ b/server/src/modules/services/aluno/CreateAlunoUseCase.ts
@@ -6,9 +6,9 @@ import { AppError } from "../../../errors/error";
const bcrypt = require('bcrypt');
export class CreateAlunoUseCase {
- async execute({ email, token }: CreateAlunoDTO): Promise>{
+ async execute({ email, token }: CreateAlunoDTO): Promise> {
- if( !email || !token ){
+ if (!email || !token) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
diff --git a/server/src/modules/services/aluno/GetCourseYearUseCase.ts b/server/src/modules/services/aluno/GetCourseYearUseCase.ts
new file mode 100644
index 0000000..8152cb0
--- /dev/null
+++ b/server/src/modules/services/aluno/GetCourseYearUseCase.ts
@@ -0,0 +1,36 @@
+import { prisma } from "../../../prisma/client";
+import { AppError } from "../../../errors/error";
+import { GetTurmasByCursoDTO } from "../../interfaces/alunoDTOs"
+
+export class GetTurmasByCursoUseCase {
+ async execute({curso, turno}: GetTurmasByCursoDTO){
+ if (!curso || !turno) {
+ throw new AppError("Parâmentros insufientes ou inválidos.");
+ }
+
+ const cursoExists = await prisma.curso.findFirst({
+ where: {
+ name: curso,
+ turno: turno
+ },
+ });
+
+ if (!cursoExists) {
+ throw new AppError("Curso não encontrado.");
+ }
+
+ const turmas = await prisma.turma.findMany({
+ where: {
+ cursoId: cursoExists.id
+ },
+ });
+
+ if (!turmas) {
+ throw new AppError("Turmas não encontradas para esse curso.");
+ }
+
+ return turmas.map(turma => ({
+ inicio: turma.inicio
+ }));
+ }
+}
\ No newline at end of file
diff --git a/server/src/modules/services/aluno/LoginAlunoUseCase.ts b/server/src/modules/services/aluno/LoginAlunoUseCase.ts
index 1f60395..e9f03d8 100644
--- a/server/src/modules/services/aluno/LoginAlunoUseCase.ts
+++ b/server/src/modules/services/aluno/LoginAlunoUseCase.ts
@@ -9,10 +9,10 @@ const bcrypt = require('bcrypt');
export class LoginAlunoUseCase {
async execute({ email, password }: LoginAlunoDTO): Promise<{ token: string, aluno: Pick }> {
- if( !email || !password ){
+ if (!email || !password) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
-
+
const aluno = await prisma.aluno.findFirst({
where: {
email
diff --git a/server/src/modules/services/aluno/UpdateCurriculoUseCase.ts b/server/src/modules/services/aluno/UpdateCurriculoUseCase.ts
index 52440f5..51e855c 100644
--- a/server/src/modules/services/aluno/UpdateCurriculoUseCase.ts
+++ b/server/src/modules/services/aluno/UpdateCurriculoUseCase.ts
@@ -24,7 +24,7 @@ export class UpdateCurriculoUseCase {
curriculo: curriculo
}
});
-
+
return;
} else {
throw new AppError("Email não encontrado");
diff --git a/server/src/modules/services/aluno/validateRecoveryUseCase.ts b/server/src/modules/services/aluno/validateRecoveryUseCase.ts
index 23497ee..0f16f91 100644
--- a/server/src/modules/services/aluno/validateRecoveryUseCase.ts
+++ b/server/src/modules/services/aluno/validateRecoveryUseCase.ts
@@ -8,11 +8,11 @@ const bcrypt = require('bcrypt');
export class ValidateRecoveryUseCase {
async execute({ email, recoveryPassword, newPass }: validateRecoveryDTO): Promise<{ token: string, aluno: Pick }> {
-
- if( !email || !recoveryPassword || !newPass ){
+
+ if (!email || !recoveryPassword || !newPass) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
-
+
const aluno = await prisma.aluno.findFirst({
where: {
email
diff --git a/server/src/modules/services/empresa/LoginEmpresaUseCase.ts b/server/src/modules/services/empresa/LoginEmpresaUseCase.ts
index a7262ae..234e4ea 100644
--- a/server/src/modules/services/empresa/LoginEmpresaUseCase.ts
+++ b/server/src/modules/services/empresa/LoginEmpresaUseCase.ts
@@ -9,7 +9,7 @@ const bcrypt = require('bcrypt');
export class LoginEmpresaUseCase {
async execute({ cnpj, password }: LoginEmpresaDTO): Promise<{ token: string, empresa: Pick }> {
- if( !cnpj || !password ){
+ if (!cnpj || !password) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
diff --git a/server/src/modules/services/empresa/ValidateEmpresaUseCase.ts b/server/src/modules/services/empresa/ValidateEmpresaUseCase.ts
index 8388f1e..094a0c7 100644
--- a/server/src/modules/services/empresa/ValidateEmpresaUseCase.ts
+++ b/server/src/modules/services/empresa/ValidateEmpresaUseCase.ts
@@ -7,8 +7,8 @@ const bcrypt = require('bcrypt');
export class ValidateEmpresaUseCase {
async execute({ cnpj, token }: ValidateEmpresaDTO): Promise> {
-
- if( !cnpj || !token ){
+
+ if (!cnpj || !token) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
@@ -41,7 +41,7 @@ export class ValidateEmpresaUseCase {
}
});
- return{
+ return {
name: empresa.name,
email: empresa.email,
validated: empresa.validated
diff --git a/server/src/modules/services/empresa/ValidateRecoveryEmpresa.ts b/server/src/modules/services/empresa/ValidateRecoveryEmpresa.ts
index f59bdba..76f6873 100644
--- a/server/src/modules/services/empresa/ValidateRecoveryEmpresa.ts
+++ b/server/src/modules/services/empresa/ValidateRecoveryEmpresa.ts
@@ -8,11 +8,11 @@ const bcrypt = require('bcrypt');
export class ValidateRecoveryEmpresaUseCase {
async execute({ cnpj, tempPass, newPass }: ValidateRecoveryEmpresaDTO): Promise<{ token: string, empresa: Pick }> {
-
- if( !cnpj || !tempPass || !newPass ){
+
+ if (!cnpj || !tempPass || !newPass) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
-
+
const empresa = await prisma.empresa.findFirst({
where: {
cnpj
diff --git a/server/src/modules/services/funcionario/InitFuncionarioUseCase.ts b/server/src/modules/services/funcionario/InitFuncionarioUseCase.ts
index 44c2695..6a8dc67 100644
--- a/server/src/modules/services/funcionario/InitFuncionarioUseCase.ts
+++ b/server/src/modules/services/funcionario/InitFuncionarioUseCase.ts
@@ -6,7 +6,7 @@ import { AppError } from "../../../errors/error";
export class InitFuncionarioUseCase {
async execute({ email, cargo }: InitFuncionarioDTO): Promise<{ funcionario: Pick }> {
- if( !email || !cargo ){
+ if (!email || !cargo) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
diff --git a/server/src/modules/services/funcionario/LoginFuncionarioUseCase.ts b/server/src/modules/services/funcionario/LoginFuncionarioUseCase.ts
index b3b0251..dd4536c 100644
--- a/server/src/modules/services/funcionario/LoginFuncionarioUseCase.ts
+++ b/server/src/modules/services/funcionario/LoginFuncionarioUseCase.ts
@@ -9,7 +9,7 @@ const bcrypt = require('bcrypt');
export class LoginFuncionarioUseCase {
async execute({ email, password }: LoginFuncionarioDTO): Promise<{ token: string, funcionario: Pick }> {
- if( !email || !password ){
+ if (!email || !password) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
diff --git a/server/src/modules/services/funcionario/ValidateFuncionarioUseCase.ts b/server/src/modules/services/funcionario/ValidateFuncionarioUseCase.ts
index b254535..07b4cd6 100644
--- a/server/src/modules/services/funcionario/ValidateFuncionarioUseCase.ts
+++ b/server/src/modules/services/funcionario/ValidateFuncionarioUseCase.ts
@@ -6,12 +6,12 @@ import { AppError } from "../../../errors/error";
const bcrypt = require('bcrypt');
export class ValidateFuncionarioUseCase {
- async execute({ email, temporaryPassword, newPassword }: ValidateFuncionarioDTO): Promise< Pick> {
-
- if( !email || !temporaryPassword || newPassword ){
+ async execute({ email, temporaryPassword, newPassword }: ValidateFuncionarioDTO): Promise> {
+
+ if (!email || !temporaryPassword || newPassword) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
-
+
const funcionario = await prisma.funcionario.findFirst({
where: {
email,
diff --git a/server/src/modules/services/funcionario/ValidateRecoveryUseCase.ts b/server/src/modules/services/funcionario/ValidateRecoveryUseCase.ts
index b63176b..9717ff3 100644
--- a/server/src/modules/services/funcionario/ValidateRecoveryUseCase.ts
+++ b/server/src/modules/services/funcionario/ValidateRecoveryUseCase.ts
@@ -8,7 +8,7 @@ const bcrypt = require('bcrypt');
export class ValidateRecoveryUseCase {
async execute({ email, recoveryPass, newPass }: ValidateRecoveryDTO): Promise<{ token: string, funcionario: Pick }> {
-
+
const errors = [];
if (!email) {
diff --git a/server/src/modules/services/professor/InitProfessorUseCase.ts b/server/src/modules/services/professor/InitProfessorUseCase.ts
index c96cf40..9a0d9d6 100644
--- a/server/src/modules/services/professor/InitProfessorUseCase.ts
+++ b/server/src/modules/services/professor/InitProfessorUseCase.ts
@@ -6,7 +6,7 @@ import { AppError } from "../../../errors/error";
export class InitProfessorUseCase {
async execute({ email }: InitProfessorDTO): Promise<{ professor: Pick }> {
- if( !email ){
+ if (!email) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
@@ -17,7 +17,7 @@ export class InitProfessorUseCase {
});
if (!professor) {
- throw new AppError("Prrofessor não encontrado");
+ throw new AppError("Professor não encontrado");
}
return {
diff --git a/server/src/modules/services/professor/LoginProfessorUseCase.ts b/server/src/modules/services/professor/LoginProfessorUseCase.ts
index bf308bc..138d74e 100644
--- a/server/src/modules/services/professor/LoginProfessorUseCase.ts
+++ b/server/src/modules/services/professor/LoginProfessorUseCase.ts
@@ -8,8 +8,8 @@ const bcrypt = require('bcrypt');
export class LoginProfessorUseCase {
async execute({ email, password }: LoginProfessorDTO): Promise<{ token: string, professor: Pick }> {
-
- if( !email || !password ){
+
+ if (!email || !password) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
@@ -21,7 +21,7 @@ export class LoginProfessorUseCase {
});
if (!professor) {
- throw new AppError("Prrofessor não encontrado ou não validado");
+ throw new AppError("Professor não encontrado ou não validado");
}
const isPasswordValid = bcrypt.compareSync(password, professor.password);
diff --git a/server/src/modules/services/professor/ValidateProfessorUseCase.ts b/server/src/modules/services/professor/ValidateProfessorUseCase.ts
index c4136c2..7b93000 100644
--- a/server/src/modules/services/professor/ValidateProfessorUseCase.ts
+++ b/server/src/modules/services/professor/ValidateProfessorUseCase.ts
@@ -8,7 +8,7 @@ const bcrypt = require('bcrypt');
export class ValidateProfessorUseCase {
async execute({ email, temporaryPassword, newPassword }: ValidateProfessorDTO): Promise> {
- if( !email || !temporaryPassword || !newPassword ){
+ if (!email || !temporaryPassword || !newPassword) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
diff --git a/server/src/modules/services/professor/ValidateRecoveryUseCase.ts b/server/src/modules/services/professor/ValidateRecoveryUseCase.ts
index d18b9e9..0fc07e8 100644
--- a/server/src/modules/services/professor/ValidateRecoveryUseCase.ts
+++ b/server/src/modules/services/professor/ValidateRecoveryUseCase.ts
@@ -8,11 +8,11 @@ const bcrypt = require('bcrypt');
export class ValidateRecoveryUseCase {
async execute({ email, recoveryPass, newPass }: ValidateRecoveryDTO): Promise<{ token: string, professor: Pick }> {
-
- if( !email || !recoveryPass || !newPass ){
+
+ if (!email || !recoveryPass || !newPass) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
-
+
const professor = await prisma.professor.findFirst({
where: {
email
diff --git a/server/src/modules/services/professor/recoveryProfessoruseCase.ts b/server/src/modules/services/professor/recoveryProfessoruseCase.ts
index 1f358c6..6e1cf2f 100644
--- a/server/src/modules/services/professor/recoveryProfessoruseCase.ts
+++ b/server/src/modules/services/professor/recoveryProfessoruseCase.ts
@@ -9,7 +9,7 @@ const bcrypt = require('bcrypt');
export class RecoveryProfessorUseCase {
async execute({ name, email }: RecoveryProfessorDTO) {
- if( !name || !email ){
+ if (!name || !email) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
diff --git a/server/src/modules/services/shared/AcceptVinculoUseCase.ts b/server/src/modules/services/shared/AcceptVinculoUseCase.ts
index 853f98a..135faf2 100644
--- a/server/src/modules/services/shared/AcceptVinculoUseCase.ts
+++ b/server/src/modules/services/shared/AcceptVinculoUseCase.ts
@@ -1,6 +1,6 @@
import { prisma } from "../../../prisma/client";
import { AppError } from "../../../errors/error";
-import { ReagirVinculoDTO, IdentificadorEnum } from "../../interfaces/sharedDTOs";
+import { ReagirVinculoDTO } from "../../interfaces/sharedDTOs";
import { encontrarEntidadePeloEmail } from "./helpers/helpers";
export class AcceptVinculoUseCase {
@@ -8,8 +8,8 @@ export class AcceptVinculoUseCase {
if (!email || !sender || !recipient || !senderIdentifier || !recipientIdentifier) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
-
- if(recipient != email){
+
+ if (recipient != email) {
throw new AppError("Rementente inválido");
}
@@ -37,6 +37,10 @@ export class AcceptVinculoUseCase {
throw new AppError("Solicitação inexistente");
}
+ if (vinculoExists.accepted) {
+ throw new AppError("Solicitação já aceita");
+ }
+
await prisma.vinculo.update({
where: {
id: vinculoExists.id
diff --git a/server/src/modules/services/shared/CreateVinculoUseCase.ts b/server/src/modules/services/shared/CreateVinculoUseCase.ts
index bf7a023..1dc3900 100644
--- a/server/src/modules/services/shared/CreateVinculoUseCase.ts
+++ b/server/src/modules/services/shared/CreateVinculoUseCase.ts
@@ -1,23 +1,27 @@
import { prisma } from "../../../prisma/client";
import { AppError } from "../../../errors/error";
-import { VinculoDTO, IdentificadorEnum } from "../../interfaces/sharedDTOs";
+import { VinculoDTO } from "../../interfaces/sharedDTOs";
import { encontrarEntidadePeloEmail } from "./helpers/helpers";
export class CreateVinculoUseCase {
- async execute({ sender, recipient, senderIdentifier, recipientIdentifier }: VinculoDTO) {
+ async execute({ email, sender, recipient, senderIdentifier, recipientIdentifier }: VinculoDTO) {
if (!sender || !recipient || !senderIdentifier || !recipientIdentifier) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
+ if (email != sender) {
+ throw new AppError("Remetente inválido.");
+ }
+
const senderData = await encontrarEntidadePeloEmail(sender, senderIdentifier);
const recipientData = await encontrarEntidadePeloEmail(recipient, recipientIdentifier);
if (!senderData) {
- throw new AppError(`${senderIdentifier.charAt(0).toUpperCase()}${senderIdentifier.slice(1).toLowerCase()} não encontrado.`);
+ throw new AppError(`${senderIdentifier.charAt(0).toUpperCase()}${senderIdentifier.slice(1).toLowerCase()}(a) remetente não encontrado(a).`);
}
if (!recipientData) {
- throw new AppError(`${recipientIdentifier.charAt(0).toUpperCase()}${recipientIdentifier.slice(1).toLowerCase()} não encontrado.`);
+ throw new AppError(`${recipientIdentifier.charAt(0).toUpperCase()}${recipientIdentifier.slice(1).toLowerCase()}(a) destinatário não encontrado(a).`);
}
const vinculoExists = await prisma.vinculo.findFirst({
diff --git a/server/src/modules/services/shared/DeleteVinculoUseCase.ts b/server/src/modules/services/shared/DeleteVinculoUseCase.ts
new file mode 100644
index 0000000..0fdb38a
--- /dev/null
+++ b/server/src/modules/services/shared/DeleteVinculoUseCase.ts
@@ -0,0 +1,61 @@
+import { prisma } from "../../../prisma/client";
+import { AppError } from "../../../errors/error";
+import { VinculoDTO } from "../../interfaces/sharedDTOs";
+import { encontrarEntidadePeloEmail } from "./helpers/helpers";
+
+export class DeleteVinculoUseCase {
+ async execute({ email, sender, recipient, senderIdentifier, recipientIdentifier }: VinculoDTO) {
+ if (!sender || !recipient || !senderIdentifier || !recipientIdentifier) {
+ throw new AppError("Parâmetros insuficientes ou inválidos.");
+ }
+
+ if (email != sender && email != recipient) {
+ throw new AppError("Usuário não pertence a nenhum dos elos da conexão.");
+ }
+
+ const senderData = await encontrarEntidadePeloEmail(sender, senderIdentifier);
+ const recipientData = await encontrarEntidadePeloEmail(recipient, recipientIdentifier);
+
+ if (!senderData) {
+ throw new AppError(`${senderIdentifier.charAt(0).toUpperCase()}${senderIdentifier.slice(1).toLowerCase()}(a) remetente não encontrado(a).`);
+ }
+
+ if (!recipientData) {
+ throw new AppError(`${recipientIdentifier.charAt(0).toUpperCase()}${recipientIdentifier.slice(1).toLowerCase()}(a) destinatário não encontrado(a).`);
+ }
+
+ const vinculoExists = await prisma.vinculo.findFirst({
+ where: {
+ alunoId: (senderIdentifier == "ALUNO") ? senderData.id : null,
+ professorId: (senderIdentifier == "PROFESSOR") ? senderData.id : null,
+ vinculoComAlunoId: (recipientIdentifier == "ALUNO") ? recipientData.id : null,
+ vinculoComProfessorId: (recipientIdentifier == "PROFESSOR") ? recipientData.id : null
+ },
+ });
+
+ if (!vinculoExists) {
+ throw new AppError("VÃnculo ou solicitação de vÃnculo inexistente");
+ }
+
+ const vinculoAlternativeExists = await prisma.vinculo.findFirst({
+ where: {
+ alunoId: (senderIdentifier == "ALUNO") ? recipientData.id : null,
+ professorId: (senderIdentifier == "PROFESSOR") ? recipientData.id : null,
+ vinculoComAlunoId: (recipientIdentifier == "ALUNO") ? senderData.id : null,
+ vinculoComProfessorId: (recipientIdentifier == "PROFESSOR") ? senderData.id : null
+ },
+ });
+
+ if (!vinculoAlternativeExists) {
+ throw new AppError("VÃnculo ou solicitação de vÃnculo inexistente");
+ }
+
+ await prisma.vinculo.delete({
+ where: {
+ id: vinculoExists ? vinculoExists.id : vinculoAlternativeExists.id
+ }
+ });
+
+ return "VÃnculo ou solicitacão desfeita!";
+ }
+}
diff --git a/server/src/modules/services/admin/GetCursosUseCase.ts b/server/src/modules/services/shared/GetCursosUseCase.ts
similarity index 87%
rename from server/src/modules/services/admin/GetCursosUseCase.ts
rename to server/src/modules/services/shared/GetCursosUseCase.ts
index ba09814..307d111 100644
--- a/server/src/modules/services/admin/GetCursosUseCase.ts
+++ b/server/src/modules/services/shared/GetCursosUseCase.ts
@@ -1,5 +1,4 @@
import { prisma } from "../../../prisma/client";
-import { AppError } from "../../../errors/error";
import { Curso } from "@prisma/client";
export class GetCursosUseCase {
diff --git a/server/src/modules/services/shared/GetUnlinkedsUseCase.ts b/server/src/modules/services/shared/GetUnlinkedsUseCase.ts
new file mode 100644
index 0000000..a718a80
--- /dev/null
+++ b/server/src/modules/services/shared/GetUnlinkedsUseCase.ts
@@ -0,0 +1,112 @@
+import { prisma } from "../../../prisma/client";
+import { AppError } from "../../../errors/error";
+import { IdentificadorEnum, GetVinculosDTO } from "../../interfaces/sharedDTOs";
+import { encontrarEntidadePeloEmail } from "./helpers/helpers";
+
+export class GetUnlinkedsUseCase {
+ async execute({ email, identifier }: GetVinculosDTO) {
+ if (!email) {
+ throw new AppError("Email necessário.");
+ }
+
+ if (!identifier) {
+ throw new AppError("Parâmetros insuficientes ou inválidos.");
+ }
+
+ const entidade = await encontrarEntidadePeloEmail(email, identifier);
+
+ if (!entidade) {
+ throw new AppError(`${identifier.charAt(0).toUpperCase()}${identifier.slice(1).toLowerCase()} não encontrado.`);
+ }
+
+ let todosVinculos;
+ todosVinculos = await prisma.vinculo.findMany({
+ where: {
+ OR: [
+ { alunoId: entidade.id },
+ { vinculoComAlunoId: entidade.id }
+ ]
+ },
+ include: {
+ professor: true
+ }
+ });
+
+ const professoresVinculadosIds = todosVinculos
+ .map(vinculo => vinculo.professorId)
+ .filter((id): id is string => id !== null);
+
+ const professoresVinculosIds = todosVinculos
+ .map(vinculo => vinculo.vinculoComProfessorId)
+ .filter((id): id is string => id !== null);
+
+ const professoresNaoVinculados = await prisma.professor.findMany({
+ where: {
+ AND: [
+ {
+ id: {
+ notIn: professoresVinculadosIds
+ }
+ },
+ {
+ id: {
+ notIn: professoresVinculosIds
+ }
+ }
+ ]
+ }
+ });
+
+ const professores = professoresNaoVinculados.map(professor => ({
+ email: professor.email,
+ identifier: IdentificadorEnum.PROFESSOR
+ }));
+
+ todosVinculos = await prisma.vinculo.findMany({
+ where: {
+ OR: [
+ { professorId: entidade.id },
+ { vinculoComProfessorId: entidade.id }
+ ]
+ },
+ include: {
+ aluno: true
+ }
+ });
+
+ const alunosVinculadosIds = todosVinculos
+ .map(vinculo => vinculo.alunoId)
+ .filter((id): id is string => id !== null);
+
+ const alunosVinculosIds = todosVinculos
+ .map(vinculo => vinculo.vinculoComAlunoId)
+ .filter((id): id is string => id !== null);
+
+ const alunosNaoVinculados = await prisma.aluno.findMany({
+ where: {
+ AND: [
+ {
+ id: {
+ notIn: alunosVinculadosIds
+ }
+ },
+ {
+ id: {
+ notIn: alunosVinculosIds
+ }
+ }
+ ]
+ }
+ });
+
+ const alunos = alunosNaoVinculados.map(aluno => ({
+ email: aluno.email,
+ identifier: IdentificadorEnum.ALUNO
+ }));
+
+ return {
+ alunosSemVinculo: alunos,
+ professoresSemVinculo: professores
+ };
+ }
+}
\ No newline at end of file
diff --git a/server/src/modules/services/shared/GetVinculosUseCase.ts b/server/src/modules/services/shared/GetVinculosUseCase.ts
index 2472db5..ab312be 100644
--- a/server/src/modules/services/shared/GetVinculosUseCase.ts
+++ b/server/src/modules/services/shared/GetVinculosUseCase.ts
@@ -1,6 +1,6 @@
import { prisma } from "../../../prisma/client";
import { AppError } from "../../../errors/error";
-import { IdentificadorEnum, GetVinculosDTO } from "../../interfaces/sharedDTOs";
+import { GetVinculosDTO } from "../../interfaces/sharedDTOs";
import { encontrarEntidadePeloEmail } from "./helpers/helpers";
export class GetVinculosUseCase {
@@ -20,65 +20,44 @@ export class GetVinculosUseCase {
}
let aceitosData, enviadosData, recebidosData;
- if (identifier === IdentificadorEnum.ALUNO) {
- aceitosData = await prisma.vinculo.findMany({
- where: {
- alunoId: entidade.id,
- accepted: true
- },
- include: {
- professor: true
- }
- });
- enviadosData = await prisma.vinculo.findMany({
- where: {
- alunoId: entidade.id,
- accepted: false
- },
- include: {
- professor: true
- }
- });
- recebidosData = await prisma.vinculo.findMany({
- where: {
- vinculoComAlunoId: entidade.id,
- accepted: false
- },
- include: {
- professor: true
- }
- });
- } else if (identifier === IdentificadorEnum.PROFESSOR) {
- aceitosData = await prisma.vinculo.findMany({
- where: {
- professorId: entidade.id,
- accepted: true
- },
- include: {
- aluno: true
- }
- });
- enviadosData = await prisma.vinculo.findMany({
- where: {
- professorId: entidade.id,
- accepted: false
- },
- include: {
- aluno: true
- }
- });
- recebidosData = await prisma.vinculo.findMany({
- where: {
- vinculoComProfessorId: entidade.id,
- accepted: false
- },
- include: {
- aluno: true
- }
- });
- } else {
- throw new AppError("Identificador inválido.");
- }
+ aceitosData = await prisma.vinculo.findMany({
+ where: {
+ OR: [
+ { alunoId: entidade.id },
+ { professorId: entidade.id },
+ { vinculoComAlunoId: entidade.id },
+ { vinculoComProfessorId: entidade.id },
+ ],
+ accepted: true
+ },
+ include: {
+ professor: true
+ }
+ });
+ enviadosData = await prisma.vinculo.findMany({
+ where: {
+ OR: [
+ { alunoId: entidade.id },
+ { professorId: entidade.id },
+ ],
+ accepted: false
+ },
+ include: {
+ professor: true
+ }
+ });
+ recebidosData = await prisma.vinculo.findMany({
+ where: {
+ OR: [
+ { vinculoComAlunoId: entidade.id },
+ { vinculoComProfessorId: entidade.id },
+ ],
+ accepted: false
+ },
+ include: {
+ professor: true
+ }
+ });
const aceitos = await Promise.all(aceitosData.map(async (aceito: any) => {
const sender = async () => {
diff --git a/server/src/modules/services/shared/IgnoreVinculoUseCase.ts b/server/src/modules/services/shared/IgnoreVinculoUseCase.ts
index 7cc0174..0e65399 100644
--- a/server/src/modules/services/shared/IgnoreVinculoUseCase.ts
+++ b/server/src/modules/services/shared/IgnoreVinculoUseCase.ts
@@ -1,6 +1,6 @@
import { prisma } from "../../../prisma/client";
import { AppError } from "../../../errors/error";
-import { ReagirVinculoDTO, IdentificadorEnum } from "../../interfaces/sharedDTOs";
+import { ReagirVinculoDTO } from "../../interfaces/sharedDTOs";
import { encontrarEntidadePeloEmail } from "./helpers/helpers";
export class IgnoreVinculoUseCase {
@@ -8,8 +8,8 @@ export class IgnoreVinculoUseCase {
if (!email || !sender || !recipient || !senderIdentifier || !recipientIdentifier) {
throw new AppError("Parâmetros insuficientes ou inválidos.");
}
-
- if(recipient != email){
+
+ if (recipient != email) {
throw new AppError("Rementente inválido");
}
@@ -44,6 +44,6 @@ export class IgnoreVinculoUseCase {
}
});
- return "Solicitação aceita!";
+ return "Solicitação ignorada!";
}
}
diff --git a/server/src/modules/services/shared/helpers/helpers.ts b/server/src/modules/services/shared/helpers/helpers.ts
index 4c00ccd..89f0275 100644
--- a/server/src/modules/services/shared/helpers/helpers.ts
+++ b/server/src/modules/services/shared/helpers/helpers.ts
@@ -1,6 +1,5 @@
import { IdentificadorEnum } from "../../../interfaces/sharedDTOs";
import { prisma } from "../../../../prisma/client";
-import { AppError } from "../../../../errors/error";
export const encontrarEntidadePeloEmail = async (email: string, identifier: IdentificadorEnum) => {
switch (identifier) {
diff --git a/server/src/router/routes/admin.routes.ts b/server/src/router/routes/admin.routes.ts
index 19f6d88..01df7d3 100644
--- a/server/src/router/routes/admin.routes.ts
+++ b/server/src/router/routes/admin.routes.ts
@@ -1,5 +1,8 @@
import { Router } from "express";
import { adminAuthMiddleware } from '../../middleware/auth/autentication';
+import {
+ GetCursosController
+} from "../../modules/controllers/sharedControllers"
import {
LoginAdminController,
RegisterCursosController,
@@ -8,7 +11,6 @@ import {
RegisterCoordenadorController,
GetAllProfessorController,
GetCoordenadorController,
- GetCursosController,
RegisterTurmaController
} from "../../modules/controllers/adminControllers";
@@ -37,6 +39,6 @@ adminRoutes.get("/auth", adminAuthMiddleware, (req, res) => {
adminRoutes.get("/professores", adminAuthMiddleware, getAllProfessorController.handle);
adminRoutes.get("/coordenadores", adminAuthMiddleware, getCoordenadoresController.handle);
-adminRoutes.get("/cursos", adminAuthMiddleware, getCursosController.handle)
+adminRoutes.get("/cursos", adminAuthMiddleware, getCursosController.handle);
export { adminRoutes };
\ No newline at end of file
diff --git a/server/src/router/routes/aluno.routes.ts b/server/src/router/routes/aluno.routes.ts
index 9e31371..3d167d6 100644
--- a/server/src/router/routes/aluno.routes.ts
+++ b/server/src/router/routes/aluno.routes.ts
@@ -4,7 +4,9 @@ import {
CreateVinculoController,
AcceptVinculoController,
GetVinculosController,
- IgnoreVinculoController
+ IgnoreVinculoController,
+ GetUnlinkedsController,
+ GetCursosController
} from "../../modules/controllers/sharedControllers";
import {
CreateAlunoController,
@@ -13,7 +15,8 @@ import {
RecoveryAlunoController,
ValidateRecoveryController,
CompleteAlunoController,
- UpdateCurriculoController
+ UpdateCurriculoController,
+ GetCourseYearController
} from "../../modules/controllers/alunoControllers";
const createPreAlunoController = new CreatePreAlunoController();
@@ -27,6 +30,9 @@ const createVinculoController = new CreateVinculoController();
const acceptVinculoController = new AcceptVinculoController();
const ignoreVinculoController = new IgnoreVinculoController();
const getVinculosController = new GetVinculosController();
+const getUnlinkedsController = new GetUnlinkedsController();
+const getCursosController = new GetCursosController();
+const getCourseYearController = new GetCourseYearController();
const alunoRoutes = Router();
@@ -41,8 +47,13 @@ alunoRoutes.post("/link/send", alunoAuthMiddleware, createVinculoController.hand
alunoRoutes.post("/link/accept", alunoAuthMiddleware, acceptVinculoController.handle);
alunoRoutes.post("/link/reject", alunoAuthMiddleware, ignoreVinculoController.handle);
-alunoRoutes.get("/links", alunoAuthMiddleware, getVinculosController.handle);
alunoRoutes.get("/auth", alunoAuthMiddleware, (req, res) => {
res.status(200).send("Aluno autenticado com sucesso.");
});
+
+alunoRoutes.get("/links", alunoAuthMiddleware, getVinculosController.handle);
+alunoRoutes.get("/unlinkeds", alunoAuthMiddleware, getUnlinkedsController.handle);
+alunoRoutes.get("/cursos", alunoAuthMiddleware, getCursosController.handle);
+alunoRoutes.get("/cursos/anos", alunoAuthMiddleware, getCourseYearController.handle);
+
export { alunoRoutes };
\ No newline at end of file
diff --git a/server/src/router/routes/empresa.routes.ts b/server/src/router/routes/empresa.routes.ts
index 42b8147..5f13593 100644
--- a/server/src/router/routes/empresa.routes.ts
+++ b/server/src/router/routes/empresa.routes.ts
@@ -13,7 +13,7 @@ const registerEmpresaController = new RegisterEmpresaController();
const validateEmpresaController = new ValidateEmpresaController();
const loginEmpresaController = new LoginEmpresaController();
const recoveryEmpresaController = new RecoveryEmpresaController();
-const validateRecoveryEmpresaController= new ValidateRecoveryEmpresaController();
+const validateRecoveryEmpresaController = new ValidateRecoveryEmpresaController();
const empresaRoutes = Router();
diff --git a/server/src/router/routes/funcionario.routes.ts b/server/src/router/routes/funcionario.routes.ts
index 7cd32a3..c231747 100644
--- a/server/src/router/routes/funcionario.routes.ts
+++ b/server/src/router/routes/funcionario.routes.ts
@@ -22,7 +22,7 @@ funcionarioRoutes.post("/recovery", recoveryFuncionarioController.handle);
funcionarioRoutes.post("/recovery/validate", validateRecoveryController.handle);
-funcionarioRoutes.post("/auth", funcionarioAuthMiddleware, (req, res) => {
+funcionarioRoutes.get("/auth", funcionarioAuthMiddleware, (req, res) => {
res.status(200).send("Funcionário autenticado com sucesso.");
});
diff --git a/server/src/router/routes/professor.routes.ts b/server/src/router/routes/professor.routes.ts
index 2309a44..f1b5ad2 100644
--- a/server/src/router/routes/professor.routes.ts
+++ b/server/src/router/routes/professor.routes.ts
@@ -5,6 +5,7 @@ import {
AcceptVinculoController,
GetVinculosController,
IgnoreVinculoController,
+ GetUnlinkedsController
} from "../../modules/controllers/sharedControllers";
import {
ValidateProfessorController,
@@ -23,6 +24,7 @@ const createVinculoController = new CreateVinculoController();
const acceptVinculoController = new AcceptVinculoController();
const ignoreVinculoController = new IgnoreVinculoController();
const getVinculosController = new GetVinculosController();
+const getUnlinkedsController = new GetUnlinkedsController();
const professorRoutes = Router();
@@ -34,11 +36,12 @@ professorRoutes.post("/link/send", professorAuthMiddleware, createVinculoControl
professorRoutes.post("/link/accept", professorAuthMiddleware, acceptVinculoController.handle);
professorRoutes.post("/link/reject", professorAuthMiddleware, ignoreVinculoController.handle);
-professorRoutes.get("/links", professorAuthMiddleware, getVinculosController.handle);
-professorRoutes.post("/auth", professorAuthMiddleware, (req, res) => {
+professorRoutes.get("/auth", professorAuthMiddleware, (req, res) => {
res.status(200).send("Professor autenticado com sucesso.");
});
professorRoutes.get("/init", initProfessorController.handle);
+professorRoutes.get("/links", professorAuthMiddleware, getVinculosController.handle);
+professorRoutes.get("/unlinkeds", professorAuthMiddleware, getUnlinkedsController.handle);
export { professorRoutes };
\ No newline at end of file