Home | Escopo | Processo | Design/Mockups | Gerência | Estudos | Arquitetura | Contratos | BD | Qualidade | Configuração | Instalação | Instruções | Utilização | Analytics | Infraestrutura | Dicas |
---|
Users - usuários
fields:
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:
{
"email": "[email protected]",
"password": "cpplanta"
}
response:
{
"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:
[
{
"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:
{
"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:
response:
{
"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:
{
"message": "User ID 12 deleted successfully"
}
Reactvate
POST http://localhost:3000/users/activate/12
request: no body
response:
{
"message": "User ID 12 activated successfully"
}