-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from gbzarelli/refactor
refactor(Interfaces): Interfaces
- Loading branch information
Showing
56 changed files
with
758 additions
and
678 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
src/main/java/br/com/beblue/musicstore/ServletInitializer.java
This file was deleted.
Oops, something went wrong.
41 changes: 5 additions & 36 deletions
41
src/main/java/br/com/beblue/musicstore/controller/DiscController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,16 @@ | ||
package br.com.beblue.musicstore.controller; | ||
|
||
import br.com.beblue.musicstore.dto.DiscDTO; | ||
import br.com.beblue.musicstore.controller.dto.DiscDTO; | ||
import br.com.beblue.musicstore.exception.NoValuePresentException; | ||
import br.com.beblue.musicstore.service.DiscService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import static br.com.beblue.musicstore.controller.DiscController.ROOT_PATH; | ||
public interface DiscController { | ||
|
||
@RestController | ||
@RequestMapping(ROOT_PATH) | ||
public class DiscController { | ||
Page<DiscDTO> listDiscsByGenre(String genre, Pageable pageable); | ||
|
||
static final String ROOT_PATH = "/disc"; | ||
static final String PATH_BY_GENRE = "/genre/{genre}"; | ||
static final String PATH_BY_ID = "/{id}"; | ||
Page<DiscDTO> listDiscs(Pageable pageable); | ||
|
||
private final DiscService discService; | ||
|
||
@Autowired | ||
public DiscController(DiscService discService) { | ||
this.discService = discService; | ||
} | ||
|
||
@GetMapping(value = PATH_BY_GENRE, produces = MediaType.APPLICATION_JSON_VALUE) | ||
public Page<DiscDTO> list(@PathVariable String genre, Pageable pageable) { | ||
return discService.getDiscs(genre, pageable); | ||
} | ||
|
||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) | ||
public Page<DiscDTO> list(Pageable pageable) { | ||
return discService.getDiscs(pageable); | ||
} | ||
|
||
@GetMapping(value = PATH_BY_ID, produces = MediaType.APPLICATION_JSON_VALUE) | ||
public DiscDTO get(@PathVariable int id) throws NoValuePresentException { | ||
return discService.getDisc(id); | ||
} | ||
DiscDTO getDiscByID(Integer id) throws NoValuePresentException; | ||
|
||
} |
29 changes: 3 additions & 26 deletions
29
src/main/java/br/com/beblue/musicstore/controller/GenreController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,9 @@ | ||
package br.com.beblue.musicstore.controller; | ||
|
||
import br.com.beblue.musicstore.dto.GenreDTO; | ||
import br.com.beblue.musicstore.service.GenreService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import br.com.beblue.musicstore.controller.dto.GenreDTO; | ||
|
||
import java.util.List; | ||
|
||
import static br.com.beblue.musicstore.controller.GenreController.ROOT_PATH; | ||
|
||
@RestController | ||
@RequestMapping(ROOT_PATH) | ||
public class GenreController { | ||
static final String ROOT_PATH = "/genre"; | ||
|
||
private final GenreService genreService; | ||
|
||
@Autowired | ||
public GenreController(GenreService genreService) { | ||
this.genreService = genreService; | ||
} | ||
|
||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) | ||
public List<GenreDTO> getAll() { | ||
return genreService.getAllGenres(); | ||
} | ||
|
||
public interface GenreController { | ||
List<GenreDTO> getAllGenres(); | ||
} |
24 changes: 0 additions & 24 deletions
24
src/main/java/br/com/beblue/musicstore/controller/HomeController.java
This file was deleted.
Oops, something went wrong.
49 changes: 6 additions & 43 deletions
49
src/main/java/br/com/beblue/musicstore/controller/SaleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,19 @@ | ||
package br.com.beblue.musicstore.controller; | ||
|
||
import br.com.beblue.musicstore.dto.SaleRequestDTO; | ||
import br.com.beblue.musicstore.dto.SaleResponseDTO; | ||
import br.com.beblue.musicstore.controller.dto.SaleRequestDTO; | ||
import br.com.beblue.musicstore.controller.dto.SaleResponseDTO; | ||
import br.com.beblue.musicstore.exception.IllegalDateException; | ||
import br.com.beblue.musicstore.exception.NoValuePresentException; | ||
import br.com.beblue.musicstore.service.SaleSearchService; | ||
import br.com.beblue.musicstore.service.SaleService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.format.annotation.DateTimeFormat; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.time.LocalDate; | ||
|
||
import static br.com.beblue.musicstore.controller.SaleController.ROOT_PATH; | ||
public interface SaleController { | ||
|
||
@RestController | ||
@RequestMapping(ROOT_PATH) | ||
public class SaleController { | ||
static final String ROOT_PATH = "/sale"; | ||
static final String PATH_BY_ORDER_NUMBER = "/{orderNumber}"; | ||
static final String PATH_BY_DATE = "/start_date/{startDate}/end_date/{endDate}"; | ||
SaleResponseDTO registerOrder(SaleRequestDTO request) throws NoValuePresentException; | ||
|
||
private final SaleService saleService; | ||
private final SaleSearchService saleSearchService; | ||
SaleResponseDTO getOrderByOrderNumber(String orderNumber) throws NoValuePresentException; | ||
|
||
@Autowired | ||
public SaleController(SaleService saleService, SaleSearchService saleSearchService) { | ||
this.saleService = saleService; | ||
this.saleSearchService = saleSearchService; | ||
} | ||
|
||
@PostMapping() | ||
public SaleResponseDTO postOrder(@RequestBody SaleRequestDTO request) throws NoValuePresentException { | ||
return saleService.registerOrder(request); | ||
} | ||
|
||
@GetMapping(value = PATH_BY_ORDER_NUMBER) | ||
public SaleResponseDTO getOrder(@PathVariable String orderNumber) throws NoValuePresentException { | ||
return saleSearchService.getOrderByNumber(orderNumber); | ||
} | ||
|
||
@GetMapping(value = PATH_BY_DATE) | ||
public Page<SaleResponseDTO> getOrders( | ||
@PathVariable | ||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) | ||
LocalDate startDate, | ||
@PathVariable | ||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) | ||
LocalDate endDate, | ||
Pageable pageable) throws IllegalDateException { | ||
return saleSearchService.getOrdersByDate(startDate, endDate, pageable); | ||
} | ||
Page<SaleResponseDTO> getOrdersByDateFilter(LocalDate startDate, LocalDate endDate, Pageable pageable) throws IllegalDateException; | ||
} |
2 changes: 1 addition & 1 deletion
2
...br/com/beblue/musicstore/dto/DiscDTO.java → ...ue/musicstore/controller/dto/DiscDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package br.com.beblue.musicstore.dto; | ||
package br.com.beblue.musicstore.controller.dto; | ||
|
||
public class DiscDTO { | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...r/com/beblue/musicstore/dto/GenreDTO.java → ...e/musicstore/controller/dto/GenreDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...musicstore/dto/HttpResponseException.java → ...controller/dto/HttpResponseException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...beblue/musicstore/dto/SaleRequestDTO.java → ...cstore/controller/dto/SaleRequestDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...eblue/musicstore/dto/SaleResponseDTO.java → ...store/controller/dto/SaleResponseDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package br.com.beblue.musicstore.dto; | ||
package br.com.beblue.musicstore.controller.dto; | ||
|
||
import java.util.List; | ||
|
||
|
47 changes: 47 additions & 0 deletions
47
src/main/java/br/com/beblue/musicstore/controller/rest/DiscRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package br.com.beblue.musicstore.controller.rest; | ||
|
||
import br.com.beblue.musicstore.controller.DiscController; | ||
import br.com.beblue.musicstore.controller.dto.DiscDTO; | ||
import br.com.beblue.musicstore.exception.NoValuePresentException; | ||
import br.com.beblue.musicstore.service.DiscService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
|
||
@RestController | ||
@RequestMapping(DiscRestController.ROOT_PATH) | ||
class DiscRestController implements DiscController { | ||
|
||
static final String ROOT_PATH = "/disc"; | ||
static final String PATH_BY_GENRE = "/genre/{genre}"; | ||
static final String PATH_BY_ID = "/{id}"; | ||
|
||
private final DiscService discService; | ||
|
||
@Autowired | ||
DiscRestController(final DiscService discService) { | ||
this.discService = discService; | ||
} | ||
|
||
@GetMapping(value = PATH_BY_GENRE, produces = MediaType.APPLICATION_JSON_VALUE) | ||
public Page<DiscDTO> listDiscsByGenre(@PathVariable String genre, Pageable pageable) { | ||
return discService.getDiscsByGenre(genre, pageable); | ||
} | ||
|
||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) | ||
public Page<DiscDTO> listDiscs(Pageable pageable) { | ||
return discService.getDiscs(pageable); | ||
} | ||
|
||
@GetMapping(value = PATH_BY_ID, produces = MediaType.APPLICATION_JSON_VALUE) | ||
public DiscDTO getDiscByID(@PathVariable Integer id) throws NoValuePresentException { | ||
return discService.getDiscByID(id); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/br/com/beblue/musicstore/controller/rest/GenreRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package br.com.beblue.musicstore.controller.rest; | ||
|
||
import br.com.beblue.musicstore.controller.GenreController; | ||
import br.com.beblue.musicstore.controller.dto.GenreDTO; | ||
import br.com.beblue.musicstore.service.GenreService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping(GenreRestController.ROOT_PATH) | ||
class GenreRestController implements GenreController { | ||
|
||
static final String ROOT_PATH = "/genre"; | ||
|
||
private final GenreService genreService; | ||
|
||
@Autowired | ||
GenreRestController(final GenreService genreService) { | ||
this.genreService = genreService; | ||
} | ||
|
||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) | ||
public List<GenreDTO> getAllGenres() { | ||
return genreService.getAllGenres(); | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/br/com/beblue/musicstore/controller/rest/SaleRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package br.com.beblue.musicstore.controller.rest; | ||
|
||
import br.com.beblue.musicstore.controller.SaleController; | ||
import br.com.beblue.musicstore.controller.dto.SaleRequestDTO; | ||
import br.com.beblue.musicstore.controller.dto.SaleResponseDTO; | ||
import br.com.beblue.musicstore.exception.IllegalDateException; | ||
import br.com.beblue.musicstore.exception.NoValuePresentException; | ||
import br.com.beblue.musicstore.service.SaleSearchService; | ||
import br.com.beblue.musicstore.service.SaleService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.format.annotation.DateTimeFormat; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.time.LocalDate; | ||
|
||
@RestController | ||
@RequestMapping(SaleRestController.ROOT_PATH) | ||
class SaleRestController implements SaleController { | ||
|
||
static final String ROOT_PATH = "/sale"; | ||
static final String PATH_BY_ORDER_NUMBER = "/{orderNumber}"; | ||
static final String PATH_BY_DATE = "/start_date/{startDate}/end_date/{endDate}"; | ||
|
||
private final SaleService saleService; | ||
private final SaleSearchService saleSearchService; | ||
|
||
@Autowired | ||
SaleRestController(final SaleService saleService, final SaleSearchService saleSearchService) { | ||
this.saleService = saleService; | ||
this.saleSearchService = saleSearchService; | ||
} | ||
|
||
@PostMapping() | ||
public SaleResponseDTO registerOrder(@RequestBody SaleRequestDTO request) throws NoValuePresentException { | ||
return saleService.registerOrder(request); | ||
} | ||
|
||
@GetMapping(value = PATH_BY_ORDER_NUMBER) | ||
public SaleResponseDTO getOrderByOrderNumber(@PathVariable String orderNumber) throws NoValuePresentException { | ||
return saleSearchService.getOrderByNumber(orderNumber); | ||
} | ||
|
||
@GetMapping(value = PATH_BY_DATE) | ||
public Page<SaleResponseDTO> getOrdersByDateFilter( | ||
@PathVariable | ||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) | ||
LocalDate startDate, | ||
@PathVariable | ||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) | ||
LocalDate endDate, | ||
Pageable pageable) throws IllegalDateException { | ||
return saleSearchService.getOrdersByDate(startDate, endDate, pageable); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/br/com/beblue/musicstore/events/SaleNotifiable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package br.com.beblue.musicstore.events; | ||
|
||
import org.springframework.amqp.AmqpException; | ||
|
||
public interface SaleNotifiable { | ||
void notifyNewOrder(String order) throws AmqpException; | ||
} |
Oops, something went wrong.