Checkpoint: dziala sprawdzanie values in the exchanges/exchange

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2021-01-06 14:34:25 +01:00
parent 6e65c26e3c
commit 3bcc35e75b
Signed by: y0rune
GPG Key ID: F204C385F57EB348
2 changed files with 29 additions and 2 deletions

View File

@ -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() {

View File

@ -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;
}
}