Checkpoint: Added docs, improved ExchangeEntity
This commit is contained in:
parent
b633d2c2df
commit
90f154f23b
@ -18,7 +18,7 @@ public class Exchange {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "owned_id")
|
@JoinColumn(name = "owned_id", unique = true)
|
||||||
private Assignment ownedAssignment;
|
private Assignment ownedAssignment;
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
|
@ -24,6 +24,12 @@ public class ExchangeService {
|
|||||||
return this.repo.save(exchange);
|
return this.repo.save(exchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param assignment Assignment to trade for
|
||||||
|
* @param group Desired group
|
||||||
|
* @return Optional with Exchange if exist
|
||||||
|
*/
|
||||||
public Optional<Exchange> checkForExchange(Assignment assignment, Groups group){
|
public Optional<Exchange> checkForExchange(Assignment assignment, Groups group){
|
||||||
return this.repo.checkForExchange(assignment, group);
|
return this.repo.checkForExchange(assignment, group);
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,8 @@ public class ExchangeController extends TokenBasedController{
|
|||||||
|
|
||||||
final Assignment assignmentInstance = assignment.get();
|
final Assignment assignmentInstance = assignment.get();
|
||||||
final Groups groupInstance = group.get();
|
final Groups groupInstance = group.get();
|
||||||
final Optional<Exchange> exchangeInstance = this.exchangeService.checkForExchange(assignmentInstance, groupInstance);
|
|
||||||
|
|
||||||
if(!(assignmentInstance.getCommision().getCommisionOwner().getId() == asker.getId() && assignmentInstance.isAccepted() && exchangeInstance.isEmpty())){
|
if(!(assignmentInstance.getCommision().getCommisionOwner().getId().equals(asker.getId()) && assignmentInstance.isAccepted())){
|
||||||
return new ResponseEntity<>("Some of problems appeared. Check if you have access to given assignment and if it is accepted or the exchange has not been already added.", HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>("Some of problems appeared. Check if you have access to given assignment and if it is accepted or the exchange has not been already added.", HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user