<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| 智慧社区 API 路由
|--------------------------------------------------------------------------
|
| 依据《智慧社区建设指南》和《物业管理条例》，
| 提供居民信息管理、房屋管理、报修服务、投诉建议、
| 社区活动、邻里互助、物业缴费、公告通知等 API。
|
| 所有路由受 kylin.security 安全响应头中间件保护，
| 敏感操作（增删改）需额外通过 RBAC 权限校验。
|*/

Route::prefix('api/community')->middleware(['api', 'kylin.security'])->group(function () {

    // 居民信息管理
    Route::apiResource('residents', \Kylin\Community\Http\Controllers\ResidentController::class);

    // 房屋管理
    Route::apiResource('houses', \Kylin\Community\Http\Controllers\HouseController::class);

    // 报修服务
    Route::apiResource('repairs', \Kylin\Community\Http\Controllers\RepairController::class);
    Route::post('repairs/{repair}/assign', [\Kylin\Community\Http\Controllers\RepairController::class, 'assign'])
        ->name('repairs.assign');

    // 投诉建议
    Route::apiResource('complaints', \Kylin\Community\Http\Controllers\ComplaintController::class);
    Route::post('complaints/{complaint}/reply', [\Kylin\Community\Http\Controllers\ComplaintController::class, 'reply'])
        ->name('complaints.reply');

    // 社区活动
    Route::apiResource('activities', \Kylin\Community\Http\Controllers\ActivityController::class);
    Route::post('activities/{activity}/sign-up', [\Kylin\Community\Http\Controllers\ActivityController::class, 'signUp'])
        ->name('activities.sign-up');
    Route::post('activities/{activity}/sign-in', [\Kylin\Community\Http\Controllers\ActivityController::class, 'signIn'])
        ->name('activities.sign-in');

    // 邻里互助
    Route::apiResource('helps', \Kylin\Community\Http\Controllers\HelpController::class);
    Route::post('helps/{help}/take', [\Kylin\Community\Http\Controllers\HelpController::class, 'take'])
        ->name('helps.take');

    // 物业缴费
    Route::apiResource('payments', \Kylin\Community\Http\Controllers\PaymentController::class);
    Route::post('payments/{payment}/pay', [\Kylin\Community\Http\Controllers\PaymentController::class, 'pay'])
        ->name('payments.pay');

    // 公告通知
    Route::apiResource('notices', \Kylin\Community\Http\Controllers\NoticeController::class);
    Route::post('notices/{notice}/read', [\Kylin\Community\Http\Controllers\NoticeController::class, 'markRead'])
        ->name('notices.read');
});