Skip to content

Service Layer interface

rmrn65 edited this page Sep 12, 2021 · 9 revisions

Wiki ▸ Conventions ▸ REST API ▸ Service Layer Interface

The Service Layer interface is used as a template that enforces the implementation of common methods in service classes.

The interface is named ServiceInterface and it is located in the service package within the java-api folder.

Path: /java-api/src/main/java/org/scoalaonline/api/service/ServiceInterface

The interface contains the following methods:

  • List<T> getAll()
  • T getOneById( String id );
  • T add( T entry );
  • T update( String id, T object);
  • void delete( String id );

Using ServiceInterface

All the service classes will have to implement this interface. For example, given an class Student and a service StudentService the implementation will look like this:

public class StudentService implements ServiceInterface<Student> {
...
}

Afterwards, you will have to implement all the methods listed previously, acordingly to the explanations given in the comments of the ServiceInterface.

Note: The generic type T used in the representation of the methods, will be replaced by the class you are making the service for. In our example this would be the Student class, so the methods will become:

public class StudentService implements ServiceInterface<Student> {

    public List<Student> getAll(){
         ...
    }
    public Student getOneById( String id ){
         ...
    }
    public Student add( Student entry ){
         ...
    }
    public Student update( String id, Student student){
         ...
    }
    public void delete( String id ){
         ...
    }
}

Getting Started

Conventions

  1. General

  1. REST API

  1. E-Learning App

Endpoints

Custom Components

Themes

Packages Used

  1. Global

  1. REST API

  1. E-Learning App

Clone this wiki locally