Revert "fix: [tenant-console] 테넌트 콘솔 분리작업"
This reverts commit 8da1702e
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Helpers\TenantHelper;
|
||||
use App\Models\Boards\Board;
|
||||
use App\Models\Boards\BoardSetting;
|
||||
use App\Models\Tenants\Tenant;
|
||||
@@ -102,14 +101,9 @@ public function getBoardById(int $id, bool $withTrashed = false, bool $systemOnl
|
||||
*/
|
||||
public function createBoard(array $data): Board
|
||||
{
|
||||
// 테넌트 콘솔이면 테넌트 게시판, 아니면 시스템 게시판
|
||||
if (TenantHelper::isTenantConsole()) {
|
||||
$data['is_system'] = false;
|
||||
$data['tenant_id'] = TenantHelper::getEffectiveTenantId();
|
||||
} else {
|
||||
$data['is_system'] = true;
|
||||
$data['tenant_id'] = null;
|
||||
}
|
||||
// 시스템 게시판 설정
|
||||
$data['is_system'] = true;
|
||||
$data['tenant_id'] = null;
|
||||
$data['created_by'] = auth()->id();
|
||||
|
||||
$board = Board::create($data);
|
||||
@@ -289,15 +283,11 @@ public function reorderBoardFields(int $boardId, array $fieldIds): bool
|
||||
*/
|
||||
public function getBoardTypes(): array
|
||||
{
|
||||
$query = Board::query()->whereNotNull('board_type');
|
||||
|
||||
if (TenantHelper::isTenantConsole()) {
|
||||
$query->where('tenant_id', TenantHelper::getEffectiveTenantId());
|
||||
} else {
|
||||
$query->systemOnly();
|
||||
}
|
||||
|
||||
return $query->distinct()->pluck('board_type')->toArray();
|
||||
return Board::systemOnly()
|
||||
->whereNotNull('board_type')
|
||||
->distinct()
|
||||
->pluck('board_type')
|
||||
->toArray();
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
@@ -421,37 +411,28 @@ public function getAllBoards(array $filters = [], int $perPage = 15): LengthAwar
|
||||
->withCount(['fields', 'posts'])
|
||||
->withTrashed();
|
||||
|
||||
// 명시적 tenant_id 필터 (테넌트 콘솔 API 호출에서 전달)
|
||||
if (! empty($filters['tenant_id'])) {
|
||||
$query->where('tenant_id', $filters['tenant_id']);
|
||||
} elseif (TenantHelper::isTenantConsole()) {
|
||||
// 테넌트 콘솔인 경우: 해당 테넌트 게시판만
|
||||
$consoleTenantId = TenantHelper::getEffectiveTenantId();
|
||||
$query->where('tenant_id', $consoleTenantId);
|
||||
} else {
|
||||
// 메인 관리자: 헤더에서 선택한 테넌트 기준
|
||||
$selectedTenantId = TenantHelper::getRawTenantId();
|
||||
// 헤더에서 선택한 테넌트 기준
|
||||
$selectedTenantId = session('selected_tenant_id');
|
||||
|
||||
if ($selectedTenantId && $selectedTenantId !== 'all') {
|
||||
// 선택된 테넌트가 본사(HQ)인지 확인
|
||||
$isHQ = Tenant::where('id', $selectedTenantId)
|
||||
->where('tenant_type', 'HQ')
|
||||
->exists();
|
||||
if ($selectedTenantId && $selectedTenantId !== 'all') {
|
||||
// 선택된 테넌트가 본사(HQ)인지 확인
|
||||
$isHQ = Tenant::where('id', $selectedTenantId)
|
||||
->where('tenant_type', 'HQ')
|
||||
->exists();
|
||||
|
||||
if ($isHQ) {
|
||||
// 본사: 시스템 게시판 + 본사 테넌트 게시판
|
||||
$query->where(function ($q) use ($selectedTenantId) {
|
||||
$q->where('is_system', true)
|
||||
->orWhere('tenant_id', $selectedTenantId);
|
||||
});
|
||||
} else {
|
||||
// 일반 테넌트: 해당 테넌트 게시판만 (시스템 게시판 제외)
|
||||
$query->where('tenant_id', $selectedTenantId);
|
||||
}
|
||||
if ($isHQ) {
|
||||
// 본사: 시스템 게시판 + 본사 테넌트 게시판
|
||||
$query->where(function ($q) use ($selectedTenantId) {
|
||||
$q->where('is_system', true)
|
||||
->orWhere('tenant_id', $selectedTenantId);
|
||||
});
|
||||
} else {
|
||||
// 전체 보기: 시스템 게시판만 (테넌트 게시판은 테넌트 선택 후 표시)
|
||||
$query->where('is_system', true);
|
||||
// 일반 테넌트: 해당 테넌트 게시판만 (시스템 게시판 제외)
|
||||
$query->where('tenant_id', $selectedTenantId);
|
||||
}
|
||||
} else {
|
||||
// 전체 보기: 시스템 게시판만 (테넌트 게시판은 테넌트 선택 후 표시)
|
||||
$query->where('is_system', true);
|
||||
}
|
||||
|
||||
// 검색 필터
|
||||
|
||||
Reference in New Issue
Block a user