Added image loader
testing/ogcore-api/pipeline/head There was a failure building this commit Details

develop-jenkins
Manuel Aranda Rosales 2024-10-08 17:27:48 +02:00
parent 29a222bc96
commit 07b6f55310
3 changed files with 36 additions and 3 deletions

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Command; namespace App\Command;
use App\Entity\Client; use App\Entity\Client;
use App\Entity\Image;
use App\Entity\OrganizationalUnit; use App\Entity\OrganizationalUnit;
use App\Model\OrganizationalUnitTypes; use App\Model\OrganizationalUnitTypes;
use App\Model\UserGroupPermissions; use App\Model\UserGroupPermissions;
@ -100,6 +101,24 @@ class LoadOrganizationalUnitDefaultCommand extends Command
] ]
]; ];
$images = [
[
'name' => 'Imagen Test 1',
'type' => 'ISO',
'path' => '/path/to/imagen1.iso'
],
[
'name' => 'Imagen Test 2',
'type' => 'ISO',
'path' => '/path/to/imagen2.iso'
],
[
'name' => 'Imagen Test 3',
'type' => 'ISO',
'path' => '/path/to/imagen3.iso'
]
];
foreach ($organizationalUnits as $organizationalUnit) { foreach ($organizationalUnits as $organizationalUnit) {
$organizationalUnitEntity = new OrganizationalUnit(); $organizationalUnitEntity = new OrganizationalUnit();
@ -132,6 +151,16 @@ class LoadOrganizationalUnitDefaultCommand extends Command
$clientEntity->setMaintenance(false); $clientEntity->setMaintenance(false);
$clientEntity->setOrganizationalUnit($classroomEntity); $clientEntity->setOrganizationalUnit($classroomEntity);
$this->entityManager->persist($clientEntity); $this->entityManager->persist($clientEntity);
foreach ($images as $image) {
$imageEntity = new Image();
$imageEntity->setName($image['name']);
$imageEntity->setType($image['type']);
$imageEntity->setPath($image['path']);
$imageEntity->setOrganizationalUnit($organizationalUnitEntity);
$imageEntity->setClient($clientEntity);
$this->entityManager->persist($imageEntity);
}
} }
} }

View File

@ -67,10 +67,14 @@ class OrganizationalUnitController extends AbstractController
#[Route('/opengnsys/rest//ous/{centerId}/images', methods: ['GET'])] #[Route('/opengnsys/rest//ous/{centerId}/images', methods: ['GET'])]
public function getImages(Request $request, int $centerId): JsonResponse public function getImages(Request $request, int $centerId): JsonResponse
{ {
$parent = $this->entityManager
->getRepository(OrganizationalUnit::class)
->find($centerId);
$images = $this->entityManager $images = $this->entityManager
->getRepository(Image::class) ->getRepository(Image::class)
->findBy([ ->findBy([
'organizationalUnit' => $centerId, 'organizationalUnit' => $parent,
], ['name' => 'ASC']); ], ['name' => 'ASC']);
$data = []; $data = [];
@ -86,7 +90,7 @@ class OrganizationalUnitController extends AbstractController
} }
#[Route('/opengnsys/rest//info', methods: ['GET'])] #[Route('/opengnsys/rest//info', methods: ['GET'])]
public function getOpengnsysInfo(): JsonResponse public function getOpengnsysInfo(Request $request, int $centerId): JsonResponse
{ {
$data = [ $data = [
"project" => "OpenGnsys", "project" => "OpenGnsys",

View File

@ -709,7 +709,7 @@ final readonly class OpenApiFactory implements OpenApiFactoryInterface
{ {
$openApi->getPaths()->addPath('/opengnsys/rest//ous', (new Model\PathItem())->withGet( $openApi->getPaths()->addPath('/opengnsys/rest//ous', (new Model\PathItem())->withGet(
(new Model\Operation('getOUs')) (new Model\Operation('getOUs'))
->withTags(['Organizational Unit']) ->withTags(['UDS'])
->withSummary('Obtener todas las Unidades Organizacionales') ->withSummary('Obtener todas las Unidades Organizacionales')
->withResponses([ ->withResponses([
Response::HTTP_OK => [ Response::HTTP_OK => [