blob: c99a95ba7c5307c35e72c39f382aec356b37b7f7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package com.ufund.api.ufundapi.controller;
import com.ufund.api.ufundapi.model.Cupboard;
import com.ufund.api.ufundapi.model.Need;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@RestController
@RequestMapping("cupboard")
public class CupboardController {
private ArrayList<Need> needs;
private Cupboard cupboard;
@PostMapping("")
public void createNeed(@RequestBody Need need) {;
cupboard.createNeed(need);
}
@GetMapping("")
public Need[] getNeeds() {
return cupboard.getNeeds();
}
@GetMapping("/")
public Need searchNeeds(@RequestParam String name) {
return cupboard.findNeeds(name);
}
@GetMapping("/{id}")
public Need getNeed(@PathVariable int id) {
return cupboard.getNeed(id);
}
@PutMapping("")
public void updateNeed(@RequestBody Need need) {
cupboard.updateNeed(need);
}
@DeleteMapping("/{id}")
public void deleteNeed(@PathVariable int id) {
cupboard.removeNeed(id);
}
}
|