UserSearchItem.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Custom\Search;
  4. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  5. use ApiPlatform\Metadata\ApiFilter;
  6. use ApiPlatform\Metadata\ApiResource;
  7. use ApiPlatform\Metadata\Get;
  8. use ApiPlatform\Metadata\GetCollection;
  9. use App\Filter\ApiPlatform\Utils\InFilter;
  10. use App\Repository\Custom\Search\UserSearchItemRepository;
  11. use Doctrine\ORM\Mapping as ORM;
  12. /**
  13. * Données réduites d'identification d'un utilisateur (ids, noms)
  14. * Utilisées entre autres pour les listes déroulantes de recherche.
  15. * TODO: revoir sécurité
  16. *
  17. * Fichier source de la view : ./sql/schema-extensions/003-view_search_user.sql
  18. */
  19. #[ApiResource(
  20. operations: [
  21. new Get(
  22. uriTemplate: '/search/users/{id}'
  23. ),
  24. new GetCollection(
  25. uriTemplate: '/search/users',
  26. paginationMaximumItemsPerPage: 10,
  27. paginationClientItemsPerPage: true,
  28. order: ['name' => 'ASC']
  29. ),
  30. ]
  31. )]
  32. #[ORM\Table(name: 'view_search_user')]
  33. #[ORM\Entity(repositoryClass: UserSearchItemRepository::class, readOnly: true)]
  34. #[ApiFilter(filterClass: InFilter::class, properties: ['id'])]
  35. #[ApiFilter(filterClass: SearchFilter::class, properties: ['fullname' => 'ipartial'])]
  36. class UserSearchItem
  37. {
  38. #[ORM\Id]
  39. #[ORM\Column]
  40. private int $id;
  41. #[ORM\Column(type: 'integer')]
  42. private ?int $organizationId = null;
  43. #[ORM\Column(type: 'integer')]
  44. private ?int $personId = null;
  45. #[ORM\Column(type: 'string')]
  46. private ?string $username = null;
  47. #[ORM\Column(type: 'string')]
  48. private ?string $name = null;
  49. #[ORM\Column(type: 'string')]
  50. private ?string $givenName = null;
  51. #[ORM\Column(type: 'string')]
  52. private ?string $fullName = null;
  53. public function getId(): int
  54. {
  55. return $this->id;
  56. }
  57. public function setId(int $id): self
  58. {
  59. $this->id = $id;
  60. return $this;
  61. }
  62. public function getOrganizationId(): ?int
  63. {
  64. return $this->organizationId;
  65. }
  66. public function setOrganizationId(?int $organizationId): self
  67. {
  68. $this->organizationId = $organizationId;
  69. return $this;
  70. }
  71. public function getPersonId(): ?int
  72. {
  73. return $this->personId;
  74. }
  75. public function setPersonId(?int $personId): self
  76. {
  77. $this->personId = $personId;
  78. return $this;
  79. }
  80. public function getUsername(): ?string
  81. {
  82. return $this->username;
  83. }
  84. public function setUsername(?string $username): self
  85. {
  86. $this->username = $username;
  87. return $this;
  88. }
  89. public function getName(): ?string
  90. {
  91. return $this->name;
  92. }
  93. public function setName(?string $name): self
  94. {
  95. $this->name = $name;
  96. return $this;
  97. }
  98. public function getGivenName(): ?string
  99. {
  100. return $this->givenName;
  101. }
  102. public function setGivenName(?string $givenName): self
  103. {
  104. $this->givenName = $givenName;
  105. return $this;
  106. }
  107. public function getFullName(): ?string
  108. {
  109. return $this->fullName;
  110. }
  111. public function setFullName(?string $fullName): self
  112. {
  113. $this->fullName = $fullName;
  114. return $this;
  115. }
  116. }