|
1
|
|
|
package com.osomapps.pt.admin.program; |
|
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/program") |
|
16
|
|
|
class AdminProgramResource { |
|
17
|
|
|
|
|
18
|
|
|
private final AdminProgramService programService; |
|
19
|
|
|
|
|
20
|
|
|
@Autowired |
|
21
|
|
|
AdminProgramResource(AdminProgramService programService) { |
|
22
|
|
|
this.programService = programService; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
@GetMapping |
|
26
|
|
|
List<ProgramResponseDTO> findAll() { |
|
27
|
|
|
return programService.findAll(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
@GetMapping("{id}") |
|
31
|
|
|
ProgramResponseDTO findOne(@PathVariable Long id) { |
|
32
|
|
|
return programService.findOne(id); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
@PostMapping |
|
36
|
|
|
ProgramResponseDTO create(@RequestBody ProgramRequestDTO programRequestDTO) { |
|
37
|
|
|
return programService.create(programRequestDTO); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
@PutMapping("{id}") |
|
41
|
|
|
ProgramResponseDTO update( |
|
42
|
|
|
@PathVariable Long id, @RequestBody ProgramRequestDTO exerciseRequestDTO) { |
|
43
|
|
|
return programService.update(id, exerciseRequestDTO); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
@DeleteMapping("{id}") |
|
47
|
|
|
ProgramResponseDTO delete(@PathVariable Long id) { |
|
48
|
|
|
return programService.delete(id); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|