diff --git a/kbazaar/src/main/java/com/kampus/kbazaar/promotion/PromotionController.java b/kbazaar/src/main/java/com/kampus/kbazaar/promotion/PromotionController.java index f5fade1..10a26ae 100644 --- a/kbazaar/src/main/java/com/kampus/kbazaar/promotion/PromotionController.java +++ b/kbazaar/src/main/java/com/kampus/kbazaar/promotion/PromotionController.java @@ -6,7 +6,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import java.util.List; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -14,13 +15,12 @@ @RestController @RequestMapping("/api/v1") -@ConditionalOnProperty( - value = "feature.toggle.promotion-api", - havingValue = "true", - matchIfMissing = true) public class PromotionController { private PromotionService promotionService; + @Value("${feature.toggle.promotion-api:true}") + private boolean promotionApi; + public PromotionController(PromotionService promotionService) { this.promotionService = promotionService; } @@ -43,8 +43,11 @@ public PromotionController(PromotionService promotionService) { mediaType = "application/json", schema = @Schema(implementation = NotFoundException.class))) @GetMapping("/promotions") - public List getAllPromotions() { - return promotionService.getAll(); + public ResponseEntity> getAllPromotions() { + if (!promotionApi) { + return ResponseEntity.notFound().build(); + } + return ResponseEntity.ok(promotionService.getAll()); } @ApiResponse(