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.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Exchange {
|
public class Exchange {
|
||||||
@ -12,8 +14,16 @@ public class Exchange {
|
|||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "trader_id")
|
||||||
private User trader;
|
private User trader;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "owned_id")
|
||||||
private Assignment ownedAssignment;
|
private Assignment ownedAssignment;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "desired_id")
|
||||||
private Groups desiredAssignment;
|
private Groups desiredAssignment;
|
||||||
|
|
||||||
public Exchange() {
|
public Exchange() {
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
package com.plannaplan.controllers;
|
package com.plannaplan.controllers;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.plannaplan.App;
|
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.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -18,10 +25,20 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
@RequestMapping("/api/" + App.API_VERSION + "/exchanges")
|
@RequestMapping("/api/" + App.API_VERSION + "/exchanges")
|
||||||
@Api(tags = { "Exchange" }, value = "Exchange", description = "Endpoint to exchange with accepted assignments.")
|
@Api(tags = { "Exchange" }, value = "Exchange", description = "Endpoint to exchange with accepted assignments.")
|
||||||
public class ExchangeController {
|
public class ExchangeController {
|
||||||
|
|
||||||
@PostMapping("/exchange")
|
@PostMapping("/exchange")
|
||||||
@ApiOperation(value = "Return all courses")
|
@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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user