Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
projet-industriel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RAGOT Jessie
projet-industriel
Commits
d93387c4
Commit
d93387c4
authored
4 months ago
by
COULIBALY Aichatou
Browse files
Options
Downloads
Patches
Plain Diff
patient controller
parent
2fe4c740
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/com/projet/projetIndu/controllers/PatientController.java
+64
-0
64 additions, 0 deletions
.../com/projet/projetIndu/controllers/PatientController.java
with
64 additions
and
0 deletions
src/main/java/com/projet/projetIndu/controllers/PatientController.java
+
64
−
0
View file @
d93387c4
package
com.projet.projetIndu.controllers
;
import
com.projet.projetIndu.entities.Patient
;
import
com.projet.projetIndu.services.PatientService
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Optional
;
@RequestMapping
(
"/patients"
)
@Controller
public
class
PatientController
{
private
final
PatientService
patientService
;
public
PatientController
(
PatientService
patientService
)
{
this
.
patientService
=
patientService
;
}
// Afficher tous les patients
@GetMapping
public
String
listPatients
(
Model
model
)
{
List
<
Patient
>
patients
=
patientService
.
getAllPatients
();
model
.
addAttribute
(
"patients"
,
patients
);
return
"patients"
;
// Page HTML contenant la liste des patients
}
//Afficher le formulaire de création d'un patient
@GetMapping
(
"/create"
)
public
String
showCreateForm
(
Model
model
)
{
model
.
addAttribute
(
"patient"
,
new
Patient
());
return
"create-patient"
;
// Page HTML pour ajouter un patient
}
// Enregistrer un nouveau patient
@PostMapping
public
String
createPatient
(
@ModelAttribute
Patient
patient
)
{
patientService
.
savePatient
(
patient
);
return
"redirect:/patients"
;
}
// Rechercher un patient par ID
@GetMapping
(
"/{id}"
)
public
String
getPatientById
(
@PathVariable
Long
id
,
Model
model
)
{
Optional
<
Patient
>
patient
=
patientService
.
getPatientById
(
id
);
if
(
patient
.
isPresent
())
{
model
.
addAttribute
(
"patient"
,
patient
.
get
());
return
"patient-details"
;
// Page HTML avec les détails du patient
}
else
{
return
"redirect:/patients?error=notfound"
;
}
}
//Supprimer un patient par ID
@PostMapping
(
"/{id}/delete"
)
public
String
deletePatient
(
@PathVariable
Long
id
)
{
patientService
.
deletePatientById
(
id
);
return
"redirect:/patients"
;
}
// Afficher le tableau de bord du patient
@GetMapping
(
"/dashboard"
)
public
String
showPatientDashboard
(
Model
model
)
{
return
"patient-dashboard"
;
// Page HTML du tableau de bord patient
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment