r/SpringBoot • u/TheUnknown_73 • Jun 12 '24
My First Spring boot project and my first reddit post
I mainly created projects using the MERN stack but recently found myself leaning towards Spring. This is my first personal project in Spring after completing Chad Darby's Udemy course and watching a bit of Bouali Ali's YouTube channel.
If you could spare some time, I would really appreciate any kind of feedback, advice, and guidance. Any mistakes I have made, or anything that I could or should change?
Here's my repo:
https://github.com/D1SCR3DIT/Employee_Management_System/tree/main
1
u/LookAtYourEyes Jun 12 '24
Maybe I'm missing something, haven't read through your whole project yet but what is this doing in your EmployeeController?
private EmployeeDTO employeeResponse(Employee employee) {
return new EmployeeDTO(
employee.getId(),
employee.getFirstName(),
employee.getLastName(),
employee.getUsername(),
employee.getEmail(),
employee.getRole(),
employee.getProjectId()
);
}
I don't see it being using anywhere else in the controller, and usually DTOs are mapped or created at the service layer. I might be missing something though.
1
u/TheUnknown_73 Jun 13 '24
I initially had all the logic in the controller layer itself and then later shifted all the logic part to the service layer. Must have forgotten to remove this function from the controller while I was doing that. I'll remove it now
2
2
u/nightmare_0204 Jun 13 '24
What is the use of this project in our life? I guess this project is implemented in the course itself. Please correct me if I am wrong.
You can utilise this knowledge to build something unique on your own which can be utilised in your day to day life and also by others.
I hope my opinion will help you.
1
2
u/thesarfo Jun 13 '24
Validate all your request DTOs for instance with @NotBlank and other annotations
And validate the DTO in your controller with @Valid annotations
Also you need to have more robust error handling