src/Controller/Api/v1/GroupApiController.php line 673

Open in your IDE?
  1. <?php
  2. namespace EADPlataforma\Controller\Api\v1;
  3. use OpenApi\Annotations as OA;
  4. use Nelmio\ApiDocBundle\Annotation\Model;
  5. use Nelmio\ApiDocBundle\Annotation\Security;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use EADPlataforma\Controller\Api\AbstractApiController;
  9. use EADPlataforma\Entity\User;
  10. use EADPlataforma\Entity\Course;
  11. use EADPlataforma\Entity\Group;
  12. use EADPlataforma\Entity\Enrollment;
  13. use EADPlataforma\Enum\GroupEnum;
  14. use EADPlataforma\Enum\CourseEnum;
  15. use EADPlataforma\Enum\TrashEnum;
  16. use EADPlataforma\Enum\UserLogEnum;
  17. use EADPlataforma\Enum\UserEnum;
  18. use EADPlataforma\Enum\UserPermissionEnum;
  19. use EADPlataforma\Enum\ErrorEnum;
  20. class GroupApiController extends AbstractApiController {
  21.     public function getEntityClass(){
  22.         return Group::class;
  23.     }
  24.     /**
  25.      * Listagem de grupos do EAD.
  26.      *
  27.      * @Route("/api/1/group", methods={"GET"})
  28.      * @OA\Response(
  29.      *     response=200,
  30.      *     description="Listagem de grupos do EAD.",
  31.      *     @OA\JsonContent(
  32.      *         type="object",
  33.      *         @OA\Property(property="grupo_id", type="integer", example=1, description="Id do grupo cadastrado no EAD."),
  34.      *         @OA\Property(property="grupo_nome", type="string", example="Grupo Nome", description="Nome do grupo cadastrado no EAD."),
  35.      *         @OA\Property(property="status", type="integer", example=0, description="Estado do grupo cadastrado no EAD(0-Liberado / 1-Bloqueado).")
  36.      *     )
  37.      * )
  38.      * 
  39.      * @OA\Response(
  40.      *     response=204,
  41.      *     description="No content"
  42.      * )
  43.      * 
  44.      * @OA\Response(
  45.      *     response=401,
  46.      *     description="Token not found",
  47.      *     @OA\JsonContent(
  48.      *         type="object",
  49.      *         @OA\Property(property="http_status", type="integer", example=401, description="Token not found"),
  50.      *         @OA\Property(property="message", type="string", example="Token not found")
  51.      *     )
  52.      * )
  53.      * 
  54.      * @OA\Response(
  55.      *     response=429,
  56.      *     description="Too many requests",
  57.      *     @OA\JsonContent(
  58.      *         type="object",
  59.      *         @OA\Property(property="http_status", type="integer", example=429, description="Too many requests"),
  60.      *         @OA\Property(property="message", type="string", example="Too many requests")
  61.      *     )
  62.      * )
  63.      * 
  64.      * @OA\Response(
  65.      *     response=500,
  66.      *     description="Internal Server Error",
  67.      *     @OA\JsonContent(
  68.      *         type="object",
  69.      *         @OA\Property(property="http_status", type="integer", example=500, description="Internal Server Error"),
  70.      *         @OA\Property(property="message", type="string", example="Internal Server Error")
  71.      *     )
  72.      * )
  73.      * 
  74.      * @OA\Parameter(
  75.      *     name="id",
  76.      *     in="query",
  77.      *     description="Grupo Id",
  78.      *     @OA\Schema(type="integer")
  79.      * )
  80.      * 
  81.      * @OA\Parameter(
  82.      *     name="paginate",
  83.      *     in="query",
  84.      *     description="Informaçoes para paginação",
  85.      *     @OA\Schema(type="integer")
  86.      * )
  87.      * 
  88.      * @OA\Parameter(
  89.      *      name="limit",
  90.      *      in="query",
  91.      *      description="Número máximo de dados retornados por página, valor padrão 1000",
  92.      *      @OA\Schema(type="integer")
  93.      * )
  94.      * 
  95.      * @OA\Parameter(
  96.      *      name="offset",
  97.      *      in="query",
  98.      *      description="Indica o início da leitura, caso não informado valor padrão será 0",
  99.      *      @OA\Schema(type="integer")
  100.      * )
  101.      * 
  102.      * @OA\Tag(name="Grupos")
  103.      * @Security(name="Bearer")
  104.      * 
  105.     */
  106.     public function getGroup(Request $request)
  107.     {
  108.        
  109.         $this->requestUtil->setRequest($request)->setData();
  110.         $columns = [
  111.             "g.id AS grupo_id"
  112.             "g.name AS grupo_nome",
  113.             "g.status"
  114.         ];
  115.         $joins = [];
  116.         $groupId = (int)$request->get('id');
  117.         $paginate $request->get('paginate');
  118.         $limit = (int)$request->get('limit');
  119.         $offset = (int)$request->get('offset');
  120.         $filter = [
  121.             "g.deleted" => 0
  122.         ];
  123.         if(empty($limit) || $limit 1000){
  124.             $limit 1000;
  125.         }
  126.         if(empty($offset)){
  127.             $offset 0;
  128.         }
  129.         if($groupId 0){
  130.             $filter["g.id"] = $groupId;
  131.         }
  132.         $order = ["g.id" => "ASC"];
  133.         $data $this->repository->paginate("g"null$columns$joins$filter$order$limit$offset);
  134.         if(count($data['rows']) == 0){
  135.             return $this->eadResponse(nullErrorEnum::NO_CONTENTnull);
  136.         }
  137.         if($paginate == 1){
  138.             unset($data['searchText']);
  139.             return $this->json($data);
  140.         }
  141.         return $this->json($data['rows']);
  142.     }
  143.     /**
  144.      * Listagem de alunos por grupos do EAD.
  145.      *
  146.      * @Route("/api/1/groupstudent/{id}", methods={"GET"})
  147.      * @OA\Response(
  148.      *     response=200,
  149.      *     description="Retorna os alunos de um grupo do EAD.",
  150.      *     @OA\JsonContent(
  151.      *         type="object",
  152.      *         @OA\Property(property="grupo_id", type="integer", example=1, description="Id do grupo cadastrado no EAD."),
  153.      *         @OA\Property(property="grupo_nome", type="string", example="Grupo Nome", description="Nome do grupo cadastrado no EAD."),
  154.      *         @OA\Property(property="aluno_id", type="integer", example=44, description="Id do aluno cadastrado no EAD."),
  155.      *         @OA\Property(property="nome", type="string", example="Nome Exemplo", description="Nome do usuário cadastrado no EAD."),
  156.      *         @OA\Property(property="email", type="string", example="email@email.com", description="E-mail do usuário cadastrado no EAD.")
  157.      *     )
  158.      * )
  159.      * 
  160.      * @OA\Response(
  161.      *     response=204,
  162.      *     description="No content"
  163.      * )
  164.      * 
  165.      * @OA\Response(
  166.      *     response=401,
  167.      *     description="Token not found",
  168.      *     @OA\JsonContent(
  169.      *         type="object",
  170.      *         @OA\Property(property="http_status", type="integer", example=401, description="Token not found"),
  171.      *         @OA\Property(property="message", type="string", example="Token not found")
  172.      *     )
  173.      * )
  174.      * 
  175.      * @OA\Response(
  176.      *     response=429,
  177.      *     description="Too many requests",
  178.      *     @OA\JsonContent(
  179.      *         type="object",
  180.      *         @OA\Property(property="http_status", type="integer", example=429, description="Too many requests"),
  181.      *         @OA\Property(property="message", type="string", example="Too many requests")
  182.      *     )
  183.      * )
  184.      * 
  185.      * @OA\Response(
  186.      *     response=500,
  187.      *     description="Internal Server Error",
  188.      *     @OA\JsonContent(
  189.      *         type="object",
  190.      *         @OA\Property(property="http_status", type="integer", example=500, description="Internal Server Error"),
  191.      *         @OA\Property(property="message", type="string", example="Internal Server Error")
  192.      *     )
  193.      * )
  194.      * 
  195.      * @OA\Parameter(
  196.      *     name="id",
  197.      *     in="path",
  198.      *     description="Grupo Id",
  199.      *     required=true,
  200.      *     @OA\Schema(type="integer")
  201.      * )
  202.      * 
  203.      * @OA\Parameter(
  204.      *     name="paginate",
  205.      *     in="query",
  206.      *     description="Informaçoes para paginação",
  207.      *     @OA\Schema(type="integer")
  208.      * )
  209.      * 
  210.      * @OA\Parameter(
  211.      *      name="limit",
  212.      *      in="query",
  213.      *      description="Número máximo de dados retornados por página, valor padrão 1000",
  214.      *      @OA\Schema(type="integer")
  215.      * )
  216.      * 
  217.      * @OA\Parameter(
  218.      *      name="offset",
  219.      *      in="query",
  220.      *      description="Indica o início da leitura, caso não informado valor padrão será 0",
  221.      *      @OA\Schema(type="integer")
  222.      * )
  223.      * 
  224.      * @OA\Tag(name="Grupos")
  225.      * @Security(name="Bearer")
  226.      * 
  227.     */
  228.     public function getGroupStudent(Request $request)
  229.     {
  230.        
  231.         $this->requestUtil->setRequest($request)->setData();
  232.         $columns = [
  233.             "g.id AS grupo_id"
  234.             "g.name AS grupo_nome",
  235.             "u.id AS aluno_id",
  236.             "u.name AS name",
  237.             "u.email"
  238.         ];
  239.         $groupClass Group::class;
  240.         $groupId = (int)$request->get('id');
  241.         $paginate $request->get('paginate');
  242.         $limit = (int)$request->get('limit');
  243.         $offset = (int)$request->get('offset');
  244.         $joins = [
  245.             "{$groupClass} AS g" => "g.id = {$groupId}",
  246.         ];
  247.         $filter = [
  248.             "u.deleted" => 0,
  249.             "u.id" => [ "!="],
  250.             "whereText" => "u MEMBER OF g.user"
  251.         ];
  252.         if(empty($limit) || $limit 1000){
  253.             $limit 1000;
  254.         }
  255.         if(empty($offset)){
  256.             $offset 0;
  257.         }
  258.         
  259.         $order = ["u.id" => "ASC"];
  260.         $data $this->em->getRepository(User::class)->paginate("u"null$columns$joins$filter$order$limit$offset);
  261.         if(count($data['rows']) == 0){
  262.             return $this->eadResponse(nullErrorEnum::NO_CONTENTnull);
  263.         }
  264.         if($paginate == 1){
  265.             unset($data['searchText']);
  266.             return $this->json($data);
  267.         }
  268.         return $this->json($data['rows']);
  269.     }
  270.     /**
  271.      * Listagem de cursos por grupos do EAD.
  272.      *
  273.      * @Route("/api/1/groupcourse/{id}", methods={"GET"})
  274.      * @OA\Response(
  275.      *     response=200,
  276.      *     description="Retorna os cursos de um grupo do EAD.",
  277.      *     @OA\Schema(
  278.      *         type="object",
  279.      *         @OA\Property(property="grupo_id", type="integer", example=1, description="Id do grupo cadastrado no EAD."),
  280.      *         @OA\Property(property="grupo_nome", type="string", example="Grupo Nome", description="Nome do grupo cadastrado no EAD."),
  281.      *         @OA\Property(property="curso_id", type="integer", example=44, description="Id do curso cadastrado no EAD."),
  282.      *         @OA\Property(property="curso_titulo", type="string", example="Nome Exemplo", description="Nome do curso cadastrado no EAD."),
  283.      *         @OA\Property(property="curso_status", type="integer", example=2, description="Status do curso(0-Rascunho / 1-Publicado / 2-Restrito).")
  284.      *     )
  285.      * )
  286.      * 
  287.      * @OA\Response(
  288.      *     response=204,
  289.      *     description="No content"
  290.      * )
  291.      * 
  292.      * @OA\Response(
  293.      *     response=401,
  294.      *     description="Token not found",
  295.      *     @OA\JsonContent(
  296.      *         type="object",
  297.      *         @OA\Property(property="http_status", type="integer", example=401, description="Token not found"),
  298.      *         @OA\Property(property="message", type="string", example="Token not found")
  299.      *     )
  300.      * )
  301.      * 
  302.      * @OA\Response(
  303.      *     response=429,
  304.      *     description="Too many requests",
  305.      *     @OA\JsonContent(
  306.      *         type="object",
  307.      *         @OA\Property(property="http_status", type="integer", example=429, description="Too many requests"),
  308.      *         @OA\Property(property="message", type="string", example="Too many requests")
  309.      *     )
  310.      * )
  311.      * 
  312.      * @OA\Response(
  313.      *     response=500,
  314.      *     description="Internal Server Error",
  315.      *     @OA\JsonContent(
  316.      *         type="object",
  317.      *         @OA\Property(property="http_status", type="integer", example=500, description="Internal Server Error"),
  318.      *         @OA\Property(property="message", type="string", example="Internal Server Error")
  319.      *     )
  320.      * )
  321.      * 
  322.      * @OA\Parameter(
  323.      *     name="id",
  324.      *     in="path",
  325.      *     description="Grupo Id",
  326.      *     required=true,
  327.      *     @OA\Schema(type="integer")
  328.      * )
  329.      * 
  330.      * @OA\Parameter(
  331.      *     name="paginate",
  332.      *     in="query",
  333.      *     description="Informaçoes para paginação",
  334.      *     @OA\Schema(type="integer")
  335.      * )
  336.      * 
  337.      * @OA\Parameter(
  338.      *      name="limit",
  339.      *      in="query",
  340.      *      description="Número máximo de dados retornados por página, valor padrão 1000",
  341.      *      @OA\Schema(type="integer")
  342.      * )
  343.      * 
  344.      * @OA\Parameter(
  345.      *      name="offset",
  346.      *      in="query",
  347.      *      description="Indica o início da leitura, caso não informado valor padrão será 0",
  348.      *      @OA\Schema(type="integer")
  349.      * )
  350.      * 
  351.      * @OA\Tag(name="Grupos")
  352.      * @Security(name="Bearer")
  353.      * 
  354.     */
  355.     public function getGroupCourse(Request $request)
  356.     {
  357.        
  358.         $this->requestUtil->setRequest($request)->setData();
  359.         $columns = [
  360.             "g.id AS grupo_id"
  361.             "g.name AS grupo_nome",
  362.             "c.id AS curso_id",
  363.             "c.title AS curso_titulo",
  364.             "c.status"
  365.         ];
  366.         $groupClass Group::class;
  367.         $groupId = (int)$request->get('id');
  368.         $paginate $request->get('paginate');
  369.         $limit = (int)$request->get('limit');
  370.         $offset = (int)$request->get('offset');
  371.         $joins = [
  372.             "{$groupClass} AS g" => "g.id = {$groupId}",
  373.         ];
  374.         $filter = [
  375.             "c.deleted" => 0,
  376.             "whereText" => "c MEMBER OF g.course"
  377.         ];
  378.         if(empty($limit) || $limit 1000){
  379.             $limit 1000;
  380.         }
  381.         if(empty($offset)){
  382.             $offset 0;
  383.         }
  384.         
  385.         $order = ["c.id" => "ASC"];
  386.         $data $this->em->getRepository(Course::class)->paginate("c"null$columns$joins$filter$order$limit$offset);
  387.         if(count($data['rows']) == 0){
  388.             return $this->eadResponse(nullErrorEnum::NO_CONTENTnull);
  389.         }
  390.         if($paginate == 1){
  391.             unset($data['searchText']);
  392.             return $this->json($data);
  393.         }
  394.         return $this->json($data['rows']);
  395.     }
  396.     /**
  397.      * Inserir um novo grupo no EAD.
  398.      *
  399.      * @Route("/api/1/group", methods={"POST"})
  400.      * consumes={"application/json"}
  401.      * produces={"application/json"}
  402.      * 
  403.      * @OA\Response(
  404.      *     response=200,
  405.      *     description="Success",
  406.      *     @OA\JsonContent(
  407.      *         type="object",
  408.      *         @OA\Property(property="http_status", type="integer", example=200, description="Success"),
  409.      *         @OA\Property(property="message", type="string", example="Success"),
  410.      *         @OA\Property(
  411.      *              property="data", 
  412.      *              type="object", 
  413.      *              @OA\Property(property="id", type="integer", example=1), 
  414.      *              @OA\Property(property="grupo_nome", type="string", example="Nome do grupo"),
  415.      *              @OA\Property(property="status", type="integer", example=1),
  416.      *              @OA\Property(property="aluno", type="array", collectionFormat="multi", @OA\Items(type="string"), example="[]"),
  417.      *              @OA\Property(property="curso", type="array", collectionFormat="multi", @OA\Items(type="string"), example="[]")
  418.      *         )  
  419.      *     )
  420.      * )
  421.      * 
  422.      * @OA\Response(
  423.      *     response=401,
  424.      *     description="Token not found",
  425.      *     @OA\JsonContent(
  426.      *         type="object",
  427.      *         @OA\Property(property="http_status", type="integer", example=401, description="Token not found"),
  428.      *         @OA\Property(property="message", type="string", example="Token not found")
  429.      *     )
  430.      * )
  431.      * 
  432.      * @OA\Response(
  433.      *     response=406,
  434.      *     description="Empty Fields",
  435.      *     @OA\JsonContent(
  436.      *         type="object",
  437.      *         @OA\Property(property="http_status", type="integer", example=406, description="Empty Field"),
  438.      *         @OA\Property(property="message", type="string", example="Error"),
  439.      *         @OA\Property(
  440.      *              property="data", 
  441.      *              type="array", 
  442.      *              collectionFormat="multi", 
  443.      *              @OA\Items(
  444.      *                  type="string",
  445.      *                  example="field"
  446.      *              )
  447.      *         ),
  448.      *     )
  449.      * )
  450.      * 
  451.      * @OA\Response(
  452.      *     response=429,
  453.      *     description="Too many requests",
  454.      *     @OA\JsonContent(
  455.      *         type="object",
  456.      *         @OA\Property(property="http_status", type="integer", example=429, description="Too many requests"),
  457.      *         @OA\Property(property="message", type="string", example="Too many requests")
  458.      *     )
  459.      * )
  460.      * 
  461.      * @OA\Response(
  462.      *     response=500,
  463.      *     description="Internal Server Error",
  464.      *     @OA\JsonContent(
  465.      *         type="object",
  466.      *         @OA\Property(property="http_status", type="integer", example=500, description="Internal Server Error"),
  467.      *         @OA\Property(property="message", type="string", example="Internal Server Error")
  468.      *     )
  469.      * )
  470.      * 
  471.      * @OA\RequestBody(
  472.      *      required=true,
  473.      *      @OA\MediaType(
  474.      *          mediaType="multipart/form-data",
  475.      *          @OA\Schema(
  476.      *              type="object",
  477.      *              @OA\Property(
  478.      *                  property="nome",
  479.      *                  description="Nome do Grupo",
  480.      *                  type="string(250)"
  481.      *              ),
  482.      *              @OA\Property(
  483.      *                  property="userManager",
  484.      *                  description="Id do usuário administrador do grupo",
  485.      *                  type="int"
  486.      *              ),
  487.      *              required={"nome", "userManager"}
  488.      *          )
  489.      *      )
  490.      * )
  491.      * 
  492.      * @OA\Tag(name="Grupos")
  493.      * @Security(name="Bearer")
  494.      * 
  495.     */
  496.     public function postGroup(Request $request)
  497.     {
  498.        
  499.         $this->requestUtil->setRequest($request)->setData();
  500.         
  501.         $group = new Group();
  502.         $name $this->requestUtil->getField('nome');
  503.         $this->requestUtil->setField('name'$name);
  504.         $userManagerId $this->requestUtil->getField('userManager');
  505.         
  506.         if($userManagerId == 1){
  507.             return $this->eadResponse(['userManager'], ErrorEnum::NOT_FOUNDErrorEnum::MESSAGE_NOT_FOUND);
  508.         }
  509.       
  510.         $userManager $this->em->getRepository(User::class)->findOneBy([
  511.             "id" => $userManagerId,
  512.             "deleted" => UserEnum::ITEM_NO_DELETED
  513.         ]);
  514.         $this->requestUtil->setField('userManager'$userManager);
  515.         
  516.         $group $this->setAllFields($group);
  517.         $errors $this->validateEntity($group);
  518.         
  519.         if($errors){
  520.             return $this->eadResponse($errorsErrorEnum::FIELD_EMPTYErrorEnum::MESSAGE_EMPTY_FIELD);
  521.         }
  522.         $this->em->persist($group);
  523.         $this->em->flush();
  524.         $return $group->toReturnApi();
  525.         //$this->userLogService->logInsert("group", $group->getId(), $return, UserLogEnum::ORIGIN_CLIENT_API);
  526.         return $this->eadResponse($returnErrorEnum::SUCCESSErrorEnum::MESSAGE_SUCCESS);
  527.     }
  528.     /**
  529.      * Inserir um aluno em um grupo do EAD.
  530.      *
  531.      * @Route("/api/1/groupstudent", methods={"POST"})
  532.      * consumes={"application/json"}
  533.      * produces={"application/json"}
  534.      * 
  535.      * @OA\Response(
  536.      *     response=200,
  537.      *     description="Success",
  538.      *     @OA\JsonContent(
  539.      *         type="object",
  540.      *         @OA\Property(property="http_status", type="integer", example=200, description="Success"),
  541.      *         @OA\Property(property="message", type="string", example="Success"),
  542.      *         @OA\Property(property="data", nullable=true, type="application/json", example="null"),  
  543.      *     )
  544.      * )
  545.      * 
  546.      * @OA\Response(
  547.      *     response=401,
  548.      *     description="Token not found",
  549.      *     @OA\JsonContent(
  550.      *         type="object",
  551.      *         @OA\Property(property="http_status", type="integer", example=401, description="Token not found"),
  552.      *         @OA\Property(property="message", type="string", example="Token not found")
  553.      *     )
  554.      * )
  555.      * 
  556.      * @OA\Response(
  557.      *     response=404,
  558.      *     description="Not found",
  559.      *     @OA\JsonContent(
  560.      *         type="object",
  561.      *         @OA\Property(property="http_status", type="integer", example=404, description="Not found"),
  562.      *         @OA\Property(property="message", type="string", example="Not found"),
  563.      *         @OA\Property(
  564.      *              property="data", 
  565.      *              type="array", 
  566.      *              collectionFormat="multi", 
  567.      *              @OA\Items(
  568.      *                  type="string",
  569.      *                  example="field"
  570.      *              )
  571.      *         ),
  572.      *     )
  573.      * )
  574.      * 
  575.      * @OA\Response(
  576.      *     response=429,
  577.      *     description="Too many requests",
  578.      *     @OA\JsonContent(
  579.      *         type="object",
  580.      *         @OA\Property(property="http_status", type="integer", example=429, description="Too many requests"),
  581.      *         @OA\Property(property="message", type="string", example="Too many requests")
  582.      *     )
  583.      * )
  584.      * 
  585.      * @OA\Response(
  586.      *     response=500,
  587.      *     description="Internal Server Error",
  588.      *     @OA\JsonContent(
  589.      *         type="object",
  590.      *         @OA\Property(property="http_status", type="integer", example=500, description="Internal Server Error"),
  591.      *         @OA\Property(property="message", type="string", example="Internal Server Error")
  592.      *     )
  593.      * )
  594.      * 
  595.      * @OA\RequestBody(
  596.      *      required=true,
  597.      *      @OA\MediaType(
  598.      *          mediaType="multipart/form-data",
  599.      *          @OA\Schema(
  600.      *              type="object",
  601.      *              @OA\Property(
  602.      *                  property="id",
  603.      *                  description="Grupo id",
  604.      *                  type="integer"
  605.      *              ),
  606.      *              @OA\Property(
  607.      *                  property="usuario_id",
  608.      *                  description="Usuário id",
  609.      *                  type="integer"
  610.      *              ),
  611.      *              required={"id", "usuario_id"}
  612.      *          )
  613.      *      )
  614.      * )
  615.      * 
  616.      * @OA\Tag(name="Grupos")
  617.      * @Security(name="Bearer")
  618.      * 
  619.     */
  620.     public function postGroupStudent(Request $request)
  621.     {
  622.        
  623.         $this->requestUtil->setRequest($request)->setData();
  624.         
  625.         $groupId $request->get('id');
  626.         $group $this->repository->findOneBy([
  627.             "id" => $groupId,
  628.             "deleted" => GroupEnum::ITEM_NO_DELETED
  629.         ]);
  630.         if (!$group) {
  631.             return $this->eadResponse(['id'], ErrorEnum::NOT_FOUNDErrorEnum::MESSAGE_NOT_FOUND);
  632.         }
  633.         $userId $request->get('usuario_id');
  634.         $user $this->em->getRepository(User::class)->findOneBy([
  635.             "id" => $userId,
  636.             "deleted" => GroupEnum::ITEM_NO_DELETED
  637.         ]);
  638.         if (!$user) {
  639.             return $this->eadResponse(['usuario_id'], ErrorEnum::NOT_FOUNDErrorEnum::MESSAGE_NOT_FOUND);
  640.         }
  641.         $group->addUser($user);
  642.         $this->em->flush();
  643.         $this->repository->enrollUsers($group, [ $user ]);
  644.         
  645.         $data $group->toReturn();
  646.         $clientDomain '//'.$this->eadDomain.'/';
  647.         $emailTitle $this->configuration->getLanguage('user_in_group.subject1''email').$group->getName().$this->configuration->getLanguage('user_in_group.subject2''email');
  648.         $emailService $this->generalService->getService('EmailService');
  649.         
  650.         if($emailService->checkUserToSend($user)){
  651.             $emailService->setToEmail($user->getEmail());
  652.             $emailService->setToName($user->getName());
  653.             $emailService->setSubject($emailTitle);
  654.             $emailService->setData([
  655.                 "userName" => $user->getName(),
  656.                 "btnLink" => 'https:'.$clientDomain,
  657.                 "groupName" => $group->getName()
  658.             ]);
  659.             $emailService->setTemplateBody("user_in_group");
  660.             $emailService->send();
  661.         }
  662.         
  663.         /*$this->userLogService->logInsert(
  664.             "group_x_user", 
  665.             $group->getId(), 
  666.             $data, 
  667.             UserLogEnum::ORIGIN_CLIENT_API
  668.         );*/
  669.         return $this->eadResponse(nullErrorEnum::SUCCESSErrorEnum::MESSAGE_SUCCESS);
  670.     }
  671.     /**
  672.      * Inserir um curso em um grupo do EAD.
  673.      *
  674.      * @Route("/api/1/groupcourse", methods={"POST"})
  675.      * consumes={"application/json"}
  676.      * produces={"application/json"}
  677.      * 
  678.      * @OA\Response(
  679.      *     response=200,
  680.      *     description="Success",
  681.      *     @OA\JsonContent(
  682.      *         type="object",
  683.      *         @OA\Property(property="http_status", type="integer", example=200, description="Success"),
  684.      *         @OA\Property(property="message", type="string", example="Success"),
  685.      *         @OA\Property(property="data", nullable=true, type="application/json", example="null"),  
  686.      *     )
  687.      * )
  688.      * 
  689.      * @OA\Response(
  690.      *     response=401,
  691.      *     description="Token not found",
  692.      *     @OA\JsonContent(
  693.      *         type="object",
  694.      *         @OA\Property(property="http_status", type="integer", example=401, description="Token not found"),
  695.      *         @OA\Property(property="message", type="string", example="Token not found")
  696.      *     )
  697.      * )
  698.      * 
  699.      * @OA\Response(
  700.      *     response=404,
  701.      *     description="Not found",
  702.      *     @OA\JsonContent(
  703.      *         type="object",
  704.      *         @OA\Property(property="http_status", type="integer", example=404, description="Not found"),
  705.      *         @OA\Property(property="message", type="string", example="Not found"),
  706.      *         @OA\Property(
  707.      *              property="data", 
  708.      *              type="array", 
  709.      *              collectionFormat="multi", 
  710.      *              @OA\Items(
  711.      *                  type="string",
  712.      *                  example="field"
  713.      *              )
  714.      *         ),
  715.      *     )
  716.      * )
  717.      * 
  718.      * @OA\Response(
  719.      *     response=429,
  720.      *     description="Too many requests",
  721.      *     @OA\JsonContent(
  722.      *         type="object",
  723.      *         @OA\Property(property="http_status", type="integer", example=429, description="Too many requests"),
  724.      *         @OA\Property(property="message", type="string", example="Too many requests")
  725.      *     )
  726.      * )
  727.      * 
  728.      * @OA\Response(
  729.      *     response=500,
  730.      *     description="Internal Server Error",
  731.      *     @OA\JsonContent(
  732.      *         type="object",
  733.      *         @OA\Property(property="http_status", type="integer", example=500, description="Internal Server Error"),
  734.      *         @OA\Property(property="message", type="string", example="Internal Server Error")
  735.      *     )
  736.      * )
  737.      * 
  738.      * @OA\RequestBody(
  739.      *      required=true,
  740.      *      @OA\MediaType(
  741.      *          mediaType="multipart/form-data",
  742.      *          @OA\Schema(
  743.      *              type="object",
  744.      *              @OA\Property(
  745.      *                  property="id",
  746.      *                  description="Grupo id",
  747.      *                  type="integer"
  748.      *              ),
  749.      *              @OA\Property(
  750.      *                  property="curso",
  751.      *                  description="Curso id",
  752.      *                  type="integer"
  753.      *              ),
  754.      *              required={"id", "curso"}
  755.      *          )
  756.      *      )
  757.      * )
  758.      * 
  759.      * @OA\Tag(name="Grupos")
  760.      * @Security(name="Bearer")
  761.      * 
  762.     */
  763.     public function postGroupCourse(Request $request)
  764.     {
  765.         $this->requestUtil->setRequest($request)->setData();
  766.         
  767.         $groupId = (int)$request->get('id');
  768.         $group $this->repository->findOneBy([
  769.             "id" => $groupId,
  770.             "deleted" => GroupEnum::ITEM_NO_DELETED
  771.         ]);
  772.         if (!$group) {
  773.             return $this->eadResponse(['id'], ErrorEnum::NOT_FOUNDErrorEnum::MESSAGE_NOT_FOUND);
  774.         }
  775.         $courseId = (int)$request->get('curso');
  776.         $courseRepository $this->em->getRepository(Course::class);
  777.         $course $courseRepository->findOneBy([
  778.             "id" => $courseId,
  779.             "status" => CourseEnum::PUBLISHED,
  780.             "deleted" => GroupEnum::ITEM_NO_DELETED
  781.         ]);
  782.     
  783.         if (!$course) {
  784.             return $this->eadResponse(
  785.                 [ 'curso' ], 
  786.                 ErrorEnum::NOT_FOUND
  787.                 ErrorEnum::MESSAGE_NOT_FOUND
  788.             );
  789.         }
  790.         
  791.         $group->addCourse($course);
  792.        
  793.         $this->em->flush();
  794.         
  795.         $this->repository->enrollUsers($groupnull, [ $course ]);
  796.         
  797.         $data $group->toReturn();
  798.         /*$this->userLogService->logInsert(
  799.             "group_x_course", 
  800.             $group->getId(), 
  801.             $data, 
  802.             UserLogEnum::ORIGIN_CLIENT_API
  803.         );*/
  804.         
  805.         return $this->eadResponse(nullErrorEnum::SUCCESSErrorEnum::MESSAGE_SUCCESS);
  806.     }
  807.     /**
  808.      * Atualizar um grupo do EAD.
  809.      *
  810.      * @Route("/api/1/group/{id}", methods={"PUT"})
  811.      * consumes={"application/json"}
  812.      * produces={"application/json"}
  813.      * 
  814.      * @OA\Response(
  815.      *     response=200,
  816.      *     description="Success",
  817.      *     @OA\JsonContent(
  818.      *         type="object",
  819.      *         @OA\Property(property="http_status", type="integer", example=200, description="Success"),
  820.      *         @OA\Property(property="message", type="string", example="Success"),
  821.      *         @OA\Property(
  822.      *              property="data", 
  823.      *              type="object", 
  824.      *              @OA\Property(property="id", type="integer", example=1), 
  825.      *              @OA\Property(property="grupo_nome", type="string", example="Nome do grupo"),
  826.      *              @OA\Property(property="status", type="integer", example=1),
  827.      *              @OA\Property(
  828.      *                  property="aluno", 
  829.      *                  type="array", 
  830.      *                  collectionFormat="multi",
  831.      *                   @OA\Items(
  832.      *                      type="object",
  833.      *                      @OA\Property(property="id", type="integer", example=100), 
  834.      *                      @OA\Property(property="nome", type="string", example="Nome do aluno")
  835.      *                  )
  836.      *              ),
  837.      *              @OA\Property(
  838.      *                  property="curso", 
  839.      *                  type="array", 
  840.      *                  collectionFormat="multi",
  841.      *                   @OA\Items(
  842.      *                      type="object",
  843.      *                      @OA\Property(property="id", type="integer", example=2), 
  844.      *                      @OA\Property(property="titulo", type="string", example="Título do curso")
  845.      *                  )
  846.      *              ),
  847.      *         )  
  848.      *     )
  849.      * )
  850.      * 
  851.      * @OA\Response(
  852.      *     response=401,
  853.      *     description="Token not found",
  854.      *     @OA\JsonContent(
  855.      *         type="object",
  856.      *         @OA\Property(property="http_status", type="integer", example=401, description="Token not found"),
  857.      *         @OA\Property(property="message", type="string", example="Token not found")
  858.      *     )
  859.      * )
  860.      * 
  861.      * @OA\Response(
  862.      *     response=404,
  863.      *     description="Not found",
  864.      *     @OA\JsonContent(
  865.      *         type="object",
  866.      *         @OA\Property(property="http_status", type="integer", example=404, description="Not found"),
  867.      *         @OA\Property(property="message", type="string", example="Not found"),
  868.      *         @OA\Property(
  869.      *              property="data", 
  870.      *              type="array", 
  871.      *              collectionFormat="multi", 
  872.      *              @OA\Items(
  873.      *                  type="string",
  874.      *                  example="field"
  875.      *              )
  876.      *         ),
  877.      *     )
  878.      * )
  879.      * 
  880.      * @OA\Response(
  881.      *     response=406,
  882.      *     description="Empty Fields",
  883.      *     @OA\JsonContent(
  884.      *         type="object",
  885.      *         @OA\Property(property="http_status", type="integer", example=406, description="Empty Field"),
  886.      *         @OA\Property(property="message", type="string", example="Error"),
  887.      *         @OA\Property(
  888.      *              property="data", 
  889.      *              type="array", 
  890.      *              collectionFormat="multi", 
  891.      *              @OA\Items(
  892.      *                  type="string",
  893.      *                  example="field"
  894.      *              )
  895.      *         ),
  896.      *     )
  897.      * )
  898.      * 
  899.      * @OA\Response(
  900.      *     response=429,
  901.      *     description="Too many requests",
  902.      *     @OA\JsonContent(
  903.      *         type="object",
  904.      *         @OA\Property(property="http_status", type="integer", example=429, description="Too many requests"),
  905.      *         @OA\Property(property="message", type="string", example="Too many requests")
  906.      *     )
  907.      * )
  908.      * 
  909.      * @OA\Response(
  910.      *     response=500,
  911.      *     description="Internal Server Error",
  912.      *     @OA\JsonContent(
  913.      *         type="object",
  914.      *         @OA\Property(property="http_status", type="integer", example=500, description="Internal Server Error"),
  915.      *         @OA\Property(property="message", type="string", example="Internal Server Error")
  916.      *     )
  917.      * )
  918.      * 
  919.      * @OA\Parameter(
  920.      *     name="id",
  921.      *     in="path",
  922.      *     description="Grupo Id",
  923.      *     required=true,
  924.      *     @OA\Schema(type="integer")
  925.      * )
  926.      * 
  927.      * @OA\RequestBody(
  928.      *      required=true,
  929.      *      @OA\MediaType(
  930.      *          mediaType="multipart/form-data",
  931.      *          @OA\Schema(
  932.      *              type="object",
  933.      *              @OA\Property(
  934.      *                  property="nome",
  935.      *                  description="Nome do Grupo",
  936.      *                  type="string(250)"
  937.      *              ),
  938.      *              @OA\Property(
  939.      *                  property="userManager",
  940.      *                  description="Id do usuário administrador do grupo",
  941.      *                  type="int"
  942.      *              )
  943.      *          )
  944.      *      )
  945.      * )
  946.      * 
  947.      * @OA\Tag(name="Grupos")
  948.      * @Security(name="Bearer")
  949.      * 
  950.     */
  951.     public function putGroup(Request $request)
  952.     {
  953.         $this->requestUtil->setRequest($request)->setData();
  954.         
  955.         $groupId = (int)$request->get('id');
  956.         $group $this->repository->findOneBy([
  957.             "id" => $groupId,
  958.             "deleted" => GroupEnum::ITEM_NO_DELETED
  959.         ]);
  960.         if (!$group) {
  961.             return $this->eadResponse(['id'], ErrorEnum::NOT_FOUNDErrorEnum::MESSAGE_NOT_FOUND);
  962.         }
  963.         
  964.         if(!empty($this->requestUtil->getField('nome'))){
  965.             $name $this->requestUtil->getField('nome');
  966.             $group->setName($name);
  967.         }
  968.         if(is_numeric($this->requestUtil->getField('userManager'))){ 
  969.             $userManagerId $this->requestUtil->getField('userManager');
  970.             if($userManagerId == 1){
  971.                 return $this->eadResponse(['userManager'], ErrorEnum::NOT_FOUNDErrorEnum::MESSAGE_NOT_FOUND);
  972.             }
  973.             $userManager $this->em->getRepository(User::class)->findOneBy([
  974.                 "id" => $userManagerId,
  975.                 "deleted" => UserEnum::ITEM_NO_DELETED
  976.             ]);
  977.             $group->setUserManager($userManager);
  978.         }
  979.         
  980.         $errors $this->validateEntity($group);
  981.         if($errors){
  982.             return $this->eadResponse($errorsErrorEnum::FIELD_EMPTYErrorEnum::MESSAGE_EMPTY_FIELD);
  983.         }
  984.         $this->em->flush();
  985.         $return $group->toReturnApi();
  986.         //$this->userLogService->logUpdate("group", $group->getId(), $return, UserLogEnum::ORIGIN_CLIENT_API);
  987.         return $this->eadResponse($returnErrorEnum::SUCCESSErrorEnum::MESSAGE_SUCCESS);
  988.     }
  989.     /**
  990.      * Excluir um grupo do EAD.
  991.      *
  992.      * @Route("/api/1/group/{id}/{excluir_matriculas}", methods={"DELETE"})
  993.      * @OA\Response(
  994.      *     response=200,
  995.      *     description="Success",
  996.      *     @OA\JsonContent(
  997.      *         type="object",
  998.      *         @OA\Property(property="http_status", type="integer", example=200, description="Success"),
  999.      *         @OA\Property(property="message", type="string", example="Success"),
  1000.      *         @OA\Property(property="data", nullable=true, type="application/json", example="null"),  
  1001.      *     )
  1002.      * )
  1003.      * 
  1004.      * @OA\Response(
  1005.      *     response=401,
  1006.      *     description="Token not found",
  1007.      *     @OA\JsonContent(
  1008.      *         type="object",
  1009.      *         @OA\Property(property="http_status", type="integer", example=401, description="Token not found"),
  1010.      *         @OA\Property(property="message", type="string", example="Token not found")
  1011.      *     )
  1012.      * )
  1013.      * 
  1014.      * @OA\Response(
  1015.      *     response=404,
  1016.      *     description="Not found",
  1017.      *     @OA\JsonContent(
  1018.      *         type="object",
  1019.      *         @OA\Property(property="http_status", type="integer", example=404, description="Not found"),
  1020.      *         @OA\Property(property="message", type="string", example="Not found"),
  1021.      *         @OA\Property(
  1022.      *              property="data", 
  1023.      *              type="array", 
  1024.      *              collectionFormat="multi", 
  1025.      *              @OA\Items(
  1026.      *                  type="string",
  1027.      *                  example="field"
  1028.      *              )
  1029.      *         ),
  1030.      *     )
  1031.      * )
  1032.      * 
  1033.      * @OA\Response(
  1034.      *     response=429,
  1035.      *     description="Too many requests",
  1036.      *     @OA\JsonContent(
  1037.      *         type="object",
  1038.      *         @OA\Property(property="http_status", type="integer", example=429, description="Too many requests"),
  1039.      *         @OA\Property(property="message", type="string", example="Too many requests")
  1040.      *     )
  1041.      * )
  1042.      * 
  1043.      * @OA\Response(
  1044.      *     response=500,
  1045.      *     description="Internal Server Error",
  1046.      *     @OA\JsonContent(
  1047.      *         type="object",
  1048.      *         @OA\Property(property="http_status", type="integer", example=500, description="Internal Server Error"),
  1049.      *         @OA\Property(property="message", type="string", example="Internal Server Error")
  1050.      *     )
  1051.      * )
  1052.      * 
  1053.      * @OA\Parameter(
  1054.      *     name="id",
  1055.      *     in="path",
  1056.      *     description="Grupo Id",
  1057.      *     required=true,
  1058.      *     @OA\Schema(type="integer")
  1059.      * )
  1060.      * 
  1061.      * @OA\Parameter(
  1062.      *     name="excluir_matriculas",
  1063.      *     in="path",
  1064.      *     required=true,
  1065.      *     description="0-Não / 1-Sim",
  1066.      *     @OA\Schema(type="integer")
  1067.      * )
  1068.      * 
  1069.      * @OA\Tag(name="Grupos")
  1070.      * @Security(name="Bearer")
  1071.     */
  1072.     public function deleteGroup(Request $request)
  1073.     {
  1074.         $this->requestUtil->setRequest($request)->setData();
  1075.         $groupId = (int)$request->get('id');
  1076.         $group $this->repository->findOneBy([
  1077.             "id" => $groupId,
  1078.             "deleted" => GroupEnum::ITEM_NO_DELETED
  1079.         ]);
  1080.         if (!$group) {
  1081.             return $this->eadResponse(nullErrorEnum::NOT_FOUNDErrorEnum::MESSAGE_NOT_FOUND);
  1082.         }
  1083.         $deleteEnrollment = (int)$request->get('excluir_matriculas');
  1084.         $this->repository->delete($groupTrashEnum::GROUPUserPermissionEnum::HIGHfalse$deleteEnrollment);
  1085.         $this->userLogService->logDelete("group"$groupIdnullUserLogEnum::ORIGIN_CLIENT_API);
  1086.         return $this->eadResponse(nullErrorEnum::SUCCESSErrorEnum::MESSAGE_SUCCESS);
  1087.     }
  1088.     /**
  1089.      * Excluir um aluno de um grupo do EAD.
  1090.      *
  1091.      *
  1092.      * @Route("/api/1/groupstudent/{id}/{usuario_id}/{excluir_matriculas}", methods={"DELETE"})
  1093.      * @OA\Response(
  1094.      *     response=200,
  1095.      *     description="Success",
  1096.      *     @OA\JsonContent(
  1097.      *         type="object",
  1098.      *         @OA\Property(property="http_status", type="integer", example=200, description="Success"),
  1099.      *         @OA\Property(property="message", type="string", example="Success"),
  1100.      *         @OA\Property(property="data", nullable=true, type="application/json", example="null"),  
  1101.      *     )
  1102.      * )
  1103.      * 
  1104.      * @OA\Response(
  1105.      *     response=401,
  1106.      *     description="Token not found",
  1107.      *     @OA\JsonContent(
  1108.      *         type="object",
  1109.      *         @OA\Property(property="http_status", type="integer", example=401, description="Token not found"),
  1110.      *         @OA\Property(property="message", type="string", example="Token not found")
  1111.      *     )
  1112.      * )
  1113.      * 
  1114.      * @OA\Response(
  1115.      *     response=404,
  1116.      *     description="Not found",
  1117.      *     @OA\JsonContent(
  1118.      *         type="object",
  1119.      *         @OA\Property(property="http_status", type="integer", example=404, description="Not found"),
  1120.      *         @OA\Property(property="message", type="string", example="Not found"),
  1121.      *         @OA\Property(
  1122.      *              property="data", 
  1123.      *              type="array", 
  1124.      *              collectionFormat="multi", 
  1125.      *              @OA\Items(
  1126.      *                  type="string",
  1127.      *                  example="field"
  1128.      *              )
  1129.      *         ),
  1130.      *     )
  1131.      * )
  1132.      * 
  1133.      * @OA\Response(
  1134.      *     response=429,
  1135.      *     description="Too many requests",
  1136.      *     @OA\JsonContent(
  1137.      *         type="object",
  1138.      *         @OA\Property(property="http_status", type="integer", example=429, description="Too many requests"),
  1139.      *         @OA\Property(property="message", type="string", example="Too many requests")
  1140.      *     )
  1141.      * )
  1142.      * 
  1143.      * @OA\Response(
  1144.      *     response=500,
  1145.      *     description="Internal Server Error",
  1146.      *     @OA\JsonContent(
  1147.      *         type="object",
  1148.      *         @OA\Property(property="http_status", type="integer", example=500, description="Internal Server Error"),
  1149.      *         @OA\Property(property="message", type="string", example="Internal Server Error")
  1150.      *     )
  1151.      * )
  1152.      * 
  1153.      * @OA\Parameter(
  1154.      *     name="id",
  1155.      *     in="path",
  1156.      *     description="Grupo Id",
  1157.      *     required=true,
  1158.      *     @OA\Schema(type="integer")
  1159.      * )
  1160.      * 
  1161.      * @OA\Parameter(
  1162.      *     name="usuario_id",
  1163.      *     in="path",
  1164.      *     required=true,
  1165.      *     description="Usuário Id",
  1166.      *     @OA\Schema(type="integer")
  1167.      * )
  1168.      * 
  1169.      * @OA\Parameter(
  1170.      *     name="excluir_matriculas",
  1171.      *     in="path",
  1172.      *     required=true,
  1173.      *     description="0-Não / 1-Sim",
  1174.      *     @OA\Schema(type="integer")
  1175.      * )
  1176.      * 
  1177.      * @OA\Tag(name="Grupos")
  1178.      * @Security(name="Bearer")
  1179.      * 
  1180.     */
  1181.     public function deleteGroupStudent(Request $request)
  1182.     {
  1183.         $this->requestUtil->setRequest($request)->setData();
  1184.        
  1185.         $groupId = (int)$request->get('id');
  1186.         $group $this->repository->findOneBy([
  1187.             "id" => $groupId,
  1188.             "deleted" => GroupEnum::ITEM_NO_DELETED
  1189.         ]);
  1190.         
  1191.         if (!$group) {
  1192.             return $this->eadResponse(['id'], ErrorEnum::NOT_FOUNDErrorEnum::MESSAGE_NOT_FOUND);
  1193.         }
  1194.         
  1195.         $userId = (int)$request->get('usuario_id');
  1196.         $user $this->em->getRepository(User::class)->findOneBy([
  1197.             "id" => $userId,
  1198.             "deleted" => GroupEnum::ITEM_NO_DELETED
  1199.         ]);
  1200.         
  1201.         if (!$user) {
  1202.             return $this->eadResponse(['usuario_id'], ErrorEnum::NOT_FOUNDErrorEnum::MESSAGE_NOT_FOUND);
  1203.         }
  1204.        
  1205.         $deleteEnrollment = (int)$request->get('excluir_matriculas');
  1206.         
  1207.         if($deleteEnrollment == GroupEnum::YES){
  1208.             $enrollments $this->em->getRepository(Enrollment::class)->getEnrollmentsByGroup($groupIdnull$userId);
  1209.             foreach ($enrollments as $key => $enrollment) {
  1210.                 $this->em->getRepository(Enrollment::class)->delete($enrollmentTrashEnum::ENROLLMENTUserPermissionEnum::HIGHfalse);
  1211.             }
  1212.         }
  1213.         $group->removeUser($user);
  1214.         $this->em->flush();
  1215.         $this->userLogService->logDelete("group_x_user"$groupIdnullUserLogEnum::ORIGIN_CLIENT_API);
  1216.         return $this->eadResponse(nullErrorEnum::SUCCESSErrorEnum::MESSAGE_SUCCESS);
  1217.     }
  1218.     /**
  1219.      * Excluir um curso de um grupo do EAD.
  1220.      *
  1221.      * @Route("/api/1/groupcourse/{id}/{curso}/{excluir_matriculas}", methods={"DELETE"})
  1222.      * @OA\Response(
  1223.      *     response=200,
  1224.      *     description="Success",
  1225.      *     @OA\JsonContent(
  1226.      *         type="object",
  1227.      *         @OA\Property(property="http_status", type="integer", example=200, description="Success"),
  1228.      *         @OA\Property(property="message", type="string", example="Success"),
  1229.      *         @OA\Property(property="data", nullable=true, type="application/json", example="null"),  
  1230.      *     )
  1231.      * )
  1232.      * 
  1233.      * @OA\Response(
  1234.      *     response=401,
  1235.      *     description="Token not found",
  1236.      *     @OA\JsonContent(
  1237.      *         type="object",
  1238.      *         @OA\Property(property="http_status", type="integer", example=401, description="Token not found"),
  1239.      *         @OA\Property(property="message", type="string", example="Token not found")
  1240.      *     )
  1241.      * )
  1242.      * 
  1243.      * @OA\Response(
  1244.      *     response=404,
  1245.      *     description="Not found",
  1246.      *     @OA\JsonContent(
  1247.      *         type="object",
  1248.      *         @OA\Property(property="http_status", type="integer", example=404, description="Not found"),
  1249.      *         @OA\Property(property="message", type="string", example="Not found"),
  1250.      *         @OA\Property(
  1251.      *              property="data", 
  1252.      *              type="array", 
  1253.      *              collectionFormat="multi", 
  1254.      *              @OA\Items(
  1255.      *                  type="string",
  1256.      *                  example="field"
  1257.      *              )
  1258.      *         ),
  1259.      *     )
  1260.      * )
  1261.      * 
  1262.      * @OA\Response(
  1263.      *     response=429,
  1264.      *     description="Too many requests",
  1265.      *     @OA\JsonContent(
  1266.      *         type="object",
  1267.      *         @OA\Property(property="http_status", type="integer", example=429, description="Too many requests"),
  1268.      *         @OA\Property(property="message", type="string", example="Too many requests")
  1269.      *     )
  1270.      * )
  1271.      * 
  1272.      * @OA\Response(
  1273.      *     response=500,
  1274.      *     description="Internal Server Error",
  1275.      *     @OA\JsonContent(
  1276.      *         type="object",
  1277.      *         @OA\Property(property="http_status", type="integer", example=500, description="Internal Server Error"),
  1278.      *         @OA\Property(property="message", type="string", example="Internal Server Error")
  1279.      *     )
  1280.      * )
  1281.      * 
  1282.      * @OA\Parameter(
  1283.      *     name="id",
  1284.      *     in="path",
  1285.      *     description="Grupo Id",
  1286.      *     required=true,
  1287.      *     @OA\Schema(type="integer")
  1288.      * )
  1289.      * 
  1290.      * @OA\Parameter(
  1291.      *     name="curso",
  1292.      *     in="path",
  1293.      *     required=true,
  1294.      *     description="Curso Id",
  1295.      *     @OA\Schema(type="integer")
  1296.      * )
  1297.      * 
  1298.      * @OA\Parameter(
  1299.      *     name="excluir_matriculas",
  1300.      *     in="path",
  1301.      *     required=true,
  1302.      *     description="0-Não / 1-Sim",
  1303.      *     @OA\Schema(type="integer")
  1304.      * )
  1305.      * 
  1306.      * @OA\Tag(name="Grupos")
  1307.      * @Security(name="Bearer")
  1308.      * 
  1309.      */
  1310.     public function deleteGroupCourse(Request $request)
  1311.     {
  1312.         $this->requestUtil->setRequest($request)->setData();
  1313.        
  1314.         $groupId = (int)$request->get('id');
  1315.         $group $this->repository->findOneBy([
  1316.             "id" => $groupId,
  1317.             "deleted" => GroupEnum::ITEM_NO_DELETED
  1318.         ]);
  1319.         
  1320.         if (!$group) {
  1321.             return $this->eadResponse(['id'], ErrorEnum::NOT_FOUNDErrorEnum::MESSAGE_NOT_FOUND);
  1322.         }
  1323.         
  1324.         $courseId = (int)$request->get('curso');
  1325.         $course $this->em->getRepository(Course::class)->findOneBy([
  1326.             "id" => $courseId,
  1327.             "deleted" => GroupEnum::ITEM_NO_DELETED
  1328.         ]);
  1329.         
  1330.         if (!$course) {
  1331.             return $this->eadResponse(['curso'], ErrorEnum::NOT_FOUNDErrorEnum::MESSAGE_NOT_FOUND);
  1332.         }
  1333.        
  1334.         $deleteEnrollment = (int)$request->get('excluir_matriculas');
  1335.         
  1336.         if($deleteEnrollment == GroupEnum::YES){
  1337.             $enrollments $this->em->getRepository(Enrollment::class)->getEnrollmentsByGroup($groupIdnullnull$courseId);
  1338.             foreach ($enrollments as $key => $enrollment) {
  1339.                 $this->em->getRepository(Enrollment::class)->delete($enrollmentTrashEnum::ENROLLMENTUserPermissionEnum::HIGHfalse);
  1340.             }
  1341.         }
  1342.         $group->removeCourse($course);
  1343.         $this->em->flush();
  1344.         $this->userLogService->logDelete("group_x_course"$groupIdnullUserLogEnum::ORIGIN_CLIENT_API);
  1345.         return $this->eadResponse(nullErrorEnum::SUCCESSErrorEnum::MESSAGE_SUCCESS);
  1346.     }
  1347. }