Files
xuetang/server/app/adminapi/validate/tcm/PrescriptionLibraryValidate.php
T
2026-09-08 11:40:15 +08:00

109 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
namespace app\adminapi\validate\tcm;
use app\common\validate\BaseValidate;
/**
* 处方库验证器
*/
class PrescriptionLibraryValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|number',
'prescription_name' => 'require|max:100',
'formula_type' => 'in:主方,辅方',
'herbs' => 'require|array',
'is_public' => 'in:0,1',
'disable_edit' => 'in:0,1',
'report_id' => 'require|number|gt:0',
'content' => 'require|max:12000',
'limit' => 'integer|between:1,500'
];
protected $message = [
'id.require' => '处方ID不能为空',
'id.number' => '处方ID必须为数字',
'prescription_name.require' => '处方名称不能为空',
'prescription_name.max' => '处方名称最多100个字符',
'formula_type.in' => '处方类型只能是主方或辅方',
'herbs.require' => '药材列表不能为空',
'herbs.array' => '药材列表格式错误',
'is_public.in' => '是否公开参数错误',
'disable_edit.in' => '禁用修改参数错误',
'report_id.require' => '报告ID不能为空',
'report_id.number' => '报告ID必须为数字',
'report_id.gt' => '报告ID必须大于0',
'content.require' => '报告内容不能为空',
'content.max' => '报告内容最多12000个字符',
'limit.integer' => '数量限制必须为整数',
'limit.between' => '数量限制必须在1到500之间'
];
/**
* @notes 添加场景
*/
public function sceneAdd()
{
return $this->only(['prescription_name', 'formula_type', 'herbs', 'is_public', 'disable_edit']);
}
/**
* @notes 编辑场景
*/
public function sceneEdit()
{
return $this->only(['id', 'prescription_name', 'formula_type', 'herbs', 'is_public', 'disable_edit']);
}
/**
* @notes 删除场景
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
*/
public function sceneDetail()
{
return $this->only(['id']);
}
/**
* @notes 读取已保存的处方 AI 解释
*/
public function sceneAiReports()
{
return $this->only(['id']);
}
/**
* @notes 查询尚无任何 AI 报告的处方
*/
public function sceneMissingAiReports()
{
return $this->only(['limit']);
}
/**
* @notes 重新生成全部固定模型的处方 AI 解释
*/
public function sceneGenerateAiReports()
{
return $this->only(['id']);
}
/**
* @notes 编辑一份已保存的处方 AI 解释
*/
public function sceneEditAiReport()
{
return $this->only(['id', 'report_id', 'content']);
}
}