com.osomapps.pt.reportphoto.ReportPhotoResource   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A findAll(String) 0 3 1
A create(String,PhotoRequestDTO) 0 5 1
A ReportPhotoResource(ReportPhotoService) 0 3 1
1
package com.osomapps.pt.reportphoto;
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-photo")
14
class ReportPhotoResource {
15
16
    private final ReportPhotoService reportPhotoService;
17
18
    @Autowired
19
    ReportPhotoResource(ReportPhotoService reportPhotoService) {
20
        this.reportPhotoService = reportPhotoService;
21
    }
22
23
    @GetMapping
24
    List<PhotoResponseDTO> findAll(@RequestHeader(value = "X-Token") String token) {
25
        return reportPhotoService.findAll(token);
26
    }
27
28
    @PostMapping
29
    PhotoResponseDTO create(
30
            @RequestHeader(value = "X-Token") String token,
31
            @RequestBody PhotoRequestDTO weightRequestDTO) {
32
        return reportPhotoService.create(token, weightRequestDTO);
33
    }
34
}
35