Repo Interface für tests
This commit is contained in:
@@ -5,7 +5,7 @@ namespace MintyPHP\Repository\Org;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class DepartmentRepository
|
||||
class DepartmentRepository implements DepartmentRepositoryInterface
|
||||
{
|
||||
private function unwrap(?array $row): ?array
|
||||
{
|
||||
@@ -284,7 +284,7 @@ class DepartmentRepository
|
||||
return $count ? (int) $count : 0;
|
||||
}
|
||||
|
||||
public function create(array $data)
|
||||
public function create(array $data): mixed
|
||||
{
|
||||
return DB::insert(
|
||||
'insert into departments (uuid, description, tenant_id, code, cost_center, active, created_by, created) values (?,?,?,?,?,?,?,NOW())',
|
||||
|
||||
36
lib/Repository/Org/DepartmentRepositoryInterface.php
Normal file
36
lib/Repository/Org/DepartmentRepositoryInterface.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Org;
|
||||
|
||||
interface DepartmentRepositoryInterface
|
||||
{
|
||||
public function list(): array;
|
||||
|
||||
public function listIds(): array;
|
||||
|
||||
public function listActiveIdsByTenantIds(array $tenantIds): array;
|
||||
|
||||
public function listByTenantIds(array $tenantIds): array;
|
||||
|
||||
public function listByIds(array $departmentIds, bool $includeInactive = false): array;
|
||||
|
||||
public function listPaged(array $options): array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function findByUuid(string $uuid): ?array;
|
||||
|
||||
public function existsByCode(string $code, int $excludeId = 0): bool;
|
||||
|
||||
public function existsByTenantAndDescription(int $tenantId, string $description, int $excludeId = 0): bool;
|
||||
|
||||
public function countByTenantId(int $tenantId): int;
|
||||
|
||||
public function create(array $data): mixed;
|
||||
|
||||
public function update(int $id, array $data): bool;
|
||||
|
||||
public function setTenant(int $id, int $tenantId): bool;
|
||||
|
||||
public function delete(int $id): bool;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Org;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class UserDepartmentRepository
|
||||
class UserDepartmentRepository implements UserDepartmentRepositoryInterface
|
||||
{
|
||||
public function listDepartmentIdsByUserId(int $userId): array
|
||||
{
|
||||
|
||||
16
lib/Repository/Org/UserDepartmentRepositoryInterface.php
Normal file
16
lib/Repository/Org/UserDepartmentRepositoryInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Org;
|
||||
|
||||
interface UserDepartmentRepositoryInterface
|
||||
{
|
||||
public function listDepartmentIdsByUserId(int $userId): array;
|
||||
|
||||
public function replaceForUser(int $userId, array $departmentIds): bool;
|
||||
|
||||
public function removeInvalidForDepartment(int $departmentId): int;
|
||||
|
||||
public function countUsersByDepartmentIds(array $departmentIds): array;
|
||||
|
||||
public function countActiveUsersByDepartmentIds(array $departmentIds): array;
|
||||
}
|
||||
Reference in New Issue
Block a user