-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppController.java
More file actions
162 lines (123 loc) · 3.84 KB
/
Copy pathAppController.java
File metadata and controls
162 lines (123 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package com;
import java.util.List;
import org.hibernate.cache.spi.support.AbstractReadWriteAccess.Item;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class AppController {
@Autowired
private doctorRepository dRepo;
@RequestMapping("/")
public String checklogin() {
return "index";
}
@RequestMapping("/home")
public String checkhome() {
return "index";
}
@RequestMapping("/login")
public String checkAdmin() {
return "login";
}
@RequestMapping("/admin")
public String checkAdminn() {
return "admin";
}
@PostMapping("/adddoctor")
public String doctorRegister(doctor doctor) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String encodedPassword = passwordEncoder.encode(doctor.getPassword());
doctor.setPassword(encodedPassword);
dRepo.save(doctor);
return "index";
}
@RequestMapping("/doctorlogin")
public String checkdoctor() {
return "doctorlogin";
}
@RequestMapping("/doctor")
public String checkAdmn() {
return "doctor";
}
@RequestMapping("/patient")
public String checkpatient() {
return "patient";
}
@Autowired
private patientRepository pRepo;
@RequestMapping("/plogin")
public String checkplogin() {
return "plogin";
}
@PostMapping("/plogin")
public String processRegister(patient patient) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String encodedPassword = passwordEncoder.encode(patient.getPassword());
patient.setPassword(encodedPassword);
pRepo.save(patient);
return "plogin";
}
@RequestMapping("/appointment")
public String checkappointmentt() {
return "appointment";
}
@Autowired
private appointmentRepository aRepo;
@RequestMapping("/appointment_success")
public String checkappointment() {
return "appointment_success";
}
@PostMapping("/appointment_success")
public String appointmentRegister(appointment appointment) {
aRepo.save(appointment);
return "appointment_success";
}
@Autowired
private appointmentService service;
@RequestMapping("/viewappointment")
public String viewHomePage(Model model) {
List<appointment> listappointment = service.listAll();
model.addAttribute("listappointment", listappointment);
return "viewappointment";
}
@Autowired
private doctorService doctorservice;
@RequestMapping("/viewdoctors")
public String viewDoctorPage(Model model) {
List<doctor> listdoctor = doctorservice.listAll();
model.addAttribute("listdoctor", listdoctor);
return "viewdoctors";
}
@RequestMapping("/delete/{id}")
public String deleteProduct(@PathVariable(name = "id") int id) {
doctorservice.delete(id);
return "redirect:/viewdoctors";
}
//@RequestMapping("/edit/{id}")
//public ModelAndView updateProduct(@PathVariable(name = "id") int id) {
//ModelAndView mav = new ModelAndView("editdoctor");
//doctor doctor = doctorservice.get(id);
//return mav;
//}
@RequestMapping("/contact")
public String checkcontact() {
return "contact";
}
@Autowired
private contactRepository Crepo;
@PostMapping("/home")
public String query(contact contact) {
Crepo.save(contact);
return "index";
}
}