Commit cf3f015f authored by Sumaiyya Burney's avatar Sumaiyya Burney

Merge branch 'AFP-65' into 'AFP-64'

# Conflicts:
#   src/main/java/com/nisum/ascend/promotions/controller/PromotionsController.java
parents a6e4dd25 680db9db
...@@ -21,8 +21,10 @@ public class PromotionsController { ...@@ -21,8 +21,10 @@ public class PromotionsController {
@GetMapping() @GetMapping()
public ResponseEntity<Flux<PromotionDto>> getAllPromotions(@RequestParam(required = false) String sku){ public ResponseEntity<Flux<PromotionDto>> getAllPromotions(@RequestParam(required = false) String sku){
//TODO: test once we have real data if (sku != null){
return ResponseEntity.ok(promotionService.findAll()); return ResponseEntity.ok(promotionService.findPromotionsByProductSku(sku));
}
else return ResponseEntity.ok(promotionService.findAll());
} }
@GetMapping("/{id}") @GetMapping("/{id}")
......
...@@ -4,7 +4,9 @@ package com.nisum.ascend.promotions.repository; ...@@ -4,7 +4,9 @@ package com.nisum.ascend.promotions.repository;
import com.nisum.ascend.promotions.model.Promotion; import com.nisum.ascend.promotions.model.Promotion;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository; import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
@Repository @Repository
public interface PromotionRepository extends ReactiveMongoRepository<Promotion, String> { public interface PromotionRepository extends ReactiveMongoRepository<Promotion, String> {
Flux<Promotion> findByProductSku(String sku);
} }
...@@ -15,4 +15,8 @@ public class PromotionService { ...@@ -15,4 +15,8 @@ public class PromotionService {
public Flux<PromotionDto> findAll(){ public Flux<PromotionDto> findAll(){
return promotionRepository.findAll().map(PromotionDto::generateDtoFromPromotion); return promotionRepository.findAll().map(PromotionDto::generateDtoFromPromotion);
} }
public Flux<PromotionDto> findPromotionsByProductSku(String sku){
return promotionRepository.findByProductSku(sku).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