UtilisateurPromoteursController.java

  1. package com.sintia.ffl.admin.dentaire.api.controllers;

  2. import com.sintia.ffl.admin.dentaire.api.utils.RestUtils;
  3. import com.sintia.ffl.admin.dentaire.services.dto.UtilisateurPromoteurDTO;
  4. import com.sintia.ffl.admin.dentaire.services.services.UtilisateurPromoteurService;
  5. import com.sintia.ffl.adminui.commons.dto.PromoteurDTO;
  6. import io.swagger.v3.oas.annotations.Operation;
  7. import io.swagger.v3.oas.annotations.responses.ApiResponse;
  8. import lombok.RequiredArgsConstructor;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.http.ResponseEntity;
  12. import org.springframework.web.bind.annotation.GetMapping;
  13. import org.springframework.web.bind.annotation.PathVariable;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;

  16. import java.util.Collection;

  17. @RestController
  18. @RequestMapping("/api/v1/userpromoteurs")
  19. @Slf4j
  20. @RequiredArgsConstructor(onConstructor = @__ ({@Autowired }))
  21. public class UtilisateurPromoteursController {
  22.    
  23.     private final UtilisateurPromoteurService utilisateurPromoteurService;
  24.    
  25.     @GetMapping(value = "/utilisateur/{utilisateur}")
  26.     @Operation(
  27.             operationId = "getUtilisateurPromoteurs",
  28.             summary = "Retourne tous les promoteurs associés à un utilisateur donné",
  29.             description = "Retourne tous les promoteurs associés à un utilisateur donné",
  30.             responses = {
  31.                     @ApiResponse(responseCode = "200", description = "Traitement terminé normalement"),
  32.                     @ApiResponse(responseCode = "204", description = "Données non-trouvées"),
  33.                     @ApiResponse(responseCode = "400", description = "Données trop volumineuses") })
  34.     public ResponseEntity<Collection<PromoteurDTO>> getUtilisateurPromoteur(@PathVariable(name = "utilisateur") String utilisateur) {
  35.         log.debug("getPromoteursForUser");
  36.         return RestUtils.constructApiResponse(utilisateurPromoteurService.getPromoteursForUser(utilisateur));
  37.        
  38.     }
  39.    
  40.     @GetMapping(value = "/all")
  41.     @Operation(
  42.             operationId = "getUtilisateurPromoteurs",
  43.             summary = "Retourne tous les utilisateurs promoteurs",
  44.             description = "Retourne tous les utilisateurs promoteurs",
  45.             responses = {
  46.                     @ApiResponse(responseCode = "200", description = "Traitement terminé normalement"),
  47.                     @ApiResponse(responseCode = "204", description = "Données non-trouvées"),
  48.                     @ApiResponse(responseCode = "400", description = "Données trop volumineuses") })
  49.     public ResponseEntity<Collection<UtilisateurPromoteurDTO>> getUtilisateurPromoteur() {
  50.         log.debug("getPromoteursForUser");
  51.         return RestUtils.constructApiResponse(utilisateurPromoteurService.getUtilisateurs());
  52.        
  53.     }
  54. }