|
1
|
|
|
package easytests.api.v1.controllers; |
|
2
|
|
|
|
|
3
|
|
|
import easytests.api.v1.mappers.SubjectsMapper; |
|
4
|
|
|
import easytests.api.v1.models.Subject; |
|
5
|
|
|
import easytests.core.models.SubjectModelInterface; |
|
6
|
|
|
import easytests.core.models.empty.UserModelEmpty; |
|
7
|
|
|
import easytests.core.options.builder.SubjectsOptionsBuilderInterface; |
|
8
|
|
|
import easytests.core.services.SubjectsServiceInterface; |
|
9
|
|
|
import java.util.List; |
|
10
|
|
|
import java.util.stream.Collectors; |
|
11
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
12
|
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
13
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
14
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
15
|
|
|
import org.springframework.web.bind.annotation.*; |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @author VeronikaRevjakina |
|
20
|
|
|
*/ |
|
21
|
|
|
@RestController("SubjectsControllerV1") |
|
22
|
|
|
@SuppressWarnings("checkstyle:MultipleStringLiterals") |
|
23
|
|
|
@RequestMapping("/v1/subjects") |
|
24
|
|
|
public class SubjectsController { |
|
25
|
|
|
|
|
26
|
|
|
@Autowired |
|
27
|
|
|
protected SubjectsServiceInterface subjectsService; |
|
28
|
|
|
|
|
29
|
|
|
@Autowired |
|
30
|
|
|
private SubjectsOptionsBuilderInterface subjectsOptionsBuilder; |
|
31
|
|
|
|
|
32
|
|
|
@Autowired |
|
33
|
|
|
@Qualifier("SubjectsMapperV1") |
|
34
|
|
|
private SubjectsMapper subjectsMapper; |
|
35
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
@GetMapping("") |
|
38
|
|
|
public List<Subject> list(@RequestParam(name = "userId", required = true) Integer userId) { |
|
39
|
|
|
final List<SubjectModelInterface> subjectsModels = this.subjectsService.findByUser(new UserModelEmpty(userId)); |
|
40
|
|
|
|
|
41
|
|
|
//todo: ACL |
|
42
|
|
|
|
|
43
|
|
|
return subjectsModels |
|
44
|
|
|
.stream() |
|
45
|
|
|
.map(model -> this.subjectsMapper.map(model, Subject.class)) |
|
46
|
|
|
.collect(Collectors.toList()); |
|
47
|
|
|
} |
|
48
|
|
|
/** |
|
49
|
|
|
* create |
|
50
|
|
|
*/ |
|
51
|
|
|
/** |
|
52
|
|
|
* update |
|
53
|
|
|
*/ |
|
54
|
|
|
/** |
|
55
|
|
|
* show(subjectId) |
|
56
|
|
|
*/ |
|
57
|
|
|
/** |
|
58
|
|
|
* delete(subjectId) |
|
59
|
|
|
*/ |
|
60
|
|
|
} |
|
61
|
|
|
|