|
1
|
|
|
package com.osomapps.pt.admin.goal; |
|
2
|
|
|
|
|
3
|
|
|
import java.util.List; |
|
4
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
5
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping; |
|
6
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
7
|
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
8
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
9
|
|
|
import org.springframework.web.bind.annotation.PutMapping; |
|
10
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
11
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
12
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
13
|
|
|
|
|
14
|
|
|
@RestController |
|
15
|
|
|
@RequestMapping("api/v1/admin/goal") |
|
16
|
|
|
class AdminGoalResource { |
|
17
|
|
|
|
|
18
|
|
|
private final AdminGoalService adminGoalService; |
|
19
|
|
|
|
|
20
|
|
|
@Autowired |
|
21
|
|
|
AdminGoalResource(AdminGoalService adminGoalService) { |
|
22
|
|
|
this.adminGoalService = adminGoalService; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
@GetMapping |
|
26
|
|
|
List<GoalResponseDTO> findAll() { |
|
27
|
|
|
return adminGoalService.findAll(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
@GetMapping("{id}") |
|
31
|
|
|
GoalResponseDTO findOne(@PathVariable Long id) { |
|
32
|
|
|
return adminGoalService.findOne(id); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
@PostMapping |
|
36
|
|
|
GoalResponseDTO create(@RequestBody GoalRequestDTO ptUserRequestDTO) { |
|
37
|
|
|
return adminGoalService.create(ptUserRequestDTO); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
@PutMapping("{id}") |
|
41
|
|
|
GoalResponseDTO update(@PathVariable Long id, @RequestBody GoalRequestDTO ptUserRequestDTO) { |
|
42
|
|
|
return adminGoalService.update(id, ptUserRequestDTO); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
@DeleteMapping("{id}") |
|
46
|
|
|
GoalResponseDTO delete(@PathVariable Long id) { |
|
47
|
|
|
return adminGoalService.delete(id); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|