Skip to content

Commit bfd1bc0

Browse files
committed
Changes
1 parent cc9e6d7 commit bfd1bc0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3000
-2437
lines changed

app/.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

app/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Step 1: Use Maven with JDK 17 to build the app
2+
FROM maven:3.9.9-eclipse-temurin-17 AS builder
3+
4+
WORKDIR /app
5+
6+
COPY pom.xml .
7+
COPY src ./src
8+
9+
RUN mvn clean package -DskipTests
10+
11+
# Step 2: Use lightweight JRE 17 for running the app
12+
FROM eclipse-temurin:17.0.15_6-jre
13+
14+
WORKDIR /app
15+
16+
COPY --from=builder /app/target/back-end-0.0.1-SNAPSHOT.jar app.jar
17+
18+
EXPOSE 8080
19+
20+
ENTRYPOINT ["java", "-jar", "app.jar"]

app/pom.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,13 @@
9393
<version>0.12.6</version>
9494
<scope>runtime</scope>
9595
</dependency>
96-
96+
<dependency>
97+
<groupId>org.springframework.boot</groupId>
98+
<artifactId>spring-boot-starter-data-jdbc</artifactId>
99+
</dependency>
100+
97101

98-
</dependencies>
102+
</dependencies>
99103

100104
<build>
101105
<plugins>

app/src/main/java/com/project/back_end/BackEndApplication.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.springframework.context.annotation.ComponentScan;
66

77
@SpringBootApplication
8-
@ComponentScan("com.project.back_end")
98
public class BackEndApplication {
109

1110
public static void main(String[] args) {
Lines changed: 102 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,105 @@
11
package com.project.back_end.DTO;
22

3+
import java.time.LocalDateTime;
4+
import java.time.LocalDate;
5+
import java.time.LocalTime;
6+
37
public class AppointmentDTO {
4-
// 1. 'id' field:
5-
// - Type: private Long
6-
// - Description:
7-
// - Represents the unique identifier for the appointment.
8-
// - This is the primary key for identifying the appointment in the system.
9-
10-
// 2. 'doctorId' field:
11-
// - Type: private Long
12-
// - Description:
13-
// - Represents the ID of the doctor associated with the appointment.
14-
// - This is a simplified field, capturing only the ID of the doctor (not the full Doctor object).
15-
16-
// 3. 'doctorName' field:
17-
// - Type: private String
18-
// - Description:
19-
// - Represents the name of the doctor associated with the appointment.
20-
// - This is a simplified field for displaying the doctor's name.
21-
22-
// 4. 'patientId' field:
23-
// - Type: private Long
24-
// - Description:
25-
// - Represents the ID of the patient associated with the appointment.
26-
// - This is a simplified field, capturing only the ID of the patient (not the full Patient object).
27-
28-
// 5. 'patientName' field:
29-
// - Type: private String
30-
// - Description:
31-
// - Represents the name of the patient associated with the appointment.
32-
// - This is a simplified field for displaying the patient's name.
33-
34-
// 6. 'patientEmail' field:
35-
// - Type: private String
36-
// - Description:
37-
// - Represents the email of the patient associated with the appointment.
38-
// - This is a simplified field for displaying the patient's email.
39-
40-
// 7. 'patientPhone' field:
41-
// - Type: private String
42-
// - Description:
43-
// - Represents the phone number of the patient associated with the appointment.
44-
// - This is a simplified field for displaying the patient's phone number.
45-
46-
// 8. 'patientAddress' field:
47-
// - Type: private String
48-
// - Description:
49-
// - Represents the address of the patient associated with the appointment.
50-
// - This is a simplified field for displaying the patient's address.
51-
52-
// 9. 'appointmentTime' field:
53-
// - Type: private LocalDateTime
54-
// - Description:
55-
// - Represents the scheduled date and time of the appointment.
56-
// - The time when the appointment is supposed to happen, stored as a LocalDateTime object.
57-
58-
// 10. 'status' field:
59-
// - Type: private int
60-
// - Description:
61-
// - Represents the status of the appointment.
62-
// - Status can indicate if the appointment is "Scheduled:0", "Completed:1", or other statuses (e.g., "Canceled") as needed.
63-
64-
// 11. 'appointmentDate' field (Custom Getter):
65-
// - Type: private LocalDate
66-
// - Description:
67-
// - A derived field representing only the date part of the appointment (without the time).
68-
// - Extracted from the 'appointmentTime' field.
69-
70-
// 12. 'appointmentTimeOnly' field (Custom Getter):
71-
// - Type: private LocalTime
72-
// - Description:
73-
// - A derived field representing only the time part of the appointment (without the date).
74-
// - Extracted from the 'appointmentTime' field.
75-
76-
// 13. 'endTime' field (Custom Getter):
77-
// - Type: private LocalDateTime
78-
// - Description:
79-
// - A derived field representing the end time of the appointment.
80-
// - Calculated by adding 1 hour to the 'appointmentTime' field.
81-
82-
// 14. Constructor:
83-
// - The constructor accepts all the relevant fields for the AppointmentDTO, including simplified fields for the doctor and patient (ID, name, etc.).
84-
// - It also calculates custom fields: 'appointmentDate', 'appointmentTimeOnly', and 'endTime' based on the 'appointmentTime' field.
85-
86-
// 15. Getters:
87-
// - Standard getter methods are provided for all fields: id, doctorId, doctorName, patientId, patientName, patientEmail, patientPhone, patientAddress, appointmentTime, status, appointmentDate, appointmentTimeOnly, and endTime.
88-
// - These methods allow access to the values of the fields in the AppointmentDTO object.
89-
90-
}
8+
9+
private Long id;
10+
11+
// Simplified Doctor fields
12+
private Long doctorId;
13+
14+
private String doctorName;
15+
16+
// Simplified Patient fields
17+
private Long patientId;
18+
private String patientName;
19+
private String patientEmail;
20+
private String patientPhone;
21+
private String patientAddress;
22+
23+
private LocalDateTime appointmentTime;
24+
private int status;
25+
26+
// Custom getters for the date and time
27+
private LocalDate appointmentDate;
28+
private LocalTime appointmentTimeOnly;
29+
private LocalDateTime endTime;
30+
31+
// Constructor
32+
public AppointmentDTO(Long id, Long doctorId,String doctorName, Long patientId, String patientName,
33+
String patientEmail, String patientPhone, String patientAddress,
34+
LocalDateTime appointmentTime, int status) {
35+
this.id = id;
36+
this.doctorId = doctorId;
37+
this.doctorName=doctorName;
38+
this.patientId = patientId;
39+
this.patientName = patientName;
40+
this.patientEmail = patientEmail;
41+
this.patientPhone = patientPhone;
42+
this.patientAddress = patientAddress;
43+
this.appointmentTime = appointmentTime;
44+
this.status = status;
45+
46+
47+
// Calculate custom fields
48+
this.appointmentDate = appointmentTime != null ? appointmentTime.toLocalDate() : null;
49+
this.appointmentTimeOnly = appointmentTime != null ? appointmentTime.toLocalTime() : null;
50+
this.endTime = appointmentTime != null ? appointmentTime.plusHours(1) : null;
51+
}
52+
53+
// Getters and Setters
54+
public Long getId() {
55+
return id;
56+
}
57+
58+
public Long getDoctorId() {
59+
return doctorId;
60+
}
61+
62+
public String getDoctorName() {
63+
return doctorName;
64+
}
65+
66+
public Long getPatientId() {
67+
return patientId;
68+
}
69+
70+
public String getPatientName() {
71+
return patientName;
72+
}
73+
74+
public String getPatientEmail() {
75+
return patientEmail;
76+
}
77+
78+
public String getPatientPhone() {
79+
return patientPhone;
80+
}
81+
82+
public String getPatientAddress() {
83+
return patientAddress;
84+
}
85+
86+
public LocalDateTime getAppointmentTime() {
87+
return appointmentTime;
88+
}
89+
90+
public int getStatus() {
91+
return status;
92+
}
93+
94+
public LocalDate getAppointmentDate() {
95+
return appointmentDate;
96+
}
97+
98+
public LocalTime getAppointmentTimeOnly() {
99+
return appointmentTimeOnly;
100+
}
101+
102+
public LocalDateTime getEndTime() {
103+
return endTime;
104+
}
105+
}
Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
package com.project.back_end.DTO;
22

3+
34
public class Login {
4-
5-
// 1. 'email' field:
6-
// - Type: private String
7-
// - Description:
8-
// - Represents the email address used for logging into the system.
9-
// - The email field is expected to contain a valid email address for user authentication purposes.
10-
11-
// 2. 'password' field:
12-
// - Type: private String
13-
// - Description:
14-
// - Represents the password associated with the email address.
15-
// - The password field is used for verifying the user's identity during login.
16-
// - It is generally hashed before being stored and compared during authentication.
17-
18-
// 3. Constructor:
19-
// - No explicit constructor is defined for this class, as it relies on the default constructor provided by Java.
20-
// - This class can be initialized with setters or directly via reflection, as per the application's needs.
21-
22-
// 4. Getters and Setters:
23-
// - Standard getter and setter methods are provided for both 'email' and 'password' fields.
24-
// - The 'getEmail()' method allows access to the email value.
25-
// - The 'setEmail(String email)' method sets the email value.
26-
// - The 'getPassword()' method allows access to the password value.
27-
// - The 'setPassword(String password)' method sets the password value.
28-
29-
30-
}
5+
6+
private String email;
7+
private String password;
8+
9+
//getters and setters
10+
11+
public String getEmail() {
12+
return email;
13+
}
14+
15+
public void setEmail(String email) {
16+
this.email = email;
17+
}
18+
19+
20+
public String getPassword() {
21+
return password;
22+
}
23+
24+
public void setPassword(String password) {
25+
this.password = password;
26+
}
27+
28+
}
Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,46 @@
1-
21
package com.project.back_end.controllers;
32

4-
public class AdminController {
3+
import java.util.Map;
54

6-
// 1. Set Up the Controller Class:
7-
// - Annotate the class with `@RestController` to indicate that it's a REST controller, used to handle web requests and return JSON responses.
8-
// - Use `@RequestMapping("${api.path}admin")` to define a base path for all endpoints in this controller.
9-
// - This allows the use of an external property (`api.path`) for flexible configuration of endpoint paths.
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.http.ResponseEntity;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
import org.springframework.web.bind.annotation.PostMapping;
10+
import org.springframework.web.bind.annotation.RequestBody;
11+
import org.springframework.web.bind.annotation.RequestMapping;
12+
import org.springframework.web.bind.annotation.RestController;
1013

14+
import com.project.back_end.models.Admin;
15+
import com.project.back_end.services.Service;
1116

12-
// 2. Autowire Service Dependency:
13-
// - Use constructor injection to autowire the `Service` class.
14-
// - The service handles core logic related to admin validation and token checking.
15-
// - This promotes cleaner code and separation of concerns between the controller and business logic layer.
17+
@RestController
18+
@RequestMapping("${api.path}" + "admin")
19+
public class AdminController {
1620

21+
private final Service service;
1722

18-
// 3. Define the `adminLogin` Method:
19-
// - Handles HTTP POST requests for admin login functionality.
20-
// - Accepts an `Admin` object in the request body, which contains login credentials.
21-
// - Delegates authentication logic to the `validateAdmin` method in the service layer.
22-
// - Returns a `ResponseEntity` with a `Map` containing login status or messages.
23+
@Autowired
24+
public AdminController(Service service) {
25+
this.service = service;
26+
}
2327

28+
@PostMapping
29+
public ResponseEntity<Map<String, String>> adminLogin(@RequestBody Admin admin)
30+
{
31+
return service.validateAdmin(admin);
32+
}
2433

2534

26-
}
35+
@GetMapping("/dashboard/{token}")
36+
public String adminDashboard(@PathVariable String token)
37+
{
38+
Map<String, String> map=service.validateToken(token,"admin").getBody();
39+
if(map==null)
40+
{
41+
return "admin/adminDashboard";
42+
}
43+
return "redirect:http://localhost:8080/";
2744

45+
}
46+
}

0 commit comments

Comments
 (0)