更新
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\setting;
|
||||
|
||||
use app\adminapi\logic\setting\DesktopWorkstationLogic;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class DesktopWorkstationValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'enabled' => 'in:0,1|checkEnabledRequiresVersion',
|
||||
'force_update' => 'in:0,1',
|
||||
'latest_version' => 'max:20|checkVersion',
|
||||
'min_version' => 'max:20|checkVersion',
|
||||
'title' => 'max:80',
|
||||
'notes' => 'max:4000',
|
||||
'packages' => 'checkPackages',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'enabled.in' => '启用状态不正确',
|
||||
'force_update.in' => '强制升级开关不正确',
|
||||
'latest_version.max' => '最新版本号过长',
|
||||
'min_version.max' => '最低版本号过长',
|
||||
'title.max' => '更新标题最多 80 个字符',
|
||||
'notes.max' => '更新说明最多 4000 个字符',
|
||||
'packages.array' => '安装包配置格式不正确',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function checkVersion($value)
|
||||
{
|
||||
$value = trim((string) $value);
|
||||
if ($value === '') {
|
||||
return true;
|
||||
}
|
||||
if (DesktopWorkstationLogic::normalizeVersion($value) === '') {
|
||||
return '版本号须为 x.y.z 数字格式,例如 0.2.0';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param mixed $rule
|
||||
* @param array $data
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function checkEnabledRequiresVersion($value, $rule, array $data = [])
|
||||
{
|
||||
unset($rule);
|
||||
$enabled = in_array((string) $value, ['1', 'true'], true);
|
||||
$latest = trim((string) ($data['latest_version'] ?? ''));
|
||||
if ($enabled && $latest === '') {
|
||||
return '启用自动检测时请填写最新版本号';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param mixed $rule
|
||||
* @param array $data
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function checkPackages($value, $rule, array $data = [])
|
||||
{
|
||||
unset($rule);
|
||||
$enabled = (string) ($data['enabled'] ?? '0');
|
||||
$latest = trim((string) ($data['latest_version'] ?? ''));
|
||||
if (in_array($enabled, ['1', 'true'], true) && $latest === '') {
|
||||
return '启用自动检测时请填写最新版本号';
|
||||
}
|
||||
if ($value === '' || $value === null) {
|
||||
return true;
|
||||
}
|
||||
if (!is_array($value)) {
|
||||
return '安装包配置格式不正确';
|
||||
}
|
||||
foreach (DesktopWorkstationLogic::PLATFORMS as $key) {
|
||||
$row = $value[$key] ?? [];
|
||||
if ($row === '' || $row === null) {
|
||||
continue;
|
||||
}
|
||||
if (!is_array($row)) {
|
||||
return '安装包配置格式不正确';
|
||||
}
|
||||
$error = $this->checkPackageRow($key, $row, $data);
|
||||
if ($error !== true) {
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $row
|
||||
* @param array<string, mixed> $data
|
||||
* @return bool|string
|
||||
*/
|
||||
private function checkPackageRow(string $key, array $row, array $data)
|
||||
{
|
||||
unset($data);
|
||||
$url = trim((string) ($row['url'] ?? ''));
|
||||
$sha256 = strtolower(trim((string) ($row['sha256'] ?? '')));
|
||||
$filename = trim((string) ($row['filename'] ?? ''));
|
||||
$size = $row['size'] ?? 0;
|
||||
$labels = [
|
||||
'windows_x64' => 'Windows 64 位',
|
||||
'macos_arm64' => 'macOS Apple 芯片',
|
||||
'macos_x64' => 'macOS Intel',
|
||||
];
|
||||
$label = $labels[$key] ?? $key;
|
||||
if ($url !== '' && !$this->isAllowedPackageUrl($url)) {
|
||||
return $label . '安装包地址必须是 http(s) 链接或站内 uploads 路径';
|
||||
}
|
||||
if ($sha256 !== '' && !preg_match('/^[a-f0-9]{64}$/', $sha256)) {
|
||||
return $label . ' SHA-256 须为 64 位十六进制';
|
||||
}
|
||||
if ($url !== '' && $sha256 === '' && preg_match('#^https?://#i', $url)) {
|
||||
return $label . '使用外部下载地址时必须填写 SHA-256,避免安装被篡改的文件';
|
||||
}
|
||||
if ($filename !== '' && strlen($filename) > 180) {
|
||||
return $label . '文件名过长';
|
||||
}
|
||||
if ($size !== '' && $size !== null && (!is_numeric($size) || (int) $size < 0)) {
|
||||
return $label . '文件大小不正确';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function isAllowedPackageUrl(string $url): bool
|
||||
{
|
||||
if (preg_match('#^https?://#i', $url)) {
|
||||
return filter_var($url, FILTER_VALIDATE_URL) !== false;
|
||||
}
|
||||
return (bool) preg_match('#^(uploads|resource)/#', str_replace('\\', '/', $url));
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class DiagnosisValidate extends BaseValidate
|
||||
'revisit_slot_start_offset' => 'integer|between:0,20',
|
||||
'report_id' => 'number|gt:0',
|
||||
'content' => 'max:12000',
|
||||
'task' => 'require|in:summary,tcm_pattern,prescription_review,medication_review,exam_review,complication_risk,guideline_review,custom',
|
||||
'task' => 'require|in:summary,tcm_pattern,prescription_review,prescription_generate,medication_review,exam_review,complication_risk,guideline_review,custom',
|
||||
'prompt' => 'max:500',
|
||||
'model' => 'in:qwen,openai',
|
||||
'patient_id' => 'integer|gt:0',
|
||||
|
||||
@@ -14,10 +14,12 @@ class PrescriptionValidate extends BaseValidate
|
||||
'appointment_id' => 'number',
|
||||
'dosage_bag_count' => 'integer|between:1,5',
|
||||
'patient_name' => 'require',
|
||||
'phone' => 'require|max:20',
|
||||
'phone' => 'max:20',
|
||||
'gender' => 'require|in:0,1',
|
||||
'clinical_diagnosis' => 'require',
|
||||
'herbs' => 'require|array',
|
||||
'doctor_name' => 'require|max:100',
|
||||
'doctor_signature' => 'require',
|
||||
'action' => 'require|in:approve,reject',
|
||||
'remark' => 'max:500',
|
||||
];
|
||||
@@ -26,24 +28,25 @@ class PrescriptionValidate extends BaseValidate
|
||||
'dosage_bag_count.integer' => '用量袋数必须为整数',
|
||||
'dosage_bag_count.between' => '用量袋数必须在1到5袋之间',
|
||||
'patient_name.require' => '患者姓名不能为空',
|
||||
'phone.require' => '手机号不能为空',
|
||||
'phone.max' => '手机号过长',
|
||||
'gender.require' => '请选择性别',
|
||||
'gender.in' => '性别无效',
|
||||
'clinical_diagnosis.require' => '临床诊断不能为空',
|
||||
'herbs.require' => '请添加中药',
|
||||
'doctor_name.require' => '医师姓名不能为空',
|
||||
'doctor_signature.require' => '请完成医师签名',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only([
|
||||
'prescription_type', 'dosage_amount', 'dosage_unit', 'dosage_bag_count', 'need_decoction', 'bags_per_dose',
|
||||
'patient_name', 'gender', 'age',
|
||||
'prescription_name', 'patient_id', 'patient_name', 'phone', 'gender', 'age',
|
||||
'visit_no', 'prescription_date', 'tongue', 'tongue_image', 'pulse',
|
||||
'pulse_condition', 'clinical_diagnosis', 'herbs', 'dose_count', 'dose_unit',
|
||||
'usage_days', 'times_per_day', 'aux_usage', 'usage_instruction', 'usage_time', 'usage_way', 'dietary_taboo',
|
||||
'usage_notes', 'doctor_name', 'is_shared', 'visible_role_ids',
|
||||
'diagnosis_id', 'appointment_id', 'audit_status',
|
||||
'usage_notes', 'doctor_name', 'doctor_signature', 'is_shared', 'visible_role_ids',
|
||||
'diagnosis_id', 'appointment_id', 'case_record', 'audit_status',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -51,11 +54,11 @@ class PrescriptionValidate extends BaseValidate
|
||||
{
|
||||
return $this->only([
|
||||
'id', 'prescription_type', 'dosage_amount', 'dosage_unit', 'dosage_bag_count', 'need_decoction', 'bags_per_dose',
|
||||
'patient_name', 'gender', 'age',
|
||||
'prescription_name', 'patient_id', 'patient_name', 'phone', 'gender', 'age',
|
||||
'visit_no', 'prescription_date', 'tongue', 'tongue_image', 'pulse',
|
||||
'pulse_condition', 'clinical_diagnosis', 'herbs', 'dose_count', 'dose_unit',
|
||||
'usage_days', 'times_per_day', 'aux_usage', 'usage_instruction', 'usage_time', 'usage_way', 'dietary_taboo',
|
||||
'usage_notes', 'doctor_name', 'is_shared', 'visible_role_ids', 'diagnosis_id',
|
||||
'usage_notes', 'doctor_name', 'doctor_signature', 'is_shared', 'visible_role_ids', 'diagnosis_id',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user