Commit a363227b authored by Sumaiyya Burney's avatar Sumaiyya Burney

Adds get all promos endpt

parent 3f0fbb6d
......@@ -20,9 +20,9 @@ public class PromotionsController {
PromotionService promotionService;
@GetMapping()
public Flux<ResponseEntity<PromotionDto>> getAllPromotions(@RequestParam(required = false) String itemSku){
//TODO: get all promos OR promos by item SKU
return null;
public ResponseEntity<Flux<PromotionDto>> getAllPromotions(@RequestParam(required = false) String itemSku){
//TODO: test once we have real data
return ResponseEntity.ok(promotionService.findAll());
}
@GetMapping("/{id}")
......
package com.nisum.ascend.promotions.service;
import com.nisum.ascend.promotions.dto.PromotionDto;
import com.nisum.ascend.promotions.repository.PromotionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
@Service
public class PromotionService {
@Autowired
PromotionRepository promotionRepository;
public Flux<PromotionDto> findAll(){
return promotionRepository.findAll().map(PromotionDto::generateDtoFromPromotion);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment