105 lines
3.9 KiB
PHP
105 lines
3.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Request;
|
|
|
|
use App\Constants\HttpEnumCode;
|
|
use Hyperf\Validation\Request\FormRequest;
|
|
use Hyperf\Validation\Rule;
|
|
|
|
class UserDoctorRequest extends FormRequest
|
|
{
|
|
protected array $scenes = [
|
|
'getInquiryConfig' => [ // 获取医生问诊配置
|
|
'inquiry_type',
|
|
'inquiry_mode',
|
|
],
|
|
'putInquiryOpen' => [ // 医生问诊开关
|
|
'inquiry_type',
|
|
'inquiry_mode',
|
|
'is_open',
|
|
],
|
|
'putInquiryConfig' => [ // 修改医生问诊配置
|
|
'inquiry_type',
|
|
'inquiry_mode',
|
|
'inquiry_price',
|
|
'work_num_day',
|
|
],
|
|
'addDoctorBankCard' => [ // 新增绑定医生银行卡
|
|
'bank_id',
|
|
'bank_card_code',
|
|
'province_id',
|
|
'city_id',
|
|
'county_id',
|
|
],
|
|
'putDoctorBankCard' => [ // 更换医生银行卡
|
|
'bank_id',
|
|
'bank_card_code',
|
|
'province_id',
|
|
'city_id',
|
|
'county_id',
|
|
],
|
|
];
|
|
|
|
/**
|
|
* 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 [
|
|
'inquiry_type' => 'required|integer|min:1|max:3',
|
|
'inquiry_mode' => 'required|integer|min:1|max:5',
|
|
'is_open' => "required|boolean",
|
|
'inquiry_price' => "required|min:0|numeric",
|
|
'work_num_day' => "required|min:0|numeric",
|
|
'bank_id' => "required",
|
|
'bank_card_code' => ['required','regex:/^(62|622)[0-9]{13,16}$/'],
|
|
'province_id' => 'required|required_with:city_id,county_id',
|
|
'city_id' => 'required|required_with:county_id',
|
|
'county_id' => 'required',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 获取已定义验证规则的错误消息.
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'inquiry_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'inquiry_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'inquiry_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'inquiry_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'is_open.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'is_open.boolean' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'inquiry_price.required' => "请填写价格",
|
|
'inquiry_price.min' => "价格填写错误",
|
|
'inquiry_price.numeric' => "价格填写错误",
|
|
'inquiry_mode.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'inquiry_mode.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'inquiry_mode.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'work_num_day.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'work_num_day.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'work_num_day.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
|
|
'bank_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'bank_card_code.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'bank_card_code.regex' => "银行卡号填写错误",
|
|
'province_id.required_with' => "请选择省份",
|
|
'province_id.required' => "请选择省份",
|
|
'city_id.required_with' => "请选择城市",
|
|
'city_id.required' => "请选择城市",
|
|
'county_id.required' => "请选择区县",
|
|
];
|
|
}
|
|
}
|