backend_users.md
0 → 100644
| [Home](home) | [**Escopo**](escopo) | [Processo](processo) | [Design/Mockups](design_mockups) | [Gerência](gerencia) | [Estudos](estudos) | [Arquitetura](arquitetura) | [Contratos](contratos) | [BD](banco_dados) | [Qualidade](qualidade) | [Configuração](configuracao) | [Instalação](instalacao) | [Instruções](instrucoes) | [Utilização](utilizacao) | [Analytics](Analytics) | [Infraestrutura](infraestrutura) | [Dicas](dicas) | | ||
| :-------: | :---------------------: | :---------------: | :---------------------------: | :----------------: | :-------------: | :---------------------: | :-----------------: | :------------: | :-----------------: | :-------------------------: | :---------------------: | :---------------------: | :---------------------: | :-----------------: | :---------------------------: | :---------: | | ||
# Users - usuários | ||
fields: | ||
```js | ||
id: number; | ||
email: string; | ||
password: string; | ||
role: Role; | ||
username: string; | ||
first_name: string; | ||
last_name: string; | ||
gender: Gender; | ||
active: boolean; | ||
``` | ||
Endpoints: | ||
## Create | ||
POST http://localhost:3000/users/ | ||
request: | ||
```json | ||
{ | ||
"email": "[email protected]", | ||
"password": "cpplanta" | ||
} | ||
``` | ||
response: | ||
```json | ||
{ | ||
"id": 15, | ||
"username": null, | ||
"email": "[email protected]", | ||
"active": true, | ||
"role": "DEFAULT", | ||
"first_name": null, | ||
"last_name": null, | ||
"gender": "OTHER", | ||
"created_at": "19/10/2024 01:50:35", | ||
"updated_at": "19/10/2024 01:50:35" | ||
} | ||
``` | ||
Observações: | ||
"role" serve para diferenciar o papel, por exemplo: | ||
ADMIN (Cássio), | ||
ROOT (sistema), | ||
DEMO (demonstração/ apresentação final) | ||
O campo "active", onde ocorrer, serve para exclusão lógica do registro. Quando não houver, a remoção é física. | ||
## FindAll | ||
GET http://localhost:3000/users/ | ||
request: no body | ||
QueryParams: | ||
orderBy | ||
fields: | ||
'id', | ||
'username', | ||
'email', | ||
'first_name', | ||
'last_name', | ||
'gender', | ||
'role', | ||
'created_at', | ||
'updated_at' | ||
response: | ||
```json | ||
[ | ||
{ | ||
"id": 10, | ||
"username": "root", | ||
"email": "[email protected]", | ||
"active": true, | ||
"role": "ROOT", | ||
"first_name": "CP", | ||
"last_name": "Planta", | ||
"gender": "MALE", | ||
"created_at": "18/10/2024 00:09:25", | ||
"updated_at": "18/10/2024 00:09:25" | ||
}, | ||
{ | ||
"id": 11, | ||
"username": "Cassio", | ||
"email": "[email protected]", | ||
"active": true, | ||
"role": "ROOT", | ||
"first_name": "Cassio", | ||
"last_name": "Santos", | ||
"gender": "MALE", | ||
"created_at": "18/10/2024 00:09:25", | ||
"updated_at": "18/10/2024 00:09:25" | ||
}, | ||
{ | ||
"id": 12, | ||
"username": "Roberto", | ||
"email": "[email protected]", | ||
"active": true, | ||
"role": "DEMO", | ||
"first_name": "Roberto", | ||
"last_name": "Da Silva", | ||
"gender": "MALE", | ||
"created_at": "18/10/2024 00:09:25", | ||
"updated_at": "18/10/2024 00:09:25" | ||
}, | ||
(...) | ||
] | ||
``` | ||
## FindById | ||
GET http://localhost:3000/users/12 | ||
request: no body | ||
response: | ||
```json | ||
{ | ||
"id": 12, | ||
"username": "Roberto", | ||
"email": "[email protected]", | ||
"active": true, | ||
"role": "DEMO", | ||
"first_name": "Roberto", | ||
"last_name": "Da Silva", | ||
"gender": "MALE", | ||
"created_at": "18/10/2024 00:09:25", | ||
"updated_at": "18/10/2024 00:09:25" | ||
} | ||
``` | ||
## Update | ||
PATH http://localhost:3000/users/12 | ||
request: | ||
- queryparams: | ||
![1729314551145](resources/images/backend/Contratosbackefront/1729314551145.png) | ||
response: | ||
```json | ||
{ | ||
"id": 12, | ||
"username": "fernanda", | ||
"email": "[email protected]", | ||
"active": true, | ||
"role": "DEFAULT", | ||
"first_name": "Fernanda", | ||
"last_name": "Silva", | ||
"gender": "FEMALE", | ||
"created_at": "18/10/2024 00:09:25", | ||
"updated_at": "19/10/2024 02:07:17" | ||
} | ||
``` | ||
## Delete | ||
DELETE http://localhost:3000/users/12 | ||
request: no body | ||
response: | ||
```json | ||
{ | ||
"message": "User ID 12 deleted successfully" | ||
} | ||
``` | ||
## Reactvate | ||
POST http://localhost:3000/users/activate/12 | ||
request: no body | ||
response: | ||
```json | ||
{ | ||
"message": "User ID 12 activated successfully" | ||
} | ||
``` |