feat: [demo] 데모 테넌트 관리 API 및 만료 알림 (Phase 3)
- DemoTenantController: 목록/상세/생성/리셋/연장/전환/통계 API - DemoTenantStoreRequest: 고객 체험 테넌트 생성 검증 - DemoTenantService: API용 메서드 추가 (index/show/reset/extend/convert/stats) - CheckDemoExpiredCommand: 만료 임박(7일) 알림 + 만료 테넌트 비활성 처리 - 라우트 등록 (api/v1/demo-tenants, 7개 엔드포인트) - 스케줄러 등록 (04:20 demo:check-expired) - i18n 메시지 추가 (message.demo_tenant.*, error.demo_tenant.*)
This commit is contained in:
95
app/Http/Controllers/Api/V1/DemoTenantController.php
Normal file
95
app/Http/Controllers/Api/V1/DemoTenantController.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Demo\DemoTenantStoreRequest;
|
||||
use App\Services\Demo\DemoTenantService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* 데모 테넌트 관리 API 컨트롤러
|
||||
*
|
||||
* 파트너가 고객 체험 테넌트를 생성/관리하는 엔드포인트
|
||||
*
|
||||
* 기존 코드 영향 없음: 데모 전용 라우트에서만 사용
|
||||
*
|
||||
* @see docs/features/sales/demo-tenant-policy.md
|
||||
*/
|
||||
class DemoTenantController extends Controller
|
||||
{
|
||||
public function __construct(private DemoTenantService $service) {}
|
||||
|
||||
/**
|
||||
* 내가 생성한 데모 테넌트 목록
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->index($request->all());
|
||||
}, __('message.demo_tenant.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 데모 테넌트 상세 조회
|
||||
*/
|
||||
public function show(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->service->show($id);
|
||||
}, __('message.demo_tenant.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 고객 체험 테넌트 생성 (Tier 3)
|
||||
*/
|
||||
public function store(DemoTenantStoreRequest $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->createTrialFromApi($request->validated());
|
||||
}, __('message.demo_tenant.created'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 데모 데이터 리셋
|
||||
*/
|
||||
public function reset(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->service->resetFromApi($id);
|
||||
}, __('message.demo_tenant.reset'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 체험 기간 연장
|
||||
*/
|
||||
public function extend(int $id, Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id, $request) {
|
||||
$days = (int) $request->input('days', 30);
|
||||
|
||||
return $this->service->extendFromApi($id, $days);
|
||||
}, __('message.demo_tenant.extended'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 데모 → 정식 전환
|
||||
*/
|
||||
public function convert(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->service->convertFromApi($id);
|
||||
}, __('message.demo_tenant.converted'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 데모 현황 통계
|
||||
*/
|
||||
public function stats()
|
||||
{
|
||||
return ApiResponse::handle(function () {
|
||||
return $this->service->stats();
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user