Checkpoint: dziala sprawdzanie values in the exchanges/exchange
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
parent
6e65c26e3c
commit
3bcc35e75b
@ -4,6 +4,8 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class Exchange {
|
||||
@ -12,8 +14,16 @@ public class Exchange {
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "trader_id")
|
||||
private User trader;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "owned_id")
|
||||
private Assignment ownedAssignment;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "desired_id")
|
||||
private Groups desiredAssignment;
|
||||
|
||||
public Exchange() {
|
||||
|
@ -1,8 +1,15 @@
|
||||
package com.plannaplan.controllers;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.plannaplan.App;
|
||||
import com.plannaplan.entities.Assignment;
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.entities.User;
|
||||
import com.plannaplan.repositories.ExchangeRepository;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -21,7 +28,17 @@ public class ExchangeController {
|
||||
|
||||
@PostMapping("/exchange")
|
||||
@ApiOperation(value = "Return all courses")
|
||||
public ResponseEntity<String> createExchange(@RequestBody Map<String, Object> exchangeRequest){
|
||||
public ResponseEntity<String> createExchange(@RequestBody Map<String, Long> exchangeRequest){
|
||||
Long user = exchangeRequest.get("user");
|
||||
Long assignment = exchangeRequest.get("assignment");
|
||||
Long group = exchangeRequest.get("group");
|
||||
|
||||
if(user == null || assignment == null|| group == null ){
|
||||
return new ResponseEntity<>("Some of provided value missing", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
//System.out.println("KUPA");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user