Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
e51c2d2
added auth screens
rlimapro Dec 11, 2024
b16f934
Criação parcial de entidades
renansuaris Dec 13, 2024
baf7451
fixed redefinir-senha fxml file, added Roboto font, added transition …
rlimapro Dec 13, 2024
e946323
Merge branch 'feature/login' of https://github.com/Carvalho-Tech-Solu…
renansuaris Dec 13, 2024
27e4793
Finalização das entidades
renansuaris Dec 13, 2024
9aef1ec
Testing database connection and the mapping of entities for tables in…
renansuaris Dec 13, 2024
0af8d66
Merge pull request #2 from Carvalho-Tech-Solution/feature/conexaoDB
rlimapro Dec 14, 2024
984ce67
added menu.fxml draft
rlimapro Dec 14, 2024
5441769
Admin data auto insert when initializing application
renansuaris Dec 14, 2024
06e43c3
fixed icons issues in menu.fxml
rlimapro Dec 14, 2024
c4b6f23
adjusted details in menu.fxml style
rlimapro Dec 14, 2024
21cf158
added authentication when logging in
rlimapro Dec 14, 2024
d1ad445
Merge pull request #3 from Carvalho-Tech-Solution/feature/login
rlimapro Dec 15, 2024
08f9607
added menu buttons style, service page and functionality to create an…
rlimapro Dec 15, 2024
ba034c7
added modal to confirm removal, remove service functionality and part…
rlimapro Dec 16, 2024
9ce5bfb
added secretary page and functionality to create and persist a secret…
renansuaris Dec 16, 2024
8727659
added secretary page and functionality to create and persist a secret…
renansuaris Dec 16, 2024
12ba7c1
Creation of session manager
renansuaris Dec 16, 2024
7aba031
Creation of secretary login authentication
renansuaris Dec 16, 2024
e60e48d
menu.fxml style finished, finished delete modal and modals to create …
rlimapro Dec 16, 2024
3bf3bc2
Merge pull request #4 from Carvalho-Tech-Solution/feature/menu
saviosoaresc Dec 16, 2024
c250b5b
commit
renansuaris Dec 16, 2024
238c448
Merge branch 'develop' into feature/auth-secretary
rlimapro Dec 17, 2024
158dbe8
Merge pull request #5 from Carvalho-Tech-Solution/feature/auth-secretary
saviosoaresUFC Dec 17, 2024
75cedcd
added valor field verification when creating a new service and brazi…
rlimapro Dec 17, 2024
175160e
Creation of validation in recover password
renansuaris Dec 17, 2024
4b0723f
Recovery password process done for admin / secretary
renansuaris Dec 17, 2024
bd5991b
verification and custumization in service page (#6)
rlimapro Dec 17, 2024
b9e0908
Merge branch 'develop' into feature/recuperar-senha
renansuaris Dec 18, 2024
37a6159
update for responsive screens
rlimapro Dec 29, 2024
a3ff0f4
Merge pull request #10 from Carvalho-Tech-Solution/feature/recuperar-…
SamuelEngSoftware Jan 6, 2025
c8b5a4c
resolve merge conflicts
rlimapro Jan 7, 2025
3f9795b
Merge pull request #11 from Carvalho-Tech-Solution/feature/responsive
SamuelEngSoftware Jan 7, 2025
194954a
added screen, controller and create method for Cliente entity
rlimapro Jan 7, 2025
50ccb45
edit and delete methods for Cliente entity
rlimapro Jan 7, 2025
a543b13
added create pet feature to client page content
rlimapro Jan 9, 2025
1512821
added feature to see all pets from a client when click in Ver Pets bu…
rlimapro Jan 11, 2025
290b80d
added feature to create and delete pets and to see details from a pet.
rlimapro Jan 12, 2025
95fd9de
Added AnimateFX dependency and transition between login and home
renansuaris Jan 13, 2025
9def40a
Show popup login confirmation feature
renansuaris Jan 14, 2025
4546bec
Cliente page (#13)
rlimapro Jan 14, 2025
78c4a61
Merge branch 'develop' into feature/animations
renansuaris Jan 14, 2025
e408159
Fix: fxml path fixed
renansuaris Jan 14, 2025
8371d68
Merge branch 'feature/animations' of https://github.com/Carvalho-Tech…
renansuaris Jan 14, 2025
d267805
added feedback to CRUD operations
rlimapro Jan 18, 2025
858eb84
Creation of mask in client phone field plus validations
renansuaris Jan 20, 2025
787d859
Creation of validation and phone mask in secretary class
renansuaris Jan 20, 2025
2d975bf
creation of additional validation on create service class
renansuaris Jan 21, 2025
3762c25
Feedback messages (#16)
rlimapro Jan 21, 2025
4037d06
Merge branch 'develop' into feature/Validations
renansuaris Jan 21, 2025
a797b20
Update README.md
renansuaris Jan 21, 2025
e332ae2
updated phone mask
rlimapro Jan 22, 2025
532bfa0
password length verification for Secretario register
rlimapro Jan 22, 2025
6f279e9
Merge pull request #18 from EngStrategy/feature/Validations
renansuaris Jan 23, 2025
3895b1b
Addition of a filter search bar in clients, secretaries and services …
renansuaris Jan 23, 2025
a933b2d
added feature to register a new Agendamento
rlimapro Jan 24, 2025
ad6ed7c
added style to search field.
rlimapro Jan 25, 2025
4bdcf52
added fields to finalize scheduling and delete feature
rlimapro Jan 25, 2025
43d02fd
added features to edit and finish a schedule
rlimapro Jan 25, 2025
2b86cba
Merge branch 'develop' into feature/agendamento
rlimapro Jan 25, 2025
641585c
fixed feedback toast error and added search field for pets table
rlimapro Jan 25, 2025
9501e00
Merge pull request #19 from EngStrategy/feature/agendamento
renansuaris Jan 25, 2025
9f4f3ec
Merge pull request #20 from EngStrategy/feature/SearchBar
rlimapro Jan 26, 2025
15540c8
added tests for persistence classes
rlimapro Jan 27, 2025
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
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
# MundoAnimal
# 🐾 Mundo Animal - Sistema de Gestão para Petshop

Mundo Animal é um sistema desktop desenvolvido em **JavaFX** com **PostgreSQL** e **Hibernate (JPA)**, projetado para a gestão eficiente de um petshop. O sistema permite o gerenciamento de clientes, animais, agendamentos, serviços e secretários.

## 🚀 Tecnologias Utilizadas
- **Java 23**
- **JavaFX** (para interface gráfica)
- **PostgreSQL** (banco de dados relacional)
- **Hibernate/JPA** (persistência de dados)
- **Maven** (gerenciador de dependências)
- **BCrypt** (para criptografar senhas)

## 📌Funcionalidades Principais
- **Autenticação:** Login seguro para administradores e secretários.
- **Gerenciamento de Agendamentos:** Exibição dinâmica dos próximos atendimentos na tela inicial.
- **Cadastro de Clientes e Animais:** Relacionamento entre clientes e seus respectivos pets.
- **Controle de Serviços:** Registros de atendimento e relatório de operações.
- **Interface intuitiva:** Com animações suaves e pop-ups de confirmação.

## 🛠️ Instalação e Execução
### Pré-requisitos
- Java 21+ instalado
- PostgreSQL instalado
- Maven instalado

## 📂 Estrutura do Projeto
```
MundoAnimal/
│── src/
│ ├── main/
│ │ ├── java/com/carvalhotechsolutions/mundoanimal/
│ │ │ ├── controllers/
│ │ │ ├── models/
│ │ │ ├── repository/
│ │ │ ├── services/
│ │ ├── resources/
│ │ │ ├── fxml/
│ │ │ ├── images/
│ │ │ ├── styles/
│── pom.xml
│── README.md
```

## 🤝 Contribuição
Se deseja contribuir, siga os passos:
1. Fork este repositório
2. Crie uma branch (`git checkout -b feature/nova-funcionalidade`)
3. Commit suas alterações (`git commit -m 'Adiciona nova funcionalidade'`)
4. Envie um push para a branch (`git push origin feature/nova-funcionalidade`)
5. Abra um Pull Request

## 📜 Licença
Este projeto está sob a licença MIT. Veja o arquivo [LICENSE](LICENSE) para mais detalhes.

---
36 changes: 36 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,46 @@
<artifactId>fontawesomefx</artifactId>
<version>8.2</version>
</dependency>

<dependency>
<groupId>io.github.typhon0</groupId>
<artifactId>AnimateFX</artifactId>
<version>1.3.0</version>
</dependency>

<!-- JUnit 5 -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>

<!-- Mockito -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>

<!-- H2 Database for testing repository -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.3.232</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
55 changes: 18 additions & 37 deletions src/main/java/com/carvalhotechsolutions/mundoanimal/Main.java
Original file line number Diff line number Diff line change
@@ -1,48 +1,29 @@
package com.carvalhotechsolutions.mundoanimal;

import animatefx.animation.FadeIn;
import com.carvalhotechsolutions.mundoanimal.database.DatabaseChecker;
import com.carvalhotechsolutions.mundoanimal.enums.ScreenEnum;
import com.carvalhotechsolutions.mundoanimal.utils.ScreenManagerHolder;
import com.carvalhotechsolutions.mundoanimal.utils.ScreenManager;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.stage.Stage;

import java.io.IOException;

public class Main extends Application {
@Override
public void start(Stage stage) throws IOException {

boolean isConnected = DatabaseChecker.testConnectionAndInitializeAdmin();
if (!isConnected) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Erro de Conexão");
alert.setHeaderText("Não foi possível conectar ao banco de dados.");
alert.setContentText("Verifique as configurações do banco e tente novamente.");
alert.showAndWait();
Platform.exit(); // Encerra a aplicação
return;
}

// Carrega o arquivo FXML da interface principal
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/autenticacao/login.fxml"));
Parent root = fxmlLoader.load();

// Define a cena com o layout carregado
Scene scene = new Scene(root);
// Aplica o CSS à cena
String css = this.getClass().getResource("/css/style.css").toExternalForm();
scene.getStylesheets().add(css);

// Configura o palco principal
stage.setTitle("Login");
stage.setScene(scene);
stage.setFullScreen(true);
stage.setFullScreenExitHint("");
stage.setResizable(false);
// Exibe a interface
public void start(Stage stage) {

// Verifica conexão com o banco de dados
DatabaseChecker.testConnectionAndInitializeAdmin();
// Inicializa o SceneManager
ScreenManager sceneManager = new ScreenManager(stage);
// Inicializa o SceneManagerHolder
ScreenManagerHolder.initialize(sceneManager);
// Seleciona a primeira tela da aplicação
sceneManager.switchTo(ScreenEnum.LOGIN);
// Exibe a tela
stage.show();
// Aplicando FadeIn (AnimateFX)
new FadeIn(sceneManager.getScreen(ScreenEnum.LOGIN)).play();
}

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package com.carvalhotechsolutions.mundoanimal.controllers.login;
package com.carvalhotechsolutions.mundoanimal.controllers.autenticacao;

import com.carvalhotechsolutions.mundoanimal.JPAutil;
import animatefx.animation.FadeIn;
import com.carvalhotechsolutions.mundoanimal.database.JPAutil;
import com.carvalhotechsolutions.mundoanimal.enums.ScreenEnum;
import com.carvalhotechsolutions.mundoanimal.model.Usuario;
import com.carvalhotechsolutions.mundoanimal.security.PasswordUtils;
import com.carvalhotechsolutions.mundoanimal.utils.NavigationManager;
import com.carvalhotechsolutions.mundoanimal.utils.PasswordManager;
import com.carvalhotechsolutions.mundoanimal.utils.ScreenManagerHolder;
import com.carvalhotechsolutions.mundoanimal.utils.SessionManager;
import jakarta.persistence.EntityManager;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;

import java.io.IOException;
import javafx.scene.Node;
import javafx.scene.control.*;

public class LoginController {
@FXML
Expand Down Expand Up @@ -57,25 +56,33 @@ private void handleLogin(ActionEvent event) {
}

// Verifica a senha
if (!PasswordUtils.checkPassword(password, usuario.getSenha())) {
if (!PasswordManager.checkPassword(password, usuario.getSenha())) {
showAlert("Erro", "Senha incorreta.");
return;
}

// Login bem-sucedido - Direciona para o menu principal
// Login bem-sucedido
SessionManager.setCurrentUser(usuario);
NavigationManager.switchScene(event, "/fxml/gerenciamento/menu.fxml", "Pet Shop Mundo Animal");

// PopupManager.showLoginSuccessPopup(ScreenManagerHolder.getInstance().getStage());

// Atualiza a interface do menu através do ScreenManagerHolder
ScreenManagerHolder.getInstance().getMenuController().updateUserInterface(usuario);

// Chamando tela de menu e aplicando FadeIn
Node menuScreen = ScreenManagerHolder.getInstance().getScreen(ScreenEnum.MENU);
new FadeIn(menuScreen).play();
ScreenManagerHolder.getInstance().switchTo(ScreenEnum.MENU);

} catch (Exception e) {
showAlert("Erro", "Ocorreu um erro ao verificar as credenciais: " + e.getMessage());
e.printStackTrace();
}
}

// Método temporário, apenas para testar a troca de telas, não há lógica alguma aplicada
@FXML
private void handleForgotPassword(ActionEvent event) throws IOException {
NavigationManager.switchScene(event, "/fxml/autenticacao/recuperar-senha.fxml", "Recuperar senha");
private void handleForgotPassword() {
ScreenManagerHolder.getInstance().switchTo(ScreenEnum.RECUPERAR_SENHA);
}

private void showAlert(String title, String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.carvalhotechsolutions.mundoanimal.controllers.autenticacao;

import com.carvalhotechsolutions.mundoanimal.database.JPAutil;
import com.carvalhotechsolutions.mundoanimal.enums.ScreenEnum;
import com.carvalhotechsolutions.mundoanimal.model.Administrador;
import com.carvalhotechsolutions.mundoanimal.model.Secretario;
import com.carvalhotechsolutions.mundoanimal.model.Usuario;
import com.carvalhotechsolutions.mundoanimal.utils.ScreenManagerHolder;
import com.carvalhotechsolutions.mundoanimal.utils.SessionManager;
import jakarta.persistence.EntityManager;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.TextField;

import java.io.IOException;

public class RecuperarSenhaController {

@FXML
private TextField recovery_cpf_field;

@FXML
private TextField recovery_username_field;

// Método temporário, apenas para testar a troca de telas, não há lógica alguma aplicada
@FXML
private void backToLogin() throws IOException {
ScreenManagerHolder.getInstance().switchTo(ScreenEnum.LOGIN);
}

@FXML
private void handleResetBtn() throws IOException {

String cpf = recovery_cpf_field.getText();
String username = recovery_username_field.getText();

if (cpf.isEmpty() || username.isEmpty()) {
showAlert("Erro.", "Por favor preencha todos os campos.");
return;
}

try (EntityManager em = JPAutil.getEntityManager()) {
Usuario usuario = null;

// Busca o CPF do administrador padrão
Administrador adminPadrao = em.createQuery(
"SELECT a FROM Administrador a WHERE a.nomeUsuario = 'admin'", Administrador.class)
.getSingleResult();

if (adminPadrao == null) {
showAlert("Erro", "Administrador padrão não encontrado no sistema.");
return;
}

// Busca o usuário pelo nome de usuário
Administrador admin = em.createQuery(
"SELECT a FROM Administrador a WHERE a.nomeUsuario = :username", Administrador.class)
.setParameter("username", username)
.getResultStream()
.findFirst()
.orElse(null);

if (admin != null) {
// Se for administrador, valida o CPF com o próprio admin padrão
if (!cpf.equals(admin.getCpf())) {
showAlert("Erro", "CPF inválido para o administrador.");
return;
}
usuario = admin;
} else {
// Se não for admin, busca em Secretário
Secretario secretario = em.createQuery(
"SELECT s FROM Secretario s WHERE s.nomeUsuario = :username", Secretario.class)
.setParameter("username", username)
.getResultStream()
.findFirst()
.orElse(null);

if (secretario == null) {
showAlert("Erro", "Usuário não encontrado.");
return;
}

// Valida o CPF do secretário com o CPF do administrador padrão
if (!cpf.equals(adminPadrao.getCpf())) {
showAlert("Erro", "CPF inválido para recuperação de senha.");
return;
}
usuario = secretario;
}

// Se passou todas as validações
SessionManager.setCurrentUser(usuario);
ScreenManagerHolder.getInstance().switchTo(ScreenEnum.REDEFINIR_SENHA);

} catch (Exception e) {
showAlert("Erro", "Erro ao buscar usuário: " + e.getMessage());
e.printStackTrace();
}

}

private void showAlert(String title, String message) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(message);
alert.showAndWait();
}
}
Loading