GithubHelp home page GithubHelp logo

mateogarciag / college-api-rest-quarkus Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 454 KB

Wellcome to my College API with Java Quarkus Framework. This is a project related to Programming Subject. This project encompasses all the concepts and learnings from Quarkus guide, OpenWebinars and Concepts of Programming's Subject. Enjoy it!!!

Java 83.79% HTML 16.21%

college-api-rest-quarkus's Introduction

College API REST Quarkus

About this Project

  1. This project has branches which are related with "Programming" asignature where are basically related with:
  • This API's using MySQL, you can find it here:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/feature/MySQL

  • This API's using MariaDB, you can find it here:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/feature/MariaDB

  • This API's using PostGreSQL, it's the default Database that I use, you can find it here:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/master

  • This API's using PostGreSQL with Active Record Pattern:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/feature/active-record

  • This API's using name of the University as ID and using mappedBy with this:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/feature/mappedby-name

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/mappedby-name/src/main/java/org/acme/rest/json/entities/University.java

  • This API's using ID type Long of the Student as ID and using mappedBy with this:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/feature/students

In this branch you can see in the Scripts SQL, Entities and enpoints how I use by ID

  1. This Project use all type of Relations: @OneToOne, @OneToMany, @ManyToOne, @ManyToMany. With bidirectional and unidirectional form. All these relations are adaptared with the Entities and Tables.
  • Relation @OneToOne using a Brigde Table "Enrollment":

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/students/src/main/java/org/acme/rest/json/entities/Enrollment.java

  • Relation @ManyToOne and @OneToMany bidirectional -> Student -> University:

@ManyToOne https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/students/src/main/java/org/acme/rest/json/entities/Student.java

@OneToMany https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/students/src/main/java/org/acme/rest/json/entities/University.java

  • Relation @ManyToMany using a Bridge Table "Classes" using @ManyToOne unidirectional(It's a way to do it in replace of to do @ManyToMany with @JoinTable which it's inneficient because we cannot add more field in this Brigde Entity in a JPA context):
  1. You can find the Definition of SQL tables here:

PostGreSQL:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/students/src/main/resources/import-dev.sql

MySQL and MariaDB:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/MySQL/src/main/resources/import-dev.sql

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/MariaDB/src/main/resources/import-dev.sql


Important: If you want more details about why there are a lot of branches and my process you can go to Reflections's section


status application





Tabla de Contenidos

  1. Tecnologías Usadas
  2. Relational Entity Diagram
  3. Apuntes
  4. Data API Rest JSON
  5. Licencia

Tecnologías Usadas

  • Java JDK 11
  • Maven
  • Visual Studio Code
  • IntelliJ
  • Git
  • Docker
  • Quarkus
  • Panache
  • TestContainers

⬆ back to top


RELATIONAL ENTITY DIAGRAM

Relational Entity Diagram

⬆ back to top


Data API Rest JSON

Example with Students:

// GET All http://localhost:8080/api/students/all

[
    {
        "name": "Mateo",
        "surname": "Alvarez",
        "dateBirth": "2005-06-05",
        "phone": "+34 666666666",
        "id": 1050
    },
    {
        "name": "Will",
        "surname": "Smith",
        "dateBirth": "1999-06-17",
        "phone": "+34 677878997",
        "id": 2050
    }
]


// POST : http://localhost:8080/api/students/add
{
    "name": "Pedro",
    "surname": "Gimenez",
    "dateBirth": "1990-12-17",
    "phone": "+34 687687878",
    "university": {
        "id": 1
    }
}
// GET by name : http://localhost:8080/api/students/Mateo

{
    "name": "Mateo",
    "surname": "Alvarez",
    "dateBirth": "2005-06-05",
    "phone": "+34 666666666",
    "id": 1050
}

// PUT : http://localhost:8080/api/students/put

{
    "name": "Pedro",
    "surname": "Gomez",
    "dateBirth": "2010-12-17",
    "phone": "+34 677777777",
    "university": {
        "id": 50
    }
}

// DELETE : http://localhost:8080/api/students/delete/1050
[
    {
        "name": "Will",
        "surname": "Smith",
        "dateBirth": "1999-06-17",
        "phone": "+34 677878997",
        "id": 2050
    }
]

⬆ back to top



Reflexiones

Que has mejorado con este proyecto?

This Project has let me to learn how to create an API REST using DAO Pattern and using all type of Relationals JPA and SQL: @OneToOne, @OneToMany, @ManyToOne, @ManyToMany

This project let me to understand better all concepts trying to create a Real Simulation of a API with I was trying to test different DataTypes of SQL with DataTypes of Java and test if it's works

I prefer DAO pattern because let me to separate more the Layers in the API and because The Entity doesn't have to managed by itself like in the Active Pattern where through PanacheEntity, the Entity use the methods like a EntityManager. So this pattern let me to separate the EntityManager from the Entity itself with a new layer called: RESPOSITORY

⬆ back to top


Licencia

MIT License

Copyright (c) 2021 Mateo Garcia Gonzalez

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

⬆ back to top


Autor

Mateo Garcia Gonzalez


college-api-rest-quarkus's People

Contributors

matdevcoder avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.