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