SimplestController

abstract class SimplestController<I : Serializable, E : SimplestEntity<I>, out Mapper : SimplestMapper<I, E>, out R : SimplestRepository<I, E>, out S : SimplestService<I, E, R, Mapper>>(typeName: String, service: S, mapper: Mapper) : CRUDController<I, E, E, E, E, E, E, E, Mapper, Mapper, R, S> (source)

The simplest variant of CRUDController where the only data model is the entity

This variant is only recommended for very simple data models. Whenever possible, try and use one of the other variants.

This is meant to be extended from a @RestController class, ideally also with a @RequestMapping with some path prefix for the endpoints.

Parameters

I

Id type of the data

E

Entity type of the data which is a SimplestEntity

Mapper

Mapper type of the data which is a SimplestMapper

R

Repository type of the data which is a SimplestRepository

S

Service type of the data which is a SimplestService

Constructors

Link copied to clipboard
fun <out Mapper : SimplestMapper<I, E>, out S : SimplestService<I, E, R, Mapper>> SimplestController(typeName: String, service: S, mapper: Mapper)

Inherited functions

Link copied to clipboard
@PostMapping(consumes = ["application/json"], produces = ["application/json"])
@ResponseStatus(code = HttpStatus.CREATED)
fun create(@RequestBody createDTO: E): E

Default implementation for creating a new entity from given create DTO

Link copied to clipboard
@DeleteMapping(value = ["/{id}"])
@ResponseStatus(value = HttpStatus.NO_CONTENT)
fun delete(@PathVariable(value = "id") id: I)

Default implementation for deleting an entity with given id

Link copied to clipboard
@GetMapping(path = ["/{id}"], produces = ["application/json"])
fun get(@PathVariable(value = "id") id: I): E

Default implementation for getting an entity with given id

Link copied to clipboard
@GetMapping(produces = ["application/json"])
fun getAll(@RequestParam(name = "page", required = false, defaultValue = "0") page: Int, @RequestParam(name = "perPage", required = false, defaultValue = "20") perPage: Int): Paged<E>

Default implementation for listing entities with given pagination

Link copied to clipboard
@PutMapping(path = ["/{id}"], consumes = ["application/json"], produces = ["application/json"])
fun update(@PathVariable(value = "id") id: I, @RequestBody updateDTO: E): E

Default implementation for updating an entity with given id with given update DTO data