<?php

declare(strict_types=1);

namespace App\Request;

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

class DoctorAuthRequest extends FormRequest
{
    protected array $scenes = [
        'addAuthReal' => [ // 新增实名认证
            'card_name',
            'card_num'
        ],
        'getAuthIden' => [ // 获取身份认证信息
            'source',// 来源（1:身份认证 2:简介）
        ],
        'addAuthIden' => [ // 新增身份认证信息
            'avatar',
            'hospital_id',
            'department_custom_id',
            'department_custom_name',
            'department_custom_mobile',
            'doctor_title',
            'brief_introduction',
            'be_good_at',
//            'license_cert',
//            'qualification_cert',
//            'work_cert',
            'doctor_expertise',
            'source',
        ],
        'addAuthMulti' => [ // 新增多点执业认证信息
            'id_card_front',
            'id_card_back',
            'sign_image'
        ],
    ];

    /**
     * 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 [
            'card_name' => 'required',
            'card_num' => 'required',
            'avatar' => 'required|url',
            'hospital_id' => 'required',
            'department_custom_id' => 'required',
            'department_custom_mobile' => 'required',
            'doctor_title' => 'required|min:1|max:4',
            'brief_introduction' => 'required',
            'be_good_at' => 'required',
            'license_cert' => 'required|array|min:1',
            'qualification_cert' => 'required|array|min:1',
            'work_cert' => 'required|array|min:1',
            'doctor_expertise' => 'required|array|min:1',
            'id_card_front' => 'required|url',
            'id_card_back' => 'required|url',
            'sign_image' => 'required|url',
            'source' => 'required|integer|min:1|max:2',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息.
     */
    public function messages(): array
    {
        return [
            'card_name.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'card_num.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'avatar.required' => "请上传头像",
            'avatar.url' => "头像错误",
            'hospital_id.required' => "请选择医院",
            'department_custom_id.required' => "请选择科室",
            'department_custom_mobile.required' => "请输入科室电话",
            'doctor_title.required' => "请选择职称",
            'doctor_title.min' => "职称错误",
            'doctor_title.max' => "职称错误",
            'brief_introduction.required' => "请填写个人简介",
            'be_good_at.required' => "请填写擅长领域",
            'license_cert.required' => "请上传医师执业证",
            'license_cert.array' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'qualification_cert.required' => "请上传医师资格证",
            'qualification_cert.array' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'work_cert.required' => "请上传职称证",
            'work_cert.array' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'doctor_expertise.required' => "请选择专长",
            'doctor_expertise.array' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'id_card_front.required' => "请上传身份证正面",
            'id_card_front.url' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'id_card_back.required' => "请上传身份证反面",
            'id_card_back.url' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'sign_image.required' => "请上传签名",
            'sign_image.url' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),

            'source.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'source.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'source.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'source.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
        ];
    }
}
