Add the gestion of scholarshipRequest (accept and refuse and select the amount)
This commit is contained in:
@ -15,6 +15,7 @@ import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.UninscriptionRequest;
|
||||
|
||||
import javax.swing.text.html.parser.Entity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
@ -94,4 +95,25 @@ public class RequestsController {
|
||||
uninscriptionRequestRepository.save(ur);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping(value = "/scholarshipreq/")
|
||||
public ResponseEntity<String> editScholReq(@RequestBody Map<String,Object> infos){
|
||||
ScholarshipRequest scholarshipRequest = srr.findById((Integer) infos.get("id"));
|
||||
|
||||
if (infos.get("state").equals("Accepted")){
|
||||
scholarshipRequest.setState(RequestState.Accepted);
|
||||
scholarshipRequest.setAmount((int) infos.get("amount"));
|
||||
}else{
|
||||
scholarshipRequest.setState(RequestState.Refused);
|
||||
}
|
||||
|
||||
srr.save(scholarshipRequest);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/scholarshipreq/{id}")
|
||||
public ResponseEntity<ScholarshipRequest> getScholReqbyId(@PathVariable long id){
|
||||
ScholarshipRequest toReturn = srr.findById(id);
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
@ -4,5 +4,5 @@ import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest;
|
||||
|
||||
public interface ScholarshipRequestRepository extends CrudRepository<ScholarshipRequest, Long> {
|
||||
|
||||
public ScholarshipRequest findById(long id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user