SimpleController

abstract class SimpleController<I : Serializable, E : SimpleEntity<I>, M : SimpleModel<I>, D : SimpleDTO<I>, out Mapper : SimpleMapper<I, E, M, D>, out R : SimpleRepository<I, E>, out S : SimpleService<I, E, M, D, R, Mapper>>(typeName: String, service: S, mapper: Mapper) : CRUDController<I, E, M, D, M, M, D, D, Mapper, Mapper, R, S> (source)

Simple variant of CRUDController where create/update models are just models and create/update DTOs are just DTOs

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 SimpleEntity

M

Model type of the data which is a SimpleModel

D

DTO type of the data which is a SimpleDTO

Mapper

Mapper type of the data which is a SimpleMapper

R

Repository type of the data which is a SimpleRepository

S

Service type of the data which is a SimpleService

Constructors

Link copied to clipboard
constructor(typeName: String, service: S, mapper: Mapper)

Inherited functions

Link copied to clipboard
@PostMapping(consumes = ["application/json"], produces = ["application/json"])
@ResponseStatus(code = HttpStatus.CREATED)
open fun create(@RequestBody createDTO: D, @PathVariable pathVariables: Map<String, String>, request: HttpServletRequest): D

Default implementation for creating a new entity from given create DTO

Link copied to clipboard
@DeleteMapping(value = ["/{id}"])
@ResponseStatus(value = HttpStatus.NO_CONTENT)
open fun delete(@PathVariable(value = "id") id: I, @PathVariable pathVariables: Map<String, String>, request: HttpServletRequest)

Default implementation for deleting an entity with given id

Link copied to clipboard
@GetMapping(path = ["/{id}"], produces = ["application/json"])
open fun get(@PathVariable(value = "id") id: I, @PathVariable pathVariables: Map<String, String>, request: HttpServletRequest): D

Default implementation for getting an entity with given id

Link copied to clipboard
@GetMapping(produces = ["application/json"])
open fun list(@RequestParam(name = "page", required = false, defaultValue = "0") page: Int, @RequestParam(name = "perPage", required = false, defaultValue = "20") perPage: Int, @PathVariable pathVariables: Map<String, String>, request: HttpServletRequest): Paged<D>

Default implementation for listing entities with given pagination

Link copied to clipboard
@PutMapping(path = ["/{id}"], consumes = ["application/json"], produces = ["application/json"])
open fun update(@PathVariable(value = "id") id: I, @RequestBody updateDTO: D, @PathVariable pathVariables: Map<String, String>, request: HttpServletRequest): D

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