Welcome to the cifojava2021-javaee-5 wiki!
JPA @Entity Employee and Images uploading/downloading
- Spring Boot JPA @RestController without View and Thymeleaf
- Rest Controller with image
public class EmployeeImageController
and Swagger - Application.properties
- Classes: JPA @Entity Employee and CrudRepository Interface
- Database: H2 (local or in Memory) and ddl.auto for data
- MongoDB connection and db for images
- Application.properties: mongoDB and H2
- Java classes JPA
n:m TA as two @Entity and
1:n
n:1
1:n
- Employee <> Expense (@Entity H2)
1:n
bidirectional - Employee <> Holidays (@Entity H2)
1:n
unidirectional - Employee <> Enrollment <> Course <> Certificate (@Entity H2)
n:m
- Employee <> EmployeeImage (@Document MongoDB)
1:1
birectional
- Employee <> Expense (@Entity H2)
- Rest Controller (Employee and EmployeeImage)
Project Tree:
- Application.properties: mongoDB and H2
- Layout and fragment
- layout.html
- layout_login.html
- Java classes JPA
- n:m TA as two @Entity and
1:n
n:1
1:n
- Employee <> Expense (@Entity H2)
1:n
bidirectional - Employee <> Holidays (@Entity H2)
1:n
unidirectional - Employee <> Enrollment <> Course <> Certificate (@Entity H2)
n:m
- Employee <> EmployeeImage (@Document MongoDB)
1:1
birectional
- n:m TA as two @Entity and
- Rest Controller (Employee and EmployeeImage)
- CommandLineRunner
- HomeController Fill in entities in H2 and assign them
- Employee (Items detail)
- Courses
- Add couse to employee
- Update status
- Expenses
- Create expense
- Delete expense
- Update expense
- Holidays
- Add holidays date
- Delete holidays dates
- Create holidays (rejects to create an existing year)
- Upload Image
- Rest Controller via Postman
- Add Image:
- upload image option (EmployeImage to mongoDB)
1:1 - bidirectional
(EmployeImage <> Employee)
- Courses
screenshoots from app: https://github.com/AlbertProfe/images/tree/main/cifospring2021/mockup
Employee JPA relationships:
Code on repo: https://github.com/AlbertProfe/employeecourse
Deployed on Heroku
: https://employeecourse.herokuapp.com/
- Application.properties: mongoDB and H2
- Layout and fragment
- layout.html
- layout_login.html
- layout_detail.html
- Java classes JPA
- n:m TA as two @Entity and
1:n
n:1
1:n
- Employee <> Expense (@Entity H2)
1:n
bidirectional - Employee <> Holidays (@Entity H2)
1:n
unidirectional - Employee <> Enrollment <> Course <> Certificate (@Entity H2)
n:m
- Employee <> EmployeeImage (@Document MongoDB)
1:1
birectional
- n:m TA as two @Entity and
- Rest Controller (Employee and EmployeeImage)
- CommandLineRunner
- HomeController Fill in entities in H2 and assign them
- Employee @entity
setEmployeeImageId
withemployeeImageId
string id from mongodb with to-do
- Employee (Items detail)
- Empployee Detail
- Path (th:scr) to mognodb image from
getEmployeeImageId
via rest controller to-do
- Path (th:scr) to mognodb image from
- Courses
- Add couse to employee (insert date and status to-do)
- Update status
- Expenses
- Create expense
- Delete expense (afer deleting return to Expenses or crete new detail to-do)
- Update expense
- Holidays
- Add holidays date
- Delete holidays dates
- Create holidays (rejects to create an existing year)
- Upload Image
- Rest Controller via Postman
- Add Image:
- upload image option (EmployeImage to mongoDB)
1:1 - bidirectional
(EmployeImage <> Employee)
- Empployee Detail
- Enrollments to-do
- Courses and filters to-do
- Thymeleaf pagination to-do
- Thymeleaf validation to-do
- Abstract class and inhrence with audit and DTO to-do
- Java 8 and H2 in memory to
DEPLOY: upload to Heroku
How layout works:
- mongoDBimage: MongoDB connection
- Application.properties:
- spring.data.mongodb.uri=mongodb+srv://cifo:XXXX@clustertest.XXXX.mongodb.net/employeeDB?retryWrites=true
- Swagger:
- @RestController for images of Employee with MongoDB & JPA
public EmployeeImage addEmployeeImage(@RequestParam String name, @RequestParam MultipartFile file) throws IOException
public ResponseEntity<byte[]> getEmployeeImage(@RequestParam String id) throws SQLException
- @RestController for Employee @Entity data with H2 local
- Get images to our HTML with
<a href="http://localhost:8086/getEmployeeImage?id=60e803f1a8ba7a1256b36fac">
- Application.properties:
Upload an image wiht API Rest and Swagger:
Upload an image wiht API Rest and Swagger:
Download an image wiht API Rest and Swagger:
Download an image wiht API Rest and Swagger: