src/Controller/admin/AdminApi.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Controller\admin;
  3. use App\Service\admin\AdminService;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. class AdminApi extends AbstractController{
  9.     
  10.     private $adminService;
  11.     public function __construct(AdminService $adminService){
  12.           
  13.          $this->adminService=$adminService;
  14.     }
  15.    
  16.     /**
  17.      * @Route("/admin/rowToValidate", name="row_validate", methods={"GET"})
  18.      * 
  19.      */
  20.     public function countRowTovalidate(){
  21.        $count=$this->adminService->countTotalRowToValidate();
  22.        $response= new Response($count,Response::HTTP_OK);
  23.        $response->headers->set('content-Type''application/json');
  24.        return $response;
  25.     }
  26.     /**
  27.      * @Route("/admin/rowValidatet", name="row_processed", methods={"GET"})
  28.      * 
  29.      */
  30.     public function countRowValidated(){
  31.         $count=$this->adminService->countTotalRowValidated();
  32.         $response= new Response($count,Response::HTTP_OK);
  33.         $response->headers->set('content-Type''application/json');
  34.         return $response;
  35.  
  36.      }
  37.    /**
  38.      * @Route("/admin/allUser", name="all_user", methods={"GET"})
  39.      * 
  40.      */
  41.      public function getAllUser(){
  42.       $res=new Response($this->adminService->getAllUser(),Response::HTTP_OK);
  43.       $res->headers->set('content-Type''application/json');
  44.       return $res;
  45.      }
  46.      /**
  47.       * @Route("/admin/getAllDep", name="get_all_dep", methods={"GET"})
  48.       */
  49.       public function getAllDep(){
  50.         $res=new Response($this->adminService->getAllDep(),Response::HTTP_OK);
  51.         $res->headers->set('content-Type''application/json');
  52.         return $res;
  53.       }
  54.       /**
  55.        * @Route("/admin/setDepLok", name="set_dep_Lock", methods={"POST"})
  56.        * 
  57.        */
  58.       public  function setDepLock(Request $request){
  59.         $dataRequest=$request->request->all();
  60.         $res=new Response($this->adminService->setLockDep($dataRequest['id'],$dataRequest['usrid']),Response::HTTP_OK);
  61.         $res->headers->set('content-Type''application/json');
  62.         return $res;
  63.       }
  64.       /**
  65.        * @Route("/admin/attribDepToUser", name="attrib_dep_user", methods={"POST"})
  66.        */
  67.       public function attribDepToUser(Request $request){
  68.         $dataRequest=$request->request->all();
  69.         $queryResponse=$this->adminService->attributeDepToUser(base64_decode($dataRequest['objt']),intval($dataRequest['id'],10));
  70.         $res=new Response($queryResponse,Response::HTTP_OK);
  71.         $res->headers->set('content-Type''application/json');
  72.         return $res;
  73.       }
  74.       /**
  75.       * @Route("/admin/updateUserDepAttrib", name="update_user_dep_attrib", methods={"POST"})
  76.       * 
  77.       */
  78.       public function updateUserDepAttrib(Request $request){
  79.         $dataRequest=$request->request->all();
  80.         $queryResponse=$this->adminService->updateDepUser(base64_decode($dataRequest['objt']),intval($dataRequest['id'],10));
  81.         $res=new Response($queryResponse,Response::HTTP_OK);
  82.         $res->headers->set('content-Type''application/json');
  83.         return $res;
  84.       }
  85.        
  86.      /**
  87.       * @Route("/admin/depWu", name="find_user_dep", methods={"GET"})
  88.       */
  89.       public function getUserById(){
  90.           $a=$this->adminService->getDepWithUSer();
  91.           $res=new Response($a,Response::HTTP_OK);
  92.           $res->headers->set('content-Type''application/json');
  93.           return $res;
  94.       }
  95.       /**
  96.        * @Route("/admin/supDepAttrib", name="suppr_dep_attrib", methods={"POST"})
  97.        */
  98.        public function unclokedDep(Request $request){
  99.            $dataRequest=$request->request->all();
  100.            $a=$this->adminService->unlockedDep($dataRequest['id']);
  101.            $res=new Response($a,Response::HTTP_OK);
  102.            $res->headers->set('content-Type''application/json');
  103.            return $res;
  104.        }
  105.        /**
  106.        * @Route("/admin/getUstAttribUsrInfo", name="get_usr_attrib_info", methods={"GET"})
  107.        */
  108.       public function getDepAttribAndUserInfo(Request $request){
  109.         $dataRequest=$request->query->get('id');
  110.         $a=$this->adminService->getDepAttribAndUserInfo($dataRequest);
  111.         $res=new Response($a,Response::HTTP_OK);
  112.         $res->headers->set('content-Type''application/json');
  113.          return $res;
  114.       }
  115.       /**
  116.        * @Route("/admin/deleteUser", name="delete_user", methods={"POST"})
  117.        */
  118.       public function deleteUser(Request $request){
  119.         $dataRequest=$request->request->all();
  120.         $a=$this->adminService->deleteUser($dataRequest["id"]);
  121.         $res=new Response($a,Response::HTTP_OK);
  122.         $res->headers->set('content-Type''application/json');
  123.         return $res;
  124.       }
  125.       /**
  126.        * @Route("/admin/deleteUserAttribute", name="delete_user_Attribute", methods={"POST"})
  127.        */
  128.       public function deleteUserAttribut(Request $request){
  129.         $dataRequest=$request->request->all();
  130.         $a=$this->adminService->deleteUserDepAttribute($dataRequest["id"]);
  131.         $res=new Response($a,Response::HTTP_OK);
  132.         $res->headers->set('content-Type''application/json');
  133.         return $res;
  134.       }
  135.       /**
  136.        * @Route("/admin/getUserByDep", name="delete_user_Attribute", methods={"POST"})
  137.        */
  138.       public function getUserByDep(Request $request){
  139.         $dataRequest=$request->request->all();
  140.         $a=$this->adminService->deleteUserDepAttribute($dataRequest["dep"]);
  141.         $res=new Response($a,Response::HTTP_OK);
  142.         $res->headers->set('content-Type''application/json');
  143.         return $res;
  144.       }
  145.       /**
  146.        * @Route("/admin/setAdminVerif", name="admin_verif", methods={"POST"})
  147.        */
  148.       public function setAdminVerif(Request $request){
  149.         $dataRequest=$request->request->all();
  150.         $a=$this->adminService->setAdminVerif($dataRequest["id"], $dataRequest["cdns"]);
  151.         $res=new Response($a,Response::HTTP_OK);
  152.         $res->headers->set('content-Type''application/json');
  153.         return $res;
  154.       }
  155.       /**
  156.       * @Route("/admin/undoAdminVerif", name="undo_admin_verif", methods={"POST"})
  157.       */
  158.       public function undoAdminVerif(Request $request){
  159.         $dataRequest=$request->request->all();
  160.         $a=$this->adminService->undoAdminVerif($dataRequest["id"], $dataRequest["cdns"]);
  161.         $res=new Response($a,Response::HTTP_OK);
  162.         $res->headers->set('content-Type''application/json');
  163.         return $res;
  164.       }
  165.       /**
  166.         *@Route("/admin/see/Historique", name="voir_historique_admin_pol", methods={"POST"}) 
  167.         *
  168.         */
  169.         public function showHistorical(Request $request){
  170.          // $this->denyAccessUnlessGranted('ROLE_USER',null,'access denied');
  171.           $dep=$request->request->get("dep");
  172.           $response=new Response($this->agentService->showHistorical($dep));
  173.           $response->headers->set('content-Type''application/json'); 
  174.           return $response;
  175.       }
  176. }