Skip to content

Commit 19ef8a4

Browse files
feat(api): Adding route to get description of the api and fix the bugs.
1 parent 8d95053 commit 19ef8a4

File tree

11 files changed

+212
-36
lines changed

11 files changed

+212
-36
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.env
12

23
target/
34
!.mvn/wrapper/maven-wrapper.jar

README.md

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,79 @@
1+
🌍 [Leia em Português](README.pt-BR.md)
2+
13
# Tech Mech Api
24

3-
Esta é uma API desenvolvida em java para o projeto TechMec.
5+
This is an API developed in java in order to perform manipulations in the database for the Tech Mech project.
46

5-
## Funcionalidade
7+
## Technologies used
68

7-
- Autenticar o usuário
9+
- `Git` - Version control.
10+
- `Java`- Development of api.
11+
- `Maven` - Build automation and dependency management tool for the api.
812

9-
## Requisitos
13+
## Requirements for installation
1014

11-
Certifique-se de ter o **Java** instalado em sua máquina e o **Compilador Java**
15+
Make sure you have the `node`, `npm` and `Java Development Kit` installed in your machine for run the project.
1216

13-
## Passos para Instalação e Inicialização do projeto:
17+
## Steps for installation and run the API
1418

15-
1. Clone o repositório:
19+
1. Clone the repository:
1620

1721
```bash
1822
git clone https://github.com/felipeclarindo/tech-mech-api.git
1923
```
2024

21-
2. Entre no diretorio da api:
25+
2. Enter the directory of api:
2226

23-
```cd
27+
```bash
2428
tech-mech-api
2529
```
2630

27-
3. Inicie o arquivo `Main.java`.
31+
3. Configure your oracle database credentials in `src/main/java/resources/application.properties`.
32+
33+
4. Execute sql locate at `sql/table/clients.sql` in the database.
34+
35+
5. Run the file `Main.java`.
36+
37+
## Steps for installation and run the Front-end
2838

29-
4. Pronto a API está no ar, agora clone o repositório de Front:
39+
1. Clone the front end repository:
3040

3141
```bash
32-
git clone https://github.com/felipeclarindo/tech-mech
42+
git clone https://github.com/felipeclarindo/tech-mech.git
3343
```
3444

35-
5. Entre no diretorio:
45+
2. Enter the directory:
3646

3747
```bash
3848
cd tech-mech
3949
```
4050

41-
6. instale as dependencias:
51+
3. Now let's run the front-end (Make sure the api is running)
4252

4353
```bash
4454
npm install
4555
```
4656

47-
7. Rode o projeto localmente (certifique-se de que a API de java também esteja rodando):
57+
4. Run the project locally (make sure the java API is running as well):
4858

4959
```bash
5060
npm run dev
5161
```
5262

53-
8. Clique no link disponibilizado no terminal, normalmente:
63+
5. Click on the link provided in the terminal, usually:
5464

55-
- http://localhost:3000
65+
- `http://localhost:3000`
5666

57-
## Contribuição
67+
## Contribution
5868

59-
Contribuições são bem-vindas! Se você tiver sugestões de melhorias, sinta-se à vontade para abrir uma issue ou enviar um pull request.
69+
Contributions are welcome! If you have suggestions for improvements, feel free to open an issue or submit a pull request.
6070

61-
## Autores
71+
## Authors
6272

6373
- [Felipe Clarindo](https://github.com/felipeclarindo)
6474
- [Victor Augusto](https://github.com/victoraugustogfavaro)
6575
- [Jennie Suzuki](https://github.com/jenniesuzuki)
6676

67-
## Licença
77+
## License
6878

69-
Este projeto está licenciado sob a [GNU Affero License](https://www.gnu.org/licenses/agpl-3.0.html).
79+
This project is licensed under the [GNU Affero License](https://www.gnu.org/licenses/agpl-3.0.html).

README.pt-BR.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
🌍 [Read in English](README.md)
2+
3+
# Tech Mech Api
4+
5+
Esta é uma API desenvolvida em java com o intuito de realizar manipulações no banco de dados para o projeto Tech Mech.
6+
7+
## Tecnologias utilizadas
8+
9+
- `Git` - Controle de Versão.
10+
- `Java`- Desenvolvimento da API.
11+
- `Maven` - Ferramenta de automação de build e gerenciamento de dependências para a api.
12+
13+
## Requisitos para instalação
14+
15+
Certifique-se de ter o `Java Development Kit`, `node`, `npm` instalado em sua máquina para executar o projeto.
16+
17+
## Passos para instalação e para execução da API
18+
19+
1. Clone o repositório da api:
20+
21+
```bash
22+
git clone https://github.com/felipeclarindo/tech-mech-api.git
23+
```
24+
25+
2. Entre no diretório:
26+
27+
```bash
28+
cd tech-mech-api
29+
```
30+
31+
3. Configure suas credenciais do banco de dados oracle em `src/main/java/resources/application.properties`.
32+
33+
4. Execute no seu banco de dados oracle o sql localizado em `sql/table/clients.sql`.
34+
35+
5. Execute o arquivo `Main.java`.
36+
37+
## Passos para a instalação e executação do Front-end.
38+
39+
1. Clone o repositorio do front end:
40+
41+
```bash
42+
git clone https://github.com/felipeclarindo/tech-mech.git
43+
```
44+
45+
2. Entre no diretório:
46+
47+
```bash
48+
cd tech-mech
49+
```
50+
51+
3. Instale as dependências:
52+
53+
```bash
54+
npm install
55+
```
56+
57+
4. Execute o projeto localmente. (Certifique-se de que a api já esteja sendo executada)
58+
59+
```bash
60+
npm run dev
61+
```
62+
63+
5. Clique no link disponibilizado no terminal, normalmente:
64+
65+
- `http://localhost:3000`
66+
67+
## Contribuição
68+
69+
Contribuições são bem-vindas! Se você tiver sugestões de melhorias, sinta-se à vontade para abrir uma issue ou enviar um pull request.
70+
71+
## Autores
72+
73+
- [Felipe Clarindo](https://github.com/felipeclarindo)
74+
- [Victor Augusto](https://github.com/victoraugustogfavaro)
75+
- [Jennie Suzuki](https://github.com/jenniesuzuki)
76+
77+
## Licença
78+
79+
Este projeto está licenciado sob a [GNU Affero License](https://www.gnu.org/licenses/agpl-3.0.html).

pom.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33

44
<modelVersion>4.0.0</modelVersion>
55

@@ -31,10 +31,16 @@
3131
<artifactId>jersey-hk2</artifactId>
3232
</dependency>
3333

34-
<dependency>
34+
<dependency>
3535
<groupId>org.glassfish.jersey.media</groupId>
3636
<artifactId>jersey-media-json-binding</artifactId>
3737
</dependency>
38+
39+
<dependency>
40+
<groupId>io.github.cdimascio</groupId>
41+
<artifactId>dotenv-java</artifactId>
42+
<version>3.0.0</version>
43+
</dependency>
3844

3945
<dependency>
4046
<groupId>com.oracle.database.jdbc</groupId>
@@ -95,5 +101,8 @@
95101
<jersey.version>3.1.8</jersey.version>
96102
<junit5.version>5.10.2</junit5.version>
97103
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
104+
<maven.compiler.source>15</maven.compiler.source>
105+
<maven.compiler.target>15</maven.compiler.target>
98106
</properties>
107+
99108
</project>

sql/table/clients.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE TABLE clients (
2+
cpf VARCHAR(11) PRIMARY KEY,
3+
nm_cliente VARCHAR(255) NOT NULL,
4+
telefone VARCHAR(11) NOT NULL,
5+
senha VARCHAR(255) NOT NULL
6+
);

src/main/java/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public class Main {
2020
*/
2121
public static HttpServer startServer() {
2222
// create a resource config that scans for JAX-RS resources and providers
23-
// in br.com.fiap package
24-
final ResourceConfig rc = new ResourceConfig().packages("br.com.fiap.resource");
23+
// in resource package
24+
final ResourceConfig rc = new ResourceConfig().packages("resource");
2525

2626
// create and start a new instance of grizzly http server
2727
// exposing the Jersey application at BASE_URI

src/main/java/bo/ClienteBO.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package bo;
22

3+
import java.util.ArrayList;
4+
35
import dao.ClienteDAO;
46
import to.ClienteTO;
5-
import java.util.ArrayList;
67

78
public class ClienteBO {
89
private ClienteDAO clienteDAO;

src/main/java/dao/ConnectionFactory.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,4 @@ public String getPass() {
9191
public String getDriver() {
9292
return driver;
9393
}
94-
95-
9694
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package resource;
2+
3+
import jakarta.ws.rs.GET;
4+
import jakarta.ws.rs.Path;
5+
import jakarta.ws.rs.Produces;
6+
import jakarta.ws.rs.core.MediaType;
7+
8+
import java.util.HashMap;
9+
import java.util.Map;
10+
11+
@Path("/api")
12+
public class ApiResource {
13+
14+
@GET
15+
@Produces(MediaType.APPLICATION_JSON) // Indica que o retorno será em formato JSON
16+
public Map<String, Object> getApiDescription() {
17+
Map<String, Object> description = new HashMap<>();
18+
description.put("welcome", "Welcome to the Tech Mech API!");
19+
description.put("API status", "Running");
20+
description.put("description", "Below are the available routes for managing clients:");
21+
22+
Map<String, Object> routes = new HashMap<>();
23+
24+
routes.put("GET /api/clients", Map.of(
25+
"description", "Retrieve all registered clients.",
26+
"response", "List of clients in JSON format."
27+
));
28+
29+
routes.put("GET /api/clients/{cpf}", Map.of(
30+
"description", "Retrieve client details by CPF.",
31+
"pathParameter", Map.of("cpf", "Client's CPF (e.g., 12345678900)."),
32+
"response", "JSON object containing client details."
33+
));
34+
35+
routes.put("POST /api/clients", Map.of(
36+
"description", "Add a new client.",
37+
"requestBody", Map.of(
38+
"name", "Client's name (String)",
39+
"cpf", "Client's CPF (String)",
40+
"password", "Client's password (String)",
41+
"phone", "Client's phone number (String)"
42+
),
43+
"response", "Success message with client ID."
44+
));
45+
46+
routes.put("PUT /api/clients/{cpf}", Map.of(
47+
"description", "Update existing client details.",
48+
"pathParameter", Map.of("cpf", "Client's CPF to update."),
49+
"requestBody", "JSON object with updated client data.",
50+
"response", "Success message indicating the update status."
51+
));
52+
53+
routes.put("DELETE /api/clients/{cpf}", Map.of(
54+
"description", "Delete a client by CPF.",
55+
"pathParameter", Map.of("cpf", "Client's CPF to delete."),
56+
"response", "Success message indicating the deletion status."
57+
));
58+
59+
description.put("routes", routes);
60+
description.put("note", "Use these endpoints to manage client information effectively. Ensure proper authentication and authorization when integrating this API.");
61+
62+
return description;
63+
}
64+
}

src/main/java/resource/ClienteResource.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
package resource;
22

3+
import java.util.ArrayList;
4+
35
import bo.ClienteBO;
4-
import to.ClienteTO;
56
import jakarta.validation.Valid;
6-
import jakarta.ws.rs.*;
7+
import jakarta.ws.rs.Consumes;
8+
import jakarta.ws.rs.DELETE;
9+
import jakarta.ws.rs.GET;
10+
import jakarta.ws.rs.POST;
11+
import jakarta.ws.rs.PUT;
12+
import jakarta.ws.rs.Path;
13+
import jakarta.ws.rs.PathParam;
14+
import jakarta.ws.rs.Produces;
715
import jakarta.ws.rs.core.MediaType;
816
import jakarta.ws.rs.core.Response;
9-
import java.util.ArrayList;
17+
import to.ClienteTO;
1018

11-
@Path("/techmec/clientes")
19+
@Path("/api/clients")
1220
public class ClienteResource {
1321
private ClienteBO clienteBO = new ClienteBO();
1422

0 commit comments

Comments
 (0)