Commit a363227b authored by Sumaiyya Burney's avatar Sumaiyya Burney

Adds get all promos endpt

parent 3f0fbb6d
...@@ -20,9 +20,9 @@ public class PromotionsController { ...@@ -20,9 +20,9 @@ public class PromotionsController {
PromotionService promotionService; PromotionService promotionService;
@GetMapping() @GetMapping()
public Flux<ResponseEntity<PromotionDto>> getAllPromotions(@RequestParam(required = false) String itemSku){ public ResponseEntity<Flux<PromotionDto>> getAllPromotions(@RequestParam(required = false) String itemSku){
//TODO: get all promos OR promos by item SKU //TODO: test once we have real data
return null; return ResponseEntity.ok(promotionService.findAll());
} }
@GetMapping("/{id}") @GetMapping("/{id}")
......
package com.nisum.ascend.promotions.service; package com.nisum.ascend.promotions.service;
import com.nisum.ascend.promotions.dto.PromotionDto;
import com.nisum.ascend.promotions.repository.PromotionRepository; import com.nisum.ascend.promotions.repository.PromotionRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
@Service @Service
public class PromotionService { public class PromotionService {
@Autowired @Autowired
PromotionRepository promotionRepository; 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