Checkpoint: szkielet

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2021-01-06 13:40:04 +01:00
parent cfc1e3eba7
commit 6e65c26e3c
Signed by: y0rune
GPG Key ID: F204C385F57EB348
4 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,57 @@
package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Exchange {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private User trader;
private Assignment ownedAssignment;
private Groups desiredAssignment;
public Exchange() {
}
public Exchange(User trader, Assignment ownedAssignment, Groups desiredAssignment){
this.trader = trader;
this.ownedAssignment = ownedAssignment;
this.desiredAssignment = desiredAssignment;
}
public Long getId(){
return this.id;
}
public Groups getDesiredAssignment() {
return desiredAssignment;
}
public void setDesiredAssignment(Groups desiredAssignment) {
this.desiredAssignment = desiredAssignment;
}
public Assignment getOwnedAssignment() {
return ownedAssignment;
}
public void setOwnedAssignment(Assignment ownedAssignment) {
this.ownedAssignment = ownedAssignment;
}
public User getTrader() {
return trader;
}
public void setTrader(User trader) {
this.trader = trader;
}
}

View File

@ -0,0 +1,11 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.Exchange;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ExchangeRepository extends JpaRepository<Exchange, Long>{
}

View File

@ -0,0 +1,18 @@
package com.plannaplan.services;
import com.plannaplan.entities.Exchange;
import com.plannaplan.repositories.ExchangeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ExchangeService {
@Autowired
private ExchangeRepository repo;
public Exchange save(Exchange exchange){
return this.repo.save(exchange);
}
}

View File

@ -0,0 +1,27 @@
package com.plannaplan.controllers;
import java.util.Map;
import com.plannaplan.App;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@CrossOrigin
@RequestMapping("/api/" + App.API_VERSION + "/exchanges")
@Api(tags = { "Exchange" }, value = "Exchange", description = "Endpoint to exchange with accepted assignments.")
public class ExchangeController {
@PostMapping("/exchange")
@ApiOperation(value = "Return all courses")
public ResponseEntity<String> createExchange(@RequestBody Map<String, Object> exchangeRequest){
return null;
}
}