Completed
Pull Request — dev (#331)
by
unknown
05:04
created

easytests.api.v1.controllers.TopicsController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A list(Integer) 0 11 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.models.empty.SubjectModelEmpty;
7
import easytests.core.options.builder.TopicsOptionsBuilderInterface;
8
import easytests.core.services.TopicsServiceInterface;
9
import org.springframework.beans.factory.annotation.Autowired;
10
import org.springframework.beans.factory.annotation.Qualifier;
11
import org.springframework.web.bind.annotation.GetMapping;
12
import org.springframework.web.bind.annotation.RequestMapping;
13
import org.springframework.web.bind.annotation.RequestParam;
14
import org.springframework.web.bind.annotation.RestController;
15
16
import java.util.ArrayList;
0 ignored issues
show
Unused Code introduced by
Remove this unused import 'java.util.ArrayList'.
Loading history...
17
import java.util.List;
18
import java.util.stream.Collectors;
19
20
/**
21
 * @author lelay
22
 */
23
@RestController("TopicsControllerV1")
24
@SuppressWarnings("checkstyle:MultipleStringLiterals")
25
@RequestMapping("/v1/topics")
26
public class TopicsController {
27
28
    @Autowired
29
    protected TopicsServiceInterface topicsService;
30
31
    @Autowired
32
    private TopicsOptionsBuilderInterface topicsOptions;
33
34
    @Autowired
35
    @Qualifier("TopicsMapperV1")
36
    private TopicsMapper topicsMapper;
37
38
    @GetMapping("")
39
    public List<Topic> list(@RequestParam(required = true) Integer subjectId) {
40
        final List<TopicModelInterface> topicsModels =
41
                this.topicsService.findBySubject(new SubjectModelEmpty(subjectId));
42
43
        //todo: ACL should be there
44
45
        return topicsModels
46
                .stream()
47
                .map(model -> this.topicsMapper.map(model, Topic.class))
48
                .collect(Collectors.toList());
49
    }
50
51
    /**
52
     * create
53
     */
54
    /**
55
     * update
56
     */
57
    /**
58
     * show(topicId)
59
     */
60
    /**
61
     * delete(topicId)
62
     */
63
}
64