|
|
@ -5,12 +5,15 @@ import fr.iut.sciencequest.sae.assemblers.IndiceModelAssembler;
|
|
|
|
import fr.iut.sciencequest.sae.assemblers.ThematiqueModelAssembler;
|
|
|
|
import fr.iut.sciencequest.sae.assemblers.ThematiqueModelAssembler;
|
|
|
|
import fr.iut.sciencequest.sae.assemblers.ThematiqueSimpleModelAssembler;
|
|
|
|
import fr.iut.sciencequest.sae.assemblers.ThematiqueSimpleModelAssembler;
|
|
|
|
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueDTO;
|
|
|
|
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueDTO;
|
|
|
|
|
|
|
|
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueLibelleOnlyDTO;
|
|
|
|
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
|
|
|
|
import fr.iut.sciencequest.sae.dto.thematique.ThematiqueSimpleDTO;
|
|
|
|
import fr.iut.sciencequest.sae.entities.Difficulte;
|
|
|
|
import fr.iut.sciencequest.sae.entities.Difficulte;
|
|
|
|
import fr.iut.sciencequest.sae.entities.Thematique;
|
|
|
|
import fr.iut.sciencequest.sae.entities.Thematique;
|
|
|
|
import fr.iut.sciencequest.sae.services.interfaces.IThematiqueService;
|
|
|
|
import fr.iut.sciencequest.sae.services.interfaces.IThematiqueService;
|
|
|
|
|
|
|
|
import jakarta.annotation.Nullable;
|
|
|
|
import jakarta.validation.Valid;
|
|
|
|
import jakarta.validation.Valid;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
|
|
|
import org.modelmapper.ModelMapper;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
import org.springframework.data.web.PageableDefault;
|
|
|
|
import org.springframework.data.web.PageableDefault;
|
|
|
@ -32,6 +35,7 @@ public class ThematiqueController extends Controller {
|
|
|
|
private final ThematiqueSimpleModelAssembler thematiqueSimpleModelAssembler;
|
|
|
|
private final ThematiqueSimpleModelAssembler thematiqueSimpleModelAssembler;
|
|
|
|
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
|
|
|
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
|
|
|
private final PagedResourcesAssembler<Thematique> pagedResourcesAssembler;
|
|
|
|
private final PagedResourcesAssembler<Thematique> pagedResourcesAssembler;
|
|
|
|
|
|
|
|
private final ModelMapper modelMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@ResponseStatus(HttpStatus.OK)
|
|
|
|
@ResponseStatus(HttpStatus.OK)
|
|
|
@ -40,17 +44,17 @@ public class ThematiqueController extends Controller {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//TODO : gestion des erreurs remontées par @Valid
|
|
|
|
//TODO : gestion des erreurs remontées par @Valid
|
|
|
|
//TODO : ajouter liens hateos
|
|
|
|
|
|
|
|
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@ResponseStatus(HttpStatus.CREATED)
|
|
|
|
@ResponseStatus(HttpStatus.CREATED)
|
|
|
|
public ThematiqueDTO createThematique(@Valid @RequestBody Thematique thematique) {
|
|
|
|
public ThematiqueSimpleDTO createThematique(@Valid @RequestBody ThematiqueLibelleOnlyDTO thematique) {
|
|
|
|
return thematiqueModelAssembler.toModel(this.thematiqueService.create(thematique));
|
|
|
|
return thematiqueSimpleModelAssembler.toModel(this.thematiqueService.create(this.modelMapper.map(thematique, Thematique.class)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PatchMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@PatchMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@ResponseStatus(HttpStatus.CREATED)
|
|
|
|
@ResponseStatus(HttpStatus.CREATED)
|
|
|
|
public ThematiqueDTO updateThematique(@PathVariable("id") int id, @Valid @RequestBody Thematique thematique) {
|
|
|
|
public ThematiqueSimpleDTO updateThematique(@PathVariable("id") int id, @Valid @RequestBody ThematiqueLibelleOnlyDTO partialThematique) {
|
|
|
|
|
|
|
|
Thematique thematique = this.modelMapper.map(partialThematique, Thematique.class);
|
|
|
|
thematique.setId(id);
|
|
|
|
thematique.setId(id);
|
|
|
|
return thematiqueModelAssembler.toModel(this.thematiqueService.update(thematique));
|
|
|
|
return thematiqueSimpleModelAssembler.toModel(this.thematiqueService.update(thematique));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|