Implements the possibility to ask for a scholarship for a student
This commit is contained in:
		| @ -7,26 +7,42 @@ import org.springframework.web.bind.annotation.PostMapping; | ||||
| import org.springframework.web.bind.annotation.RequestBody; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
| import ovh.herisson.Clyde.Repositories.ExemptionsRequestRepository; | ||||
| import ovh.herisson.Clyde.Repositories.ScholarshipRequestRepository; | ||||
| import ovh.herisson.Clyde.Tables.ExemptionsRequest; | ||||
| import ovh.herisson.Clyde.Tables.RequestState; | ||||
| import ovh.herisson.Clyde.Tables.ScholarshipRequest; | ||||
|  | ||||
| @RestController | ||||
| @CrossOrigin(originPatterns = "*", allowCredentials = "true") | ||||
| public class RequestsController { | ||||
|  | ||||
|     public final ExemptionsRequestRepository err; | ||||
|     public final ScholarshipRequestRepository srr; | ||||
|  | ||||
|     public RequestsController(ExemptionsRequestRepository err) { | ||||
|     public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr) { | ||||
|         this.err = err; | ||||
|         this.srr = srr; | ||||
|     } | ||||
|  | ||||
|     @PostMapping(value="/exemptionreq") | ||||
|     public ResponseEntity<String> register(@RequestBody ExemptionsRequest exemptionsRequest){ | ||||
|  | ||||
|         //This line ensures that the request is sent in pending state not matter what | ||||
|         exemptionsRequest.setState(RequestState.Pending); | ||||
|  | ||||
|         err.save(exemptionsRequest); | ||||
|  | ||||
|         return new ResponseEntity<>(HttpStatus.CREATED); | ||||
|     } | ||||
|  | ||||
|     @PostMapping(value="/scholarshipreq") | ||||
|     public ResponseEntity<String> register(@RequestBody ScholarshipRequest scholarshipRequest){ | ||||
|  | ||||
|         //This line ensures that the request is sent in pending state not matter what | ||||
|         scholarshipRequest.setState(RequestState.Pending); | ||||
|  | ||||
|         srr.save(scholarshipRequest); | ||||
|  | ||||
|         return new ResponseEntity<>(HttpStatus.CREATED); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,8 @@ | ||||
| package ovh.herisson.Clyde.Repositories; | ||||
|  | ||||
| import org.springframework.data.repository.CrudRepository; | ||||
| import ovh.herisson.Clyde.Tables.ScholarshipRequest; | ||||
|  | ||||
| public interface ScholarshipRequestRepository extends CrudRepository<ScholarshipRequest, Long> { | ||||
|  | ||||
| } | ||||
| @ -2,35 +2,39 @@ package ovh.herisson.Clyde.Tables; | ||||
|  | ||||
| import jakarta.persistence.*; | ||||
|  | ||||
| import java.util.Date; | ||||
|  | ||||
| @Entity | ||||
| public class ScholarshipRequest { | ||||
|     @Id | ||||
|     @GeneratedValue(strategy = GenerationType.AUTO) | ||||
|     private int id; | ||||
|     private long id; | ||||
|  | ||||
|     @ManyToOne | ||||
|     @JoinColumn(name = "Users") | ||||
|     private User user; | ||||
|     private long userId; | ||||
|     private RequestState state; | ||||
|     private String requestForm; | ||||
|     private Date date; | ||||
|     private int amount; | ||||
|  | ||||
|     private String taxDocUrl; | ||||
|     private String residencyDocUrl; | ||||
|  | ||||
|     public ScholarshipRequest(User user, RequestState state, String requestForm, int amount){ | ||||
|         this.user = user; | ||||
|     public ScholarshipRequest(long userId, RequestState state, int amount, Date date, String taxDocUrl, String residencyDocUrl){ | ||||
|         this.userId = userId; | ||||
|         this.state = state; | ||||
|         this.requestForm = requestForm; | ||||
|         this.amount = amount; | ||||
|         this.date = date; | ||||
|         this.taxDocUrl = taxDocUrl; | ||||
|         this.residencyDocUrl = residencyDocUrl; | ||||
|     } | ||||
|  | ||||
|     public ScholarshipRequest(){} | ||||
|  | ||||
|     public User getUser() { | ||||
|         return user; | ||||
|     public Long getUserId() { | ||||
|         return userId; | ||||
|     } | ||||
|  | ||||
|     public void setUser(User user) { | ||||
|         this.user = user; | ||||
|     public void setUserId(Long userId) { | ||||
|         this.userId = userId; | ||||
|     } | ||||
|  | ||||
|     public RequestState getState() { | ||||
| @ -41,14 +45,6 @@ public class ScholarshipRequest { | ||||
|         this.state = state; | ||||
|     } | ||||
|  | ||||
|     public String getRequestForm() { | ||||
|         return requestForm; | ||||
|     } | ||||
|  | ||||
|     public void setRequestForm(String requestForm) { | ||||
|         this.requestForm = requestForm; | ||||
|     } | ||||
|  | ||||
|     public int getAmount() { | ||||
|         return amount; | ||||
|     } | ||||
| @ -56,4 +52,32 @@ public class ScholarshipRequest { | ||||
|     public void setAmount(int amount) { | ||||
|         this.amount = amount; | ||||
|     } | ||||
|  | ||||
|     public Date getDate() { | ||||
|         return date; | ||||
|     } | ||||
|  | ||||
|     public void setDate(Date date) { | ||||
|         this.date = date; | ||||
|     } | ||||
|  | ||||
|     public long getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public String getResidencyDocUrl() { | ||||
|         return residencyDocUrl; | ||||
|     } | ||||
|  | ||||
|     public void setResidencyDocUrl(String residencyDocUrl) { | ||||
|         this.residencyDocUrl = residencyDocUrl; | ||||
|     } | ||||
|  | ||||
|     public String getTaxDocUrl() { | ||||
|         return taxDocUrl; | ||||
|     } | ||||
|  | ||||
|     public void setTaxDocUrl(String taxDocUrl) { | ||||
|         this.taxDocUrl = taxDocUrl; | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user