Passed
Pull Request — dev (#331)
by
unknown
06:06
created

list(Integer)   A

Complexity

Conditions 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 11
rs 9.85
c 0
b 0
f 0
1
package easytests.api.v1.controllers;
2
3
import easytests.api.v1.mappers.TopicsMapper;
4
import easytests.api.v1.models.Topic;
5
import easytests.core.models.TopicModelInterface;
6
import easytests.core.models.empty.SubjectModelEmpty;
7
import easytests.core.options.builder.TopicsOptionsBuilderInterface;
8
import easytests.core.services.TopicsServiceInterface;
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.RequestMapping;
15
import org.springframework.web.bind.annotation.RequestParam;
16
import org.springframework.web.bind.annotation.RestController;
17
18
/**
19
 * @author lelay
20
 */
21
@RestController("TopicsControllerV1")
22
@SuppressWarnings("checkstyle:MultipleStringLiterals")
23
@RequestMapping("/v1/topics")
24
public class TopicsController {
25
26
    @Autowired
27
    protected TopicsServiceInterface topicsService;
28
29
    @Autowired
30
    private TopicsOptionsBuilderInterface topicsOptionsBuilder;
31
32
    @Autowired
33
    @Qualifier("TopicsMapperV1")
34
    private TopicsMapper topicsMapper;
35
36
    @GetMapping("")
37
    public List<Topic> list(@RequestParam(name = "subjectId", required = true) Integer subjectId) {
38
        final List<TopicModelInterface> topicsModels =
39
                this.topicsService.findBySubject(new SubjectModelEmpty(subjectId));
40
41
        //todo: ACL should be there
42
43
        return topicsModels
44
                .stream()
45
                .map(model -> this.topicsMapper.map(model, Topic.class))
46
                .collect(Collectors.toList());
47
    }
48
49
    /**
50
     * create
51
     */
52
    /**
53
     * update
54
     */
55
    /**
56
     * show(topicId)
57
     */
58
    /**
59
     * delete(topicId)
60
     */
61
}
62