<?php

declare(strict_types=1);

namespace App\Request;

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

class UserPharmacistRequest extends FormRequest
{
    protected array $scenes = [
        'getPrescriptionList' => [ // 获取药师审核处方列表
            'pharmacist_audit_status',
            'platform_audit_status',
        ],
        'putOnOff' => [ // 设置上下线
            'is_online',
        ],
        'putPrescriptionVerify' => [ // 审核处方
            'pharmacist_audit_status',// 药师审核状态（0:审核中 1:审核成功 2:审核驳回）
            'pharmacist_fail_reason',// 药师审核驳回原因
        ],
    ];

    /**
     * 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 [
            'pharmacist_audit_status' => 'required|numeric|min:0|max:2',
            'platform_audit_status' => 'required|numeric|min:0|max:2',
            'is_online' => 'required|integer|min:0|max:1',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息.
     */
    public function messages(): array
    {
        return [
            'pharmacist_audit_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'pharmacist_audit_status.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'pharmacist_audit_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'pharmacist_audit_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'platform_audit_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'platform_audit_status.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'platform_audit_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'platform_audit_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_online.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_online.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_online.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_online.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
        ];
    }
}
