springadmin
This commit is contained in:
parent
bfe9b749a5
commit
a145487b1d
8 changed files with 233 additions and 145 deletions
|
|
@ -7,6 +7,8 @@ import com.mproduits.web.exceptions.ProductNotFoundException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
|
@ -16,7 +18,7 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
public class ProductController {
|
||||
public class ProductController implements HealthIndicator {
|
||||
|
||||
@Autowired
|
||||
ProductDao productDao;
|
||||
|
|
@ -27,6 +29,17 @@ public class ProductController {
|
|||
@Autowired
|
||||
ApplicationPropertiesConfiguration appProperties;
|
||||
|
||||
@Override
|
||||
public Health health() {
|
||||
|
||||
List<Product> products = productDao.findAll();
|
||||
|
||||
if(products.isEmpty()) {
|
||||
return Health.down().build();
|
||||
}
|
||||
return Health.up().build();
|
||||
}
|
||||
|
||||
// Affiche la liste de tous les produits disponibles
|
||||
@GetMapping(value = "/Produits")
|
||||
public List<Product> listeDesProduits(){
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
spring.application.name=microservice-produits
|
||||
|
||||
management.endpoints.web.exposure.include=health,info,metrics
|
||||
|
||||
info.app.version=1.0-Beta
|
||||
|
||||
spring.cloud.config.uri=http://localhost:9101
|
||||
Loading…
Add table
Add a link
Reference in a new issue