Skip to content

Commit 3f9d356

Browse files
authored
Merge pull request #3 from gbzarelli/refactor
refactor(Interfaces): Interfaces
2 parents 9af5cf5 + 7bda559 commit 3f9d356

File tree

56 files changed

+758
-678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+758
-678
lines changed

src/main/java/br/com/beblue/musicstore/ServletInitializer.java

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,16 @@
11
package br.com.beblue.musicstore.controller;
22

3-
import br.com.beblue.musicstore.dto.DiscDTO;
3+
import br.com.beblue.musicstore.controller.dto.DiscDTO;
44
import br.com.beblue.musicstore.exception.NoValuePresentException;
5-
import br.com.beblue.musicstore.service.DiscService;
6-
import org.springframework.beans.factory.annotation.Autowired;
75
import org.springframework.data.domain.Page;
86
import org.springframework.data.domain.Pageable;
9-
import org.springframework.http.MediaType;
10-
import org.springframework.web.bind.annotation.GetMapping;
11-
import org.springframework.web.bind.annotation.PathVariable;
12-
import org.springframework.web.bind.annotation.RequestMapping;
13-
import org.springframework.web.bind.annotation.RestController;
147

15-
import static br.com.beblue.musicstore.controller.DiscController.ROOT_PATH;
8+
public interface DiscController {
169

17-
@RestController
18-
@RequestMapping(ROOT_PATH)
19-
public class DiscController {
10+
Page<DiscDTO> listDiscsByGenre(String genre, Pageable pageable);
2011

21-
static final String ROOT_PATH = "/disc";
22-
static final String PATH_BY_GENRE = "/genre/{genre}";
23-
static final String PATH_BY_ID = "/{id}";
12+
Page<DiscDTO> listDiscs(Pageable pageable);
2413

25-
private final DiscService discService;
26-
27-
@Autowired
28-
public DiscController(DiscService discService) {
29-
this.discService = discService;
30-
}
31-
32-
@GetMapping(value = PATH_BY_GENRE, produces = MediaType.APPLICATION_JSON_VALUE)
33-
public Page<DiscDTO> list(@PathVariable String genre, Pageable pageable) {
34-
return discService.getDiscs(genre, pageable);
35-
}
36-
37-
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
38-
public Page<DiscDTO> list(Pageable pageable) {
39-
return discService.getDiscs(pageable);
40-
}
41-
42-
@GetMapping(value = PATH_BY_ID, produces = MediaType.APPLICATION_JSON_VALUE)
43-
public DiscDTO get(@PathVariable int id) throws NoValuePresentException {
44-
return discService.getDisc(id);
45-
}
14+
DiscDTO getDiscByID(Integer id) throws NoValuePresentException;
4615

4716
}
Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,9 @@
11
package br.com.beblue.musicstore.controller;
22

3-
import br.com.beblue.musicstore.dto.GenreDTO;
4-
import br.com.beblue.musicstore.service.GenreService;
5-
import org.springframework.beans.factory.annotation.Autowired;
6-
import org.springframework.http.MediaType;
7-
import org.springframework.web.bind.annotation.GetMapping;
8-
import org.springframework.web.bind.annotation.RequestMapping;
9-
import org.springframework.web.bind.annotation.RestController;
3+
import br.com.beblue.musicstore.controller.dto.GenreDTO;
104

115
import java.util.List;
126

13-
import static br.com.beblue.musicstore.controller.GenreController.ROOT_PATH;
14-
15-
@RestController
16-
@RequestMapping(ROOT_PATH)
17-
public class GenreController {
18-
static final String ROOT_PATH = "/genre";
19-
20-
private final GenreService genreService;
21-
22-
@Autowired
23-
public GenreController(GenreService genreService) {
24-
this.genreService = genreService;
25-
}
26-
27-
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
28-
public List<GenreDTO> getAll() {
29-
return genreService.getAllGenres();
30-
}
31-
7+
public interface GenreController {
8+
List<GenreDTO> getAllGenres();
329
}

src/main/java/br/com/beblue/musicstore/controller/HomeController.java

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,19 @@
11
package br.com.beblue.musicstore.controller;
22

3-
import br.com.beblue.musicstore.dto.SaleRequestDTO;
4-
import br.com.beblue.musicstore.dto.SaleResponseDTO;
3+
import br.com.beblue.musicstore.controller.dto.SaleRequestDTO;
4+
import br.com.beblue.musicstore.controller.dto.SaleResponseDTO;
55
import br.com.beblue.musicstore.exception.IllegalDateException;
66
import br.com.beblue.musicstore.exception.NoValuePresentException;
7-
import br.com.beblue.musicstore.service.SaleSearchService;
8-
import br.com.beblue.musicstore.service.SaleService;
9-
import org.springframework.beans.factory.annotation.Autowired;
107
import org.springframework.data.domain.Page;
118
import org.springframework.data.domain.Pageable;
12-
import org.springframework.format.annotation.DateTimeFormat;
13-
import org.springframework.web.bind.annotation.*;
149

1510
import java.time.LocalDate;
1611

17-
import static br.com.beblue.musicstore.controller.SaleController.ROOT_PATH;
12+
public interface SaleController {
1813

19-
@RestController
20-
@RequestMapping(ROOT_PATH)
21-
public class SaleController {
22-
static final String ROOT_PATH = "/sale";
23-
static final String PATH_BY_ORDER_NUMBER = "/{orderNumber}";
24-
static final String PATH_BY_DATE = "/start_date/{startDate}/end_date/{endDate}";
14+
SaleResponseDTO registerOrder(SaleRequestDTO request) throws NoValuePresentException;
2515

26-
private final SaleService saleService;
27-
private final SaleSearchService saleSearchService;
16+
SaleResponseDTO getOrderByOrderNumber(String orderNumber) throws NoValuePresentException;
2817

29-
@Autowired
30-
public SaleController(SaleService saleService, SaleSearchService saleSearchService) {
31-
this.saleService = saleService;
32-
this.saleSearchService = saleSearchService;
33-
}
34-
35-
@PostMapping()
36-
public SaleResponseDTO postOrder(@RequestBody SaleRequestDTO request) throws NoValuePresentException {
37-
return saleService.registerOrder(request);
38-
}
39-
40-
@GetMapping(value = PATH_BY_ORDER_NUMBER)
41-
public SaleResponseDTO getOrder(@PathVariable String orderNumber) throws NoValuePresentException {
42-
return saleSearchService.getOrderByNumber(orderNumber);
43-
}
44-
45-
@GetMapping(value = PATH_BY_DATE)
46-
public Page<SaleResponseDTO> getOrders(
47-
@PathVariable
48-
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
49-
LocalDate startDate,
50-
@PathVariable
51-
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
52-
LocalDate endDate,
53-
Pageable pageable) throws IllegalDateException {
54-
return saleSearchService.getOrdersByDate(startDate, endDate, pageable);
55-
}
18+
Page<SaleResponseDTO> getOrdersByDateFilter(LocalDate startDate, LocalDate endDate, Pageable pageable) throws IllegalDateException;
5619
}

src/main/java/br/com/beblue/musicstore/dto/DiscDTO.java renamed to src/main/java/br/com/beblue/musicstore/controller/dto/DiscDTO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package br.com.beblue.musicstore.dto;
1+
package br.com.beblue.musicstore.controller.dto;
22

33
public class DiscDTO {
44

src/main/java/br/com/beblue/musicstore/dto/GenreDTO.java renamed to src/main/java/br/com/beblue/musicstore/controller/dto/GenreDTO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package br.com.beblue.musicstore.dto;
1+
package br.com.beblue.musicstore.controller.dto;
22

33
public class GenreDTO {
44
private int id;

src/main/java/br/com/beblue/musicstore/dto/HttpResponseException.java renamed to src/main/java/br/com/beblue/musicstore/controller/dto/HttpResponseException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package br.com.beblue.musicstore.dto;
1+
package br.com.beblue.musicstore.controller.dto;
22

33
import java.util.ArrayList;
44
import java.util.Date;

src/main/java/br/com/beblue/musicstore/dto/SaleRequestDTO.java renamed to src/main/java/br/com/beblue/musicstore/controller/dto/SaleRequestDTO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package br.com.beblue.musicstore.dto;
1+
package br.com.beblue.musicstore.controller.dto;
22

33
import javax.validation.constraints.Min;
44
import java.util.List;

src/main/java/br/com/beblue/musicstore/dto/SaleResponseDTO.java renamed to src/main/java/br/com/beblue/musicstore/controller/dto/SaleResponseDTO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package br.com.beblue.musicstore.dto;
1+
package br.com.beblue.musicstore.controller.dto;
22

33
import java.util.List;
44

0 commit comments

Comments
 (0)