<?php

namespace Kylin\Region\Http\Controllers;

use Illuminate\Http\JsonResponse;
use Kylin\Core\ApiResponse;
use Kylin\Core\Controllers\BaseController;
use Kylin\Region\Services\RegionService;

/**
 * 区域控制器
 *
 * 提供省市区三级行政区划数据查询 API。
 */
class RegionController extends BaseController
{
    public function __construct(private readonly RegionService $service) {}

    public function provinces(): JsonResponse
    {
        return ApiResponse::success($this->service->getProvinces());
    }

    public function children(int $parentId): JsonResponse
    {
        return ApiResponse::success($this->service->getChildren($parentId));
    }

    public function tree(): JsonResponse
    {
        return ApiResponse::success($this->service->getTree());
    }
}
