feat: gestion des dotations equipements et historique des paiements
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.astalange.web.controller;
|
||||
|
||||
import com.astalange.core.entity.Dotation;
|
||||
import com.astalange.core.repository.DotationRepository;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Controller
|
||||
public class DotationController {
|
||||
|
||||
private final DotationRepository dotationRepository;
|
||||
|
||||
public DotationController(DotationRepository dotationRepository) {
|
||||
this.dotationRepository = dotationRepository;
|
||||
}
|
||||
|
||||
@PostMapping("/dotations/{id}")
|
||||
public String updateDotation(
|
||||
@PathVariable Long id,
|
||||
@RequestParam Long adherentId,
|
||||
@RequestParam(required = false, defaultValue = "") String taille,
|
||||
@RequestParam(required = false, defaultValue = "") String flocage,
|
||||
@RequestParam(required = false) Boolean fourni) {
|
||||
|
||||
Dotation dotation = dotationRepository.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid Dotation ID: " + id));
|
||||
|
||||
dotation.setTaille(taille);
|
||||
dotation.setFlocage(flocage);
|
||||
dotation.setFourni(fourni != null && fourni);
|
||||
|
||||
dotationRepository.save(dotation);
|
||||
|
||||
return "redirect:/adherents/" + adherentId + "/edit";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user