Class AbstractPanacheController<D,E extends io.quarkus.hibernate.orm.panache.PanacheEntity,S extends AbstractPanacheService<E>,A extends AbstractPanacheAssembly<D,E>>

java.lang.Object
br.com.trajy.architecture.base.AbstractPanacheController<D,E,S,A>
Type Parameters:
D - Data Transfer Object Type (DTO)
E - Entity Type
S - Service Type
A - Assembly Type

public abstract class AbstractPanacheController<D,E extends io.quarkus.hibernate.orm.panache.PanacheEntity,S extends AbstractPanacheService<E>,A extends AbstractPanacheAssembly<D,E>> extends Object
Abstract Class that contains boilerplate code to implement GET, CREATE, UPDATE and DELETE rest end-points using Hibernate panache entity reactive
Author:
Trajy
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected A
     
    protected S
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Override this method to handle request after create
    protected void
    Override this method to handle request after delete
    protected void
    Override this method to handle request after find
    protected void
    Override this method to handle request after update
    protected void
    Override this method to handle request before create
    protected void
    Override this method to handle request before delete
    protected void
    Override this method to handle request before find
    protected void
    Override this method to handle request before update
    jakarta.ws.rs.core.Response
    create(D d)
    Boilerplate code implementation to handle POST requests
    jakarta.ws.rs.core.Response
    Boilerplate code implementation to handle DELETE requests
    Boilerplate code implementation to handle GET requests
    jakarta.ws.rs.core.Response
    update(Long id, D d)
    Boilerplate code implementation to handle PUT requests

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AbstractPanacheController

      public AbstractPanacheController()
  • Method Details

    • find

      @GET @Produces("application/json") public List<D> find()
      Boilerplate code implementation to handle GET requests
      Returns:
      List of found objects
    • create

      @POST @Consumes("application/json") @Produces("application/json") public jakarta.ws.rs.core.Response create(D d)
      Boilerplate code implementation to handle POST requests
      Parameters:
      d - data from request body
      Returns:
      no content 204 response
    • update

      @PUT @Path("/{id}") @Consumes("application/json") @Produces("application/json") public jakarta.ws.rs.core.Response update(@PathParam("id") Long id, D d)
      Boilerplate code implementation to handle PUT requests
      Parameters:
      id - id from rul path param
      d - data from request body
      Returns:
      no content 204 response
    • delete

      @DELETE @Path("/{id}") @Produces("application/json") public jakarta.ws.rs.core.Response delete(@PathParam("id") Long id)
      Boilerplate code implementation to handle DELETE requests
      Parameters:
      id - id from request path param
      Returns:
      no content 204 response
    • beforeFind

      protected void beforeFind()
      Override this method to handle request before find
    • afterFind

      protected void afterFind(List<D> es)
      Override this method to handle request after find
      Parameters:
      es - List of found results
    • beforeCreate

      protected void beforeCreate(D d)
      Override this method to handle request before create
      Parameters:
      d - data received from request body
    • afterCreate

      protected void afterCreate()
      Override this method to handle request after create
    • beforeUpdate

      protected void beforeUpdate(Long id, D d)
      Override this method to handle request before update
      Parameters:
      id - received from path url
      d - data received from request body
    • afterUpdate

      protected void afterUpdate()
      Override this method to handle request after update
    • beforeDelete

      protected void beforeDelete(Long id)
      Override this method to handle request before delete
      Parameters:
      id - id received from path url
    • afterDelete

      protected void afterDelete()
      Override this method to handle request after delete