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

easytests.api.v1.controllers.TopicsController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 25
rs 10
c 2
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A list(Integer) 0 10 1
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.options.builder.TopicsOptionsBuilderInterface;
7
import easytests.core.services.TopicsServiceInterface;
8
import org.springframework.beans.factory.annotation.Autowired;
9
import org.springframework.beans.factory.annotation.Qualifier;
10
import org.springframework.web.bind.annotation.GetMapping;
11
import org.springframework.web.bind.annotation.RequestMapping;
12
import org.springframework.web.bind.annotation.RequestParam;
13
import org.springframework.web.bind.annotation.RestController;
14
15
import java.util.List;
16
import java.util.stream.Collectors;
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 topicsOptions;
31
32
    @Autowired
33
    @Qualifier("TopicsMapperV1")
34
    private TopicsMapper topicsMapper;
35
36
    @GetMapping("")
37
    public List<Topic> list(@RequestParam(required = true) Integer subjectId) {
38
        final List<TopicModelInterface> topicsModels = this.topicsService.findBySubject(subjectId);
39
40
        //todo: ACL should be there
41
42
        return topicsModels
43
                .stream()
44
                .map(model -> this.topicsMapper.map(model, Topic.class))
45
                .collect(Collectors.toList());
46
    }
47
48
    /**
49
     * create
50
     */
51
    /**
52
     * update
53
     */
54
    /**
55
     * show(topicId)
56
     */
57
    /**
58
     * delete(topicId)
59
     */
60
}
61