<?php

declare(strict_types=1);

namespace App\Request;

use App\Constants\HttpEnumCode;
use Hyperf\Validation\Request\FormRequest;

class BasicDataRequest extends FormRequest
{
    protected array $scenes = [
        'getHospital' => [ // 获取医院数据
            'province_id',
            'city_id',
            'county_id',
        ],
        'getDiseaseSearch' => [ // 搜索疾病分类
//            'disease_class_name',
        ],
        'getProductSearch' => [ // 搜索商品
            'product_keyword',
        ],
        'getDiseaseIcdSearch' => [ // 搜索平台疾病分类
            'icd_keyword',
        ],
    ];

    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'province_id' => 'required_with:city_id,county_id',
            'city_id' => 'required_with:county_id',
            'disease_class_name' => 'required',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息.
     */
    public function messages(): array
    {
        return [
            'province_id.required_with' => "请选择省份",
            'city_id.required_with' => "请选择城市",
            'disease_class_name.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
        ];
    }
}
