Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 46 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,62 @@
## LabenuSystem:
<h1 align="center"> 💻 LabeSystem 💻</h1>

Você estuda na Labenu_ há tanto tempo que já parecem anos, não é? Então, hoje, vamos pedir para criar um sistema que represente o básico da nossa organização.
<h2 align="center"> 📃 Sobre 📃</h2>
<p align="justify"> Projeto de backend desenvolvido conforme proposta da Labenu para criação de uma API para um sistema de uma escola de programação.</p>

Ele deve possuir, ao menos, as 3 entidades importantes:
Esse sistema possui 3 entidades importantes:

1. Estudantes
<h3> Estudantes </h3>

Representa estudantes da nossa instituição. Eles devem possuir: id, nome, email, data de nascimento e os principais hobbies dele.
<p> Representa estudantes da instituição. Eles possuem: id, nome, email, data de nascimento e os principais hobbies deles. </p>

2. Docente
<h3> Docente </h3>

Representa docentes da nossa instituição. Eles devem possuir: id, nome, email, data de nascimento e todas as especialidades dele. Há 7 especialidades: React, Redux, CSS, Testes, Typescript, Programação Orientada a Objetos e Backend
<p> Representa docentes da instituição. Eles possuem: id, nome, email, data de nascimento e todas as especialidades deles. Há 5 especialidades: React, JS, CSS, Typescript, POO. </p>

3. Turma
<h3> Turma </h3>

Toda turma é composta das seguintes características: id, nome, data de início, data de término, lista de professores responsáveis, uma lista de alunos e módulo atual em que a turma está.
<p> Toda turma é composta das seguintes características: id, nome e módulo atual em que a turma está. </p>
<p> O módulo pode assumir os valores de 1 a 6, ou 0, indicando que as aulas dessa turma ainda não começaram. </p>

O módulo pode assumir os valores de 1 a 7 ou `undefined`, indicando que as aulas dessa turma ainda não começaram. Para esse exercício, vamos considerar que existam dois tipos de turma: integral ou noturna. Há uma restrição para o nome das turmas noturnas: tem que terminar com `-na-night`.
<h2 align="center"> 📝 Documentação 📝 </h2>

As funcionalidades básicas são:
<p> https://documenter.getpostman.com/view/19721031/UzXKXeSC </p>

→ Criar estudante;
<h2 align="center"> ✅ O que funciona ✅ </h2>

→ Criar docente;
* Criar estudante;
* Criar docente;
* Criar turma;
* Mudar aluno de turma;
* Mudar docente de turma;
* Mudar módulo da turma;
* Buscar alunos;
* Buscar docentes;
* Buscar todas as turmas;
* Buscar turmas ativas;

→ Criar turma;
<h2 align="center"> 🛠 Em desenvolvimento 🛠 </h2>

→ Adicionar estudante na turma;
* Ao buscar alunos não é exibido a lista de hobbies deles.
* Ao buscar docentes não é exibido a lista de especialidades deles.

→ Adicionar docente na turma;
<h2 align="center">👨‍💻 Desenvolvedores 👩‍💻</h2>

→ Pegar a idade de algum estudante a partir do id
<table align="center">
<tr>

<td align="center"><a href="https://github.com/tiagohennig"><img style="border-radius: 50%" src="https://avatars.githubusercontent.com/u/86529848?v=4" width="100px" alt=""/>
<br />
<sub><b>Tiago Hennig</b></sub></a> <a href="https://github.com/tiagohennig"></a></td>

<td align="center"><a href="https://github.com/raul-rita"><img style="border-radius: 50%" src="https://avatars.githubusercontent.com/u/93088559?v=4" width="100px" alt=""/>
<br />
<sub><b>Raul Rita</b></sub></a> <a href="https://github.com/raul-rita"></a></td>

<td align="center"><a href="https://github.com/Maria-Karolina"><img style="border-radius: 50%" src="https://avatars.githubusercontent.com/u/88107710?v=4" width="100px" alt=""/>
<br />
<sub><b>Maria Karolina Freitas </b></sub></a> <a href="https://github.com/Maria-Karolina"></a></td>

</tr>

</table>
4 changes: 4 additions & 0 deletions labenu-system/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
package-lock.json
build
.env
31 changes: 31 additions & 0 deletions labenu-system/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "labenu-system",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "ts-node-dev ./src/index.ts",
"start": "node ./build/index.js",
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"knex": "^2.1.0",
"mysql": "^2.18.1",
"uuid": "^8.3.2"
},
"devDependencies": {
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/knex": "^0.16.1",
"@types/node": "^18.0.6",
"@types/uuid": "^8.3.4",
"ts-node-dev": "^2.0.0",
"typescript": "^4.7.4"
}
}
76 changes: 76 additions & 0 deletions labenu-system/querys.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
-- Active: 1658325348046@@35.226.146.116@3306@guimaraes-4211089-raul-rita
USE `guimaraes-4211089-raul-rita`;

CREATE TABLE LS_Turma(
id VARCHAR(255) PRIMARY KEY,
nome VARCHAR(255) NOT NULL,
modulo ENUM('0','1','2','3','4','5','6') DEFAULT '0'
);

CREATE TABLE LS_Estudante(
id VARCHAR(255) PRIMARY KEY,
nome VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
data_nasc VARCHAR(255) NOT NULL,
turma_id VARCHAR(255), FOREIGN KEY (turma_id) REFERENCES LS_Turma(id)
);

CREATE TABLE LS_Hobby (
id VARCHAR(255) PRIMARY KEY,
nome_hobby ENUM("assistir séries de tv", "jogar videogames", "sair com os amigos", "praticar esportes") NOT NULL
);



CREATE TABLE LS_Hobby_Estudante(
id VARCHAR(255) PRIMARY KEY,
id_estudante VARCHAR(255), FOREIGN KEY(id_estudante) REFERENCES LS_Estudante(id),
id_hobby VARCHAR(255), FOREIGN KEY(id_hobby) REFERENCES LS_Hobby(id)
);
SELECT * FROM `LS_Hobby_Estudante`;

CREATE TABLE LS_Docente(
id VARCHAR(255) PRIMARY KEY,
nome VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
data_nasc VARCHAR(255) NOT NULL,
turma_id VARCHAR(255), FOREIGN KEY (turma_id) REFERENCES LS_Turma(id)
);

SELECT * FROM `LS_Docente_Especialidade`;

CREATE TABLE LS_Especialidade (
id VARCHAR(255) PRIMARY KEY,
nome_especialidade ENUM("JS", "CSS", "React", "Typescript", "POO") NOT NULL
);

ALTER TABLE `LS_Especialidade`
MODIFY COLUMN nome_especialidade VARCHAR(255) NOT NULL;
SELECT * FROM `LS_Especialidade`;

CREATE TABLE LS_Docente_Especialidade (
id VARCHAR(255) PRIMARY KEY,
id_docente VARCHAR(255), FOREIGN KEY(id_docente) REFERENCES LS_Docente(id),
id_especialidade VARCHAR(255), FOREIGN KEY(id_especialidade) REFERENCES LS_Especialidade(id)
);

ALTER TABLE `LS_Turma`
MODIFY COLUMN modulo VARCHAR(255) NOT NULL DEFAULT 0;

SELECT * FROM `LS_Turma`;

SELECT * FROM LS_Turma INNER JOIN `LS_Estudante` ON LS_Turma.id = LS_Estudante.turma_id;

INSERT INTO `LS_Especialidade`(id,nome_especialidade) VALUES ("1", "react");
INSERT INTO `LS_Especialidade`(id,nome_especialidade) VALUES ("2", "js");
INSERT INTO `LS_Especialidade`(id,nome_especialidade) VALUES ("3", "css");
INSERT INTO `LS_Especialidade`(id,nome_especialidade) VALUES ("4", "typescript");
INSERT INTO `LS_Especialidade`(id,nome_especialidade) VALUES ("5", "poo");


SELECT nome, nome_hobby
FROM LS_Hobby_Estudante
INNER JOIN LS_Estudante
ON LS_Hobby_Estudante.id_estudante = LS_Estudante.id
INNER JOIN LS_Hobby
ON LS_Hobby_Estudante.id_hobby = "8c1fa295-c2b9-4e9f-b62e-7ab486f546af";
81 changes: 81 additions & 0 deletions labenu-system/request.rest
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
POST http://localhost:3003/turma/
Content-Type: application/json

{
"nome": "abc",
"modulo": "5"
}

###

POST http://localhost:3003/estudante/
Content-Type: application/json

{
"nome": "Maria Karolina",
"email": "mariakarolina@email.com",
"data_nasc": "28/06/1993",
"turma_id": "b555b321-8c42-4fab-9083-022c83b965d6",
"hobby": ["Programar", "Nadar", "Dançar"]
}

###

POST http://localhost:3003/docente/
Content-Type: application/json

{
"nome": "Juliana",
"email": "juliana@email.com",
"data_nasc": "28/06/1990",
"turma_id": "b555b321-8c42-4fab-9083-022c83b965d6",
"especialidade": ["React", "JS", "poo"]
}

###

GET http://localhost:3003/turma/ativa

###

GET http://localhost:3003/turma/

###

Get http://localhost:3003/estudante/?nome=

###

GET http://localhost:3003/docente/

###



PUT http://localhost:3003/turma/guimaraes
Content-Type: application/json

{
"modulo": "1"
}

###

PUT http://localhost:3003/estudante/
Content-Type: application/json

{
"id": "a28cafd1-88e4-42b5-951a-1c075d08b8dd",
"turma": "joy"
}

###

PUT http://localhost:3003/docente/
Content-Type: application/json

{
"id": "00800266-93f3-4d5c-b93d-3b6348afd150",
"turma": "joi"
}

19 changes: 19 additions & 0 deletions labenu-system/src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import express from "express";
import cors from "cors"
import { AddressInfo } from "net";

const app = express();

app.use(express.json());
app.use(cors());

const server = app.listen(process.env.PORT || 3003, () => {
if (server) {
const address = server.address() as AddressInfo;
console.log(`Server is running in http://localhost: ${address.port}`);
} else {
console.error(`Failure upon starting server.`);
}
});

export default app;
17 changes: 17 additions & 0 deletions labenu-system/src/classes/Docente.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { User } from "./User"


export class Docente extends User {

public especialidade?: string[]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

especialidades seria um nome melhor, no plural.


constructor(
id:string,
nome:string,
email:string,
data_nasc:string,
turma_id:string,
) {
super(id, nome, email, data_nasc, turma_id)
}
}
17 changes: 17 additions & 0 deletions labenu-system/src/classes/Estudante.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { User } from "./User"


export class Estudante extends User{
public hobby?: string[]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hobbies


constructor(
id:string,
nome:string,
email:string,
data_nasc:string,
turma_id:string
){
super(id, nome, email, data_nasc, turma_id)
}

}
23 changes: 23 additions & 0 deletions labenu-system/src/classes/User.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export class User {
public "id": string
public "nome": string
public "email": string
public "data_nasc": string
public "turma_id": string

constructor(
id:string,
nome:string,
email:string,
data_nasc:string,
turma_id:string
)
{
console.log("Chamando o constructor da Classe User")
this.id = id,
this.nome = nome,
this.email = email,
this.data_nasc = data_nasc
this.turma_id = turma_id
}
Comment on lines +2 to +22
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sobre estilo de código: a declaração dos atributos não precisa de aspas, e pode-se usar a notação constructor(public id: string, public nome: string, etc) {} para ter um código mais enxuto.
Também não deixar console.logs perdidos por aí.

}
26 changes: 26 additions & 0 deletions labenu-system/src/classes/turma.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export enum MODULO {
MODULO_0 = "0",
MODULO_1 = "1",
MODULO_2 = "2",
MODULO_3 = "3",
MODULO_4 = "4",
MODULO_5 = "5",
MODULO_6 = "6",
}

export class Turma {
"id": string
"nome": string
"modulo": MODULO

constructor(
id:string,
nome:string,
modulo:MODULO
)
{
this.id = id;
this.nome = nome;
this.modulo = modulo
}
}
Loading