com.osomapps.pt.reportweight.ReportWeightResource   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 14
dl 0
loc 21
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create(String,WeightRequestDTO) 0 5 1
A ReportWeightResource(ReportWeightService) 0 3 1
A findAll(String) 0 3 1
1
package com.osomapps.pt.reportweight;
2
3
import java.util.List;
4
import org.springframework.beans.factory.annotation.Autowired;
5
import org.springframework.web.bind.annotation.GetMapping;
6
import org.springframework.web.bind.annotation.PostMapping;
7
import org.springframework.web.bind.annotation.RequestBody;
8
import org.springframework.web.bind.annotation.RequestHeader;
9
import org.springframework.web.bind.annotation.RequestMapping;
10
import org.springframework.web.bind.annotation.RestController;
11
12
@RestController
13
@RequestMapping("api/v1/report-weight")
14
class ReportWeightResource {
15
16
    private final ReportWeightService reportWeightService;
17
18
    @Autowired
19
    ReportWeightResource(ReportWeightService reportWeightService) {
20
        this.reportWeightService = reportWeightService;
21
    }
22
23
    @GetMapping
24
    List<WeightResponseDTO> findAll(@RequestHeader(value = "X-Token") String token) {
25
        return reportWeightService.findAll(token);
26
    }
27
28
    @PostMapping
29
    WeightResponseDTO create(
30
            @RequestHeader(value = "X-Token") String token,
31
            @RequestBody WeightRequestDTO weightRequestDTO) {
32
        return reportWeightService.create(token, weightRequestDTO);
33
    }
34
}
35