/cifojava2021-javaee-5

Spring Boot with @RestController and Swagger connected to H2 local database and MongoDB clouddatabase for images.

Primary LanguageHTML

Welcome to the cifojava2021-javaee-5 wiki!

cifojava2021-javaee-5

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

employeeCourse (java-EE spring)

employeeCourse:

  • 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
  • Rest Controller (Employee and EmployeeImage)

Project Tree:

| | | |

employeeCourse2:

  • 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
  • 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)

screenshoots from app: https://github.com/AlbertProfe/images/tree/main/cifospring2021/mockup

Employee JPA relationships:

employeeCourse3:

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
  • Rest Controller (Employee and EmployeeImage)
  • CommandLineRunner
    • HomeController Fill in entities in H2 and assign them
    • Employee @entity
      • setEmployeeImageId with employeeImageId 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
    • 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)
  • 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 (java-EE spring)

  • mongoDBimage: MongoDB connection
    • Application.properties:
    • 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">

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: