Answer the question
In order to leave comments, you need to log in
Is it possible to accept a parent entity in a Rest controller?
Good day.
Tell me, is it possible to accept the entity of the parent (abstract class) in the REST controller?
For example:
Abstract class:
public abstract class Warrior {
long id;
String name;
Integer age;
Type type;
public class Attackers extends Warrior {
int power;
boolean magic;
}
public class Defenders extends Warrior {
int def;
int magicDef;
}
@PostMapping(value = "/create")
public ResponseEntity<Long> createWarrior(@RequestParam Warrior warrior){
return ResponseEntity.ok(service.createWarrior(warrior));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question