first commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\validate;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class FanValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'name' => 'require|length:1,50',
|
||||
'phone' => 'require|mobile',
|
||||
'id_card' => 'length:15,18',
|
||||
'age' => 'number|between:0,150',
|
||||
'gender' => 'in:0,1,2',
|
||||
'status' => 'in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'name.require' => '请输入姓名',
|
||||
'name.length' => '姓名长度须在1-50位字符',
|
||||
'phone.require' => '请输入手机号',
|
||||
'phone.mobile' => '手机号格式不正确',
|
||||
'id_card.length' => '身份证号长度不正确',
|
||||
'age.number' => '年龄必须为数字',
|
||||
'age.between' => '年龄范围0-150',
|
||||
'gender.in' => '性别参数错误',
|
||||
'status.in' => '状态参数错误',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'name', 'phone', 'id_card', 'age', 'gender', 'status']);
|
||||
}
|
||||
|
||||
public function sceneId()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\validate;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class FanVisitRecordValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'fan_id' => 'require',
|
||||
'visit_type' => 'require|in:1,2,3,4,5',
|
||||
'visit_time' => 'require',
|
||||
'content' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'fan_id.require' => '请选择粉丝',
|
||||
'visit_type.require' => '请选择回访类型',
|
||||
'visit_type.in' => '回访类型参数错误',
|
||||
'visit_time.require' => '请选择回访时间',
|
||||
'content.require' => '请输入回访内容',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'visit_type', 'visit_time', 'content', 'result', 'next_visit_time']);
|
||||
}
|
||||
|
||||
public function sceneId()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 文件验证
|
||||
* Class FileValidate
|
||||
* @package app\adminapi\validate
|
||||
*/
|
||||
class FileValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|number',
|
||||
'cid' => 'require|number',
|
||||
'ids' => 'require|array',
|
||||
'type' => 'require|in:10,20,30',
|
||||
'pid' => 'require|number',
|
||||
'name' => 'require|max:20'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少id参数',
|
||||
'cid.require' => '缺少cid参数',
|
||||
'ids.require' => '缺少ids参数',
|
||||
'type.require' => '缺少type参数',
|
||||
'pid.require' => '缺少pid参数',
|
||||
'name.require' => '请填写分组名称',
|
||||
'name.max' => '分组名称长度须为20字符内',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes id验证场景
|
||||
* @return FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:32
|
||||
*/
|
||||
public function sceneId()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 重命名文件场景
|
||||
* @return FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:32
|
||||
*/
|
||||
public function sceneRename()
|
||||
{
|
||||
return $this->only(['id', 'name']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 新增分类场景
|
||||
* @return FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:33
|
||||
*/
|
||||
public function sceneAddCate()
|
||||
{
|
||||
return $this->only(['type', 'pid', 'name']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑分类场景
|
||||
* @return FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:33
|
||||
*/
|
||||
public function sceneEditCate()
|
||||
{
|
||||
return $this->only(['id', 'name']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 移动场景
|
||||
* @return FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:33
|
||||
*/
|
||||
public function sceneMove()
|
||||
{
|
||||
return $this->only(['ids', 'cid']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return FileValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 14:35
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['ids']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\adminapi\validate;
|
||||
|
||||
|
||||
use app\common\enum\AdminTerminalEnum;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\cache\AdminAccountSafeCache;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\validate\BaseValidate;
|
||||
use think\facade\Config;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
* Class LoginValidate
|
||||
* @package app\adminapi\validate
|
||||
*/
|
||||
class LoginValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'terminal' => 'require|in:' . AdminTerminalEnum::PC . ',' . AdminTerminalEnum::MOBILE,
|
||||
'account' => 'require',
|
||||
'password' => 'require|password',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'account.require' => '请输入账号',
|
||||
'password.require' => '请输入密码'
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes @notes 密码验证
|
||||
* @param $password
|
||||
* @param $other
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/2 14:00
|
||||
*/
|
||||
public function password($password, $other, $data)
|
||||
{
|
||||
// 本地调试:免密登录开关。须同时满足 APP_DEBUG=1 + LOCAL_DEBUG.LOGIN_SKIP_PASSWORD=true,
|
||||
// 任一不满足都走原始密码校验。每次免密登录都会记一条 warning 日志,便于发现误开。
|
||||
if (self::isLocalDebugLoginBypassEnabled()) {
|
||||
$adminInfo = Admin::where('account', '=', $data['account'])
|
||||
->field(['password,disable'])
|
||||
->findOrEmpty();
|
||||
if ($adminInfo->isEmpty()) {
|
||||
return '账号不存在';
|
||||
}
|
||||
if ((int)($adminInfo['disable'] ?? 0) === 1) {
|
||||
return '账号已禁用';
|
||||
}
|
||||
Log::warning(sprintf(
|
||||
'[LOCAL_DEBUG] login bypass password: account=%s, ip=%s',
|
||||
(string)($data['account'] ?? ''),
|
||||
(string)request()->ip()
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 登录限制
|
||||
$config = [
|
||||
'login_restrictions' => ConfigService::get('admin_login', 'login_restrictions'),
|
||||
'password_error_times' => ConfigService::get('admin_login', 'password_error_times'),
|
||||
'limit_login_time' => ConfigService::get('admin_login', 'limit_login_time'),
|
||||
];
|
||||
|
||||
$adminAccountSafeCache = new AdminAccountSafeCache();
|
||||
if ($config['login_restrictions'] == 1) {
|
||||
$adminAccountSafeCache->count = $config['password_error_times'];
|
||||
$adminAccountSafeCache->minute = $config['limit_login_time'];
|
||||
}
|
||||
|
||||
//后台账号安全机制,连续输错后锁定,防止账号密码暴力破解
|
||||
if ($config['login_restrictions'] == 1 && !$adminAccountSafeCache->isSafe()) {
|
||||
return '密码连续' . $adminAccountSafeCache->count . '次输入错误,请' . $adminAccountSafeCache->minute . '分钟后重试';
|
||||
}
|
||||
|
||||
$adminInfo = Admin::where('account', '=', $data['account'])
|
||||
->field(['password,disable'])
|
||||
->findOrEmpty();
|
||||
|
||||
if ($adminInfo->isEmpty()) {
|
||||
return '账号不存在';
|
||||
}
|
||||
|
||||
if ($adminInfo['disable'] === 1) {
|
||||
return '账号已禁用';
|
||||
}
|
||||
|
||||
if (empty($adminInfo['password'])) {
|
||||
$adminAccountSafeCache->record();
|
||||
return '账号不存在';
|
||||
}
|
||||
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
if ($adminInfo['password'] !== create_password($password, $passwordSalt)) {
|
||||
$adminAccountSafeCache->record();
|
||||
return '密码错误';
|
||||
}
|
||||
|
||||
$adminAccountSafeCache->relieve();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否启用"本地调试免密登录"。
|
||||
*
|
||||
* 双重闸门:
|
||||
* 1. APP_DEBUG 必须为 true(即应用本身处于调试模式)
|
||||
* 2. LOCAL_DEBUG.LOGIN_SKIP_PASSWORD 必须显式为 true / 1 / yes / on
|
||||
*
|
||||
* 任何一条不满足都返回 false,强制走原始密码校验。这样即使误把
|
||||
* LOGIN_SKIP_PASSWORD 配进生产,只要 APP_DEBUG=0 仍然安全。
|
||||
*/
|
||||
private static function isLocalDebugLoginBypassEnabled(): bool
|
||||
{
|
||||
$appDebug = strtolower((string) env('app_debug', '0'));
|
||||
if (!in_array($appDebug, ['1', 'true', 'yes', 'on'], true)) {
|
||||
return false;
|
||||
}
|
||||
$flag = strtolower((string) env('local_debug.login_skip_password', ''));
|
||||
|
||||
return in_array($flag, ['1', 'true', 'yes', 'on'], true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\article;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\article\ArticleCate;
|
||||
use app\common\model\article\Article;
|
||||
|
||||
/**
|
||||
* 资讯分类管理验证
|
||||
* Class ArticleCateValidate
|
||||
* @package app\adminapi\validate\article
|
||||
*/
|
||||
class ArticleCateValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkArticleCate',
|
||||
'name' => 'require|length:1,90',
|
||||
'is_show' => 'require|in:0,1',
|
||||
'sort' => 'egt:0',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '资讯分类id不能为空',
|
||||
'name.require' => '资讯分类不能为空',
|
||||
'name.length' => '资讯分类长度须在1-90位字符',
|
||||
'sort.egt' => '排序值不正确',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return ArticleCateValidate
|
||||
* @author heshihu
|
||||
* @date 2022/2/10 15:11
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove(['id'])
|
||||
->remove('id', 'require|checkArticleCate');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return ArticleCateValidate
|
||||
* @author heshihu
|
||||
* @date 2022/2/21 17:55
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改状态场景
|
||||
* @return ArticleCateValidate
|
||||
* @author heshihu
|
||||
* @date 2022/2/21 18:02
|
||||
*/
|
||||
public function sceneStatus()
|
||||
{
|
||||
return $this->only(['id', 'is_show']);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取所有资讯分类场景
|
||||
* @return ArticleCateValidate
|
||||
* @author heshihu
|
||||
* @date 2022/2/15 10:05
|
||||
*/
|
||||
public function sceneSelect()
|
||||
{
|
||||
return $this->only(['type']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return ArticleCateValidate
|
||||
* @author heshihu
|
||||
* @date 2022/2/21 17:52
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id', 'checkDeleteArticleCate');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检查指定资讯分类是否存在
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author heshihu
|
||||
* @date 2022/2/10 15:10
|
||||
*/
|
||||
public function checkArticleCate($value)
|
||||
{
|
||||
$article_category = ArticleCate::findOrEmpty($value);
|
||||
if ($article_category->isEmpty()) {
|
||||
return '资讯分类不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除时验证该资讯分类是否已使用
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 14:45
|
||||
*/
|
||||
public function checkDeleteArticleCate($value)
|
||||
{
|
||||
$article = Article::where('cid', $value)->findOrEmpty();
|
||||
if (!$article->isEmpty()) {
|
||||
return '资讯分类已使用,请先删除绑定该资讯分类的资讯';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\article;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\article\Article;
|
||||
|
||||
/**
|
||||
* 资讯管理验证
|
||||
* Class ArticleValidate
|
||||
* @package app\adminapi\validate\article
|
||||
*/
|
||||
class ArticleValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkArticle',
|
||||
'title' => 'require|length:1,255',
|
||||
// 'image' => 'require',
|
||||
'cid' => 'require',
|
||||
'is_show' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '资讯id不能为空',
|
||||
'title.require' => '标题不能为空',
|
||||
'title.length' => '标题长度须在1-255位字符',
|
||||
// 'image.require' => '封面图必须存在',
|
||||
'cid.require' => '所属栏目必须存在',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return ArticleValidate
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 9:57
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove(['id'])
|
||||
->remove('id','require|checkArticle');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return ArticleValidate
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 10:15
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改状态场景
|
||||
* @return ArticleValidate
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 10:18
|
||||
*/
|
||||
public function sceneStatus()
|
||||
{
|
||||
return $this->only(['id', 'is_show']);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return ArticleValidate
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 10:17
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检查指定资讯是否存在
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author heshihu
|
||||
* @date 2022/2/22 10:11
|
||||
*/
|
||||
public function checkArticle($value)
|
||||
{
|
||||
$article = Article::findOrEmpty($value);
|
||||
if ($article->isEmpty()) {
|
||||
return '资讯不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\auth;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\auth\Admin;
|
||||
|
||||
/**
|
||||
* 管理员验证
|
||||
* Class AdminValidate
|
||||
* @package app\adminapi\validate\auth
|
||||
*/
|
||||
class AdminValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkAdmin',
|
||||
'account' => 'require|length:1,32|unique:'.Admin::class,
|
||||
'name' => 'require|length:1,16|unique:'.Admin::class,
|
||||
'password' => 'require|length:6,32|edit',
|
||||
'password_confirm' => 'requireWith:password|confirm',
|
||||
'role_id' => 'require',
|
||||
'disable' => 'require|in:0,1|checkAbleDisable',
|
||||
'multipoint_login' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '管理员id不能为空',
|
||||
'account.require' => '账号不能为空',
|
||||
'account.length' => '账号长度须在1-32位字符',
|
||||
'account.unique' => '账号已存在',
|
||||
'password.require' => '密码不能为空',
|
||||
'password.length' => '密码长度须在6-32位字符',
|
||||
'password_confirm.requireWith' => '确认密码不能为空',
|
||||
'password_confirm.confirm' => '两次输入的密码不一致',
|
||||
'name.require' => '名称不能为空',
|
||||
'name.length' => '名称须在1-16位字符',
|
||||
'name.unique' => '名称已存在',
|
||||
'role_id.require' => '请选择角色',
|
||||
'disable.require' => '请选择状态',
|
||||
'disable.in' => '状态值错误',
|
||||
'multipoint_login.require' => '请选择是否支持多处登录',
|
||||
'multipoint_login.in' => '多处登录状态值为误',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return AdminValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 15:46
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove(['password', 'edit'])
|
||||
->remove('id', true)
|
||||
->remove('disable', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return AdminValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 15:46
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return AdminValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 15:47
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->remove('password', 'require|length')
|
||||
->append('id', 'require|checkAdmin')
|
||||
->remove('role_id', 'require')
|
||||
->append('role_id', 'checkRole');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return AdminValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 15:47
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑情况下,检查是否填密码
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 10:19
|
||||
*/
|
||||
public function edit($value, $rule, $data)
|
||||
{
|
||||
if (empty($data['password']) && empty($data['password_confirm'])) {
|
||||
return true;
|
||||
}
|
||||
$len = strlen($value);
|
||||
if ($len < 6 || $len > 32) {
|
||||
return '密码长度须在6-32位字符';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检查指定管理员是否存在
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 10:19
|
||||
*/
|
||||
public function checkAdmin($value)
|
||||
{
|
||||
$admin = Admin::findOrEmpty($value);
|
||||
if ($admin->isEmpty()) {
|
||||
return '管理员不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 禁用校验
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/8/11 9:59
|
||||
*/
|
||||
public function checkAbleDisable($value, $rule, $data)
|
||||
{
|
||||
$admin = Admin::findOrEmpty($data['id']);
|
||||
if ($admin->isEmpty()) {
|
||||
return '管理员不存在';
|
||||
}
|
||||
|
||||
if ($value && $admin['root']) {
|
||||
return '超级管理员不允许被禁用';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 校验角色
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2023/9/6 16:58
|
||||
*/
|
||||
public function checkRole($value, $rule, $data)
|
||||
{
|
||||
$admin = Admin::findOrEmpty($data['id']);
|
||||
if ($admin->isEmpty()) {
|
||||
return '管理员不存在';
|
||||
}
|
||||
|
||||
if ($admin['root']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (empty($data['role_id'])) {
|
||||
return '请选择角色';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\auth;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\auth\{SystemRole,SystemMenu};
|
||||
|
||||
|
||||
/**
|
||||
* 系统菜单
|
||||
* Class SystemMenuValidate
|
||||
* @package app\adminapi\validate\auth
|
||||
*/
|
||||
class MenuValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'pid' => 'require|checkPid',
|
||||
'type' => 'require|in:M,C,A',
|
||||
'name' => 'require|length:1,30|checkUniqueName',
|
||||
'icon' => 'max:100',
|
||||
'sort' => 'require|egt:0',
|
||||
'perms' => 'max:100',
|
||||
'paths' => 'max:200',
|
||||
'component' => 'max:200',
|
||||
'selected' => 'max:200',
|
||||
'params' => 'max:200',
|
||||
'is_cache' => 'require|in:0,1',
|
||||
'is_show' => 'require|in:0,1',
|
||||
'is_disable' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'pid.require' => '请选择上级菜单',
|
||||
'type.require' => '请选择菜单类型',
|
||||
'type.in' => '菜单类型参数值错误',
|
||||
'name.require' => '请填写菜单名称',
|
||||
'name.length' => '菜单名称长度需为1~30个字符',
|
||||
'icon.max' => '图标名称不能超过100个字符',
|
||||
'sort.require' => '请填写排序',
|
||||
'sort.egt' => '排序值需大于或等于0',
|
||||
'perms.max' => '权限字符不能超过100个字符',
|
||||
'paths.max' => '路由地址不能超过200个字符',
|
||||
'component.max' => '组件路径不能超过200个字符',
|
||||
'selected.max' => '选中菜单路径不能超过200个字符',
|
||||
'params.max' => '路由参数不能超过200个字符',
|
||||
'is_cache.require' => '请选择缓存状态',
|
||||
'is_cache.in' => '缓存状态参数值错误',
|
||||
'is_show.require' => '请选择显示状态',
|
||||
'is_show.in' => '显示状态参数值错误',
|
||||
'is_disable.require' => '请选择菜单状态',
|
||||
'is_disable.in' => '菜单状态参数值错误',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return MenuValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/29 18:26
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return MenuValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/29 18:27
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return MenuValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/29 18:27
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id', 'checkAbleDelete');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新状态场景
|
||||
* @return MenuValidate
|
||||
* @author 段誉
|
||||
* @date 2022/7/6 17:04
|
||||
*/
|
||||
public function sceneStatus()
|
||||
{
|
||||
return $this->only(['id', 'is_disable']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验菜单名称是否已存在
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/6/29 18:24
|
||||
*/
|
||||
protected function checkUniqueName($value, $rule, $data)
|
||||
{
|
||||
if ($data['type'] != 'M') {
|
||||
return true;
|
||||
}
|
||||
$where[] = ['type', '=', $data['type']];
|
||||
$where[] = ['name', '=', $data['name']];
|
||||
|
||||
if (!empty($data['id'])) {
|
||||
$where[] = ['id', '<>', $data['id']];
|
||||
}
|
||||
|
||||
$check = SystemMenu::where($where)->findOrEmpty();
|
||||
|
||||
if (!$check->isEmpty()) {
|
||||
return '菜单名称已存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 是否有子级菜单
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/6/30 9:40
|
||||
*/
|
||||
protected function checkAbleDelete($value, $rule, $data)
|
||||
{
|
||||
$hasChild = SystemMenu::where(['pid' => $value])->findOrEmpty();
|
||||
if (!$hasChild->isEmpty()) {
|
||||
return '存在子菜单,不允许删除';
|
||||
}
|
||||
|
||||
// 已绑定角色菜单不可以删除
|
||||
$isBindRole = SystemRole::hasWhere('roleMenuIndex', ['menu_id' => $value])->findOrEmpty();
|
||||
if (!$isBindRole->isEmpty()) {
|
||||
return '已分配菜单不可删除';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验上级
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/6/30 9:51
|
||||
*/
|
||||
protected function checkPid($value, $rule, $data)
|
||||
{
|
||||
if (!empty($data['id']) && $data['id'] == $value) {
|
||||
return '上级菜单不能选择自己';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\auth;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\auth\{AdminRole, SystemRole, Admin};
|
||||
|
||||
/**
|
||||
* 角色验证器
|
||||
* Class RoleValidate
|
||||
* @package app\adminapi\validate\auth
|
||||
*/
|
||||
class RoleValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkRole',
|
||||
'name' => 'require|max:64|unique:' . SystemRole::class . ',name',
|
||||
'menu_id' => 'array',
|
||||
'data_scope' => 'in:1,2,3,4',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择角色',
|
||||
'name.require' => '请输入角色名称',
|
||||
'name.max' => '角色名称最长为16个字符',
|
||||
'name.unique' => '角色名称已存在',
|
||||
'menu_id.array' => '权限格式错误',
|
||||
'data_scope.in' => '数据范围取值不合法',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return RoleValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 15:47
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['name', 'menu_id', 'data_scope']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return RoleValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 15:47
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return RoleValidate
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 15:48
|
||||
*/
|
||||
public function sceneDel()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id', 'checkAdmin');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 验证角色是否存在
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 15:48
|
||||
*/
|
||||
public function checkRole($value, $rule, $data)
|
||||
{
|
||||
if (!SystemRole::find($value)) {
|
||||
return '角色不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 验证角色是否被使用
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2021/12/29 15:49
|
||||
*/
|
||||
public function checkAdmin($value, $rule, $data)
|
||||
{
|
||||
if (AdminRole::where(['role_id' => $value])->find()) {
|
||||
return '有管理员在使用该角色,不允许删除';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\auth;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\auth\Admin;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 编辑超级管理员验证
|
||||
* Class editSelfValidate
|
||||
* @package app\adminapi\validate\auth
|
||||
*/
|
||||
class editSelfValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'name' => 'require|length:1,16',
|
||||
'avatar' => 'require',
|
||||
'password' => 'length:6,32|checkPassword',
|
||||
'password_confirm' => 'requireWith:password|confirm',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'name.require' => '请填写名称',
|
||||
'name.length' => '名称须在1-16位字符',
|
||||
'avatar.require' => '请选择头像',
|
||||
'password_now.length' => '密码长度须在6-32位字符',
|
||||
'password_confirm.requireWith' => '确认密码不能为空',
|
||||
'password_confirm.confirm' => '两次输入的密码不一致',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验密码
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/4/8 17:40
|
||||
*/
|
||||
public function checkPassword($value, $rule, $data)
|
||||
{
|
||||
if (empty($data['password_old'])) {
|
||||
return '请填写当前密码';
|
||||
}
|
||||
|
||||
$admin = Admin::findOrEmpty($data['admin_id']);
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$oldPassword = create_password($data['password_old'], $passwordSalt);
|
||||
|
||||
if ($admin['password'] != $oldPassword) {
|
||||
return '当前密码错误';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\channel;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 小程序设置
|
||||
* Class MnpSettingsValidate
|
||||
* @package app\adminapi\validate\channel
|
||||
*/
|
||||
class MnpSettingsValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'app_id' => 'require',
|
||||
'app_secret' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'app_id.require' => '请填写AppID',
|
||||
'app_secret.require' => '请填写AppSecret',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\channel;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 微信公众号回复验证器
|
||||
* Class OfficialAccountReplyValidate
|
||||
* @package app\adminapi\validate\channel
|
||||
*/
|
||||
class OfficialAccountReplyValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|integer',
|
||||
'reply_type' => 'require|in:1,2,3',
|
||||
'name' => 'require',
|
||||
'content_type' => 'require|in:1',
|
||||
'content' => 'require',
|
||||
'status' => 'require|in:0,1',
|
||||
'keyword' => 'requireIf:reply_type,2',
|
||||
'matching_type' => 'requireIf:reply_type,2|in:1,2',
|
||||
'sort' => 'requireIf:reply_type,2',
|
||||
'reply_num' => 'requireIf:reply_type,2|in:1',
|
||||
'new_sort' => 'require|integer|egt:0',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'reply_type.require' => '请输入回复类型',
|
||||
'reply_type.in' => '回复类型状态值错误',
|
||||
'name.require' => '请输入规则名称',
|
||||
'content_type.require' => '请选择内容类型',
|
||||
'content_type.in' => '内容类型状态值有误',
|
||||
'content.require' => '请输入回复内容',
|
||||
'status.require' => '请选择启用状态',
|
||||
'status.in' => '启用状态值错误',
|
||||
'keyword.requireIf' => '请输入关键词',
|
||||
'matching_type.requireIf' => '请选择匹配类型',
|
||||
'matching_type.in' => '匹配类型状态值错误',
|
||||
'sort.requireIf' => '请输入排序值',
|
||||
'sort.integer' => '排序值须为整型',
|
||||
'sort.egt' => '排序值须大于或等于0',
|
||||
'reply_num.requireIf' => '请选择回复数量',
|
||||
'reply_num.in' => '回复数量状态值错误',
|
||||
'id.require' => '参数缺失',
|
||||
'id.integer' => '参数格式错误',
|
||||
'new_sort.require' => '请输入新排序值',
|
||||
'new_sort.integer' => '新排序值须为整型',
|
||||
'new_sort.egt' => '新排序值须大于或等于0',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'add' => ['reply_type', 'name', 'content_type', 'content', 'status', 'keyword', 'matching_type', 'sort', 'reply_num'],
|
||||
'detail' => ['id'],
|
||||
'delete' => ['id'],
|
||||
'sort' => ['id', 'new_sort'],
|
||||
'status' => ['id'],
|
||||
'edit' => ['id', 'reply_type', 'name', 'content_type', 'content', 'status','keyword', 'matching_type', 'sort', 'reply_num']
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\channel;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 公众号设置
|
||||
* Class OfficialAccountSettingValidate
|
||||
* @package app\adminapi\validate\channel
|
||||
*/
|
||||
class OfficialAccountSettingValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'app_id' => 'require',
|
||||
'app_secret' => 'require',
|
||||
'encryption_type' => 'require|in:1,2,3',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'app_id.require' => '请填写AppID',
|
||||
'app_secret.require' => '请填写AppSecret',
|
||||
'encryption_type.require' => '请选择消息加密方式',
|
||||
'encryption_type.in' => '消息加密方式状态值错误',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\validate\channel;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 开放平台验证
|
||||
* Class OpenSettingValidate
|
||||
* @package app\adminapi\validate\channel
|
||||
*/
|
||||
class OpenSettingValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'app_id' => 'require',
|
||||
'app_secret' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'app_id.require' => '请输入appId',
|
||||
'app_secret.require' => '请输入appSecret',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\validate\channel;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* H5设置验证器
|
||||
* Class HFiveSettingValidate
|
||||
* @package app\adminapi\validate\setting\h5
|
||||
*/
|
||||
class WebPageSettingValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'status' => 'require|in:0,1'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'status.require' => '请选择启用状态',
|
||||
'status.in' => '启用状态值有误',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\crontab;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
use Cron\CronExpression;
|
||||
|
||||
/**
|
||||
* 定时任务验证器
|
||||
* Class CrontabValidate
|
||||
* @package app\adminapi\validate\crontab
|
||||
*/
|
||||
class CrontabValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'name' => 'require',
|
||||
'type' => 'require|in:1',
|
||||
'command' => 'require',
|
||||
'status' => 'require|in:1,2,3',
|
||||
'expression' => 'require|checkExpression',
|
||||
'id' => 'require',
|
||||
'operate' => 'require'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.require' => '请输入定时任务名称',
|
||||
'type.require' => '请选择类型',
|
||||
'type.in' => '类型值错误',
|
||||
'command.require' => '请输入命令',
|
||||
'status.require' => '请选择状态',
|
||||
'status.in' => '状态值错误',
|
||||
'expression.require' => '请输入运行规则',
|
||||
'id.require' => '参数缺失',
|
||||
'operate.require' => '请选择操作',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加定时任务场景
|
||||
* @return CrontabValidate
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:39
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', 'require')->remove('operate', 'require');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 查看定时任务详情场景
|
||||
* @return CrontabValidate
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:39
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑定时任务
|
||||
* @return CrontabValidate
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:39
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->remove('operate', 'require');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除定时任务场景
|
||||
* @return CrontabValidate
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:40
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes CrontabValidate
|
||||
* @return CrontabValidate
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:40
|
||||
*/
|
||||
public function sceneOperate()
|
||||
{
|
||||
return $this->only(['id', 'operate']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取规则执行时间场景
|
||||
* @return CrontabValidate
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:40
|
||||
*/
|
||||
public function sceneExpression()
|
||||
{
|
||||
return $this->only(['expression']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验运行规则
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/3/29 14:40
|
||||
*/
|
||||
public function checkExpression($value, $rule, $data)
|
||||
{
|
||||
if (CronExpression::isValidExpression($value) === false) {
|
||||
return '定时任务运行规则错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\decorate;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 装修页面验证
|
||||
* Class DecoratePageValidate
|
||||
* @package app\adminapi\validate\decorate
|
||||
*/
|
||||
class DecoratePageValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'type' => 'require',
|
||||
'data' => 'require',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'type.require' => '装修类型参数缺失',
|
||||
'data.require' => '装修信息参数缺失',
|
||||
];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\dept;
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminDept;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 部门验证器
|
||||
* Class DeptValidate
|
||||
* @package app\adminapi\validate\dept
|
||||
*/
|
||||
class DeptValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|checkDept',
|
||||
'pid' => 'require|integer',
|
||||
'name' => 'require|length:1,30|checkDeptNameUnderParent',
|
||||
'status' => 'require|in:0,1',
|
||||
'sort' => 'egt:0',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'name.require' => '请填写部门名称',
|
||||
'name.length' => '部门名称长度须在1-30位字符',
|
||||
'name.checkDeptNameUnderParent' => '同级部门下名称已存在',
|
||||
'sort.egt' => '排序值不正确',
|
||||
'pid.require' => '请选择上级部门',
|
||||
'pid.integer' => '上级部门参数错误',
|
||||
'status.require' => '请选择部门状态',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return DeptValidate
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:16
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true)->append('pid', 'checkDept');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return DeptValidate
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:16
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return DeptValidate
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 18:42
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->append('pid', 'checkPid');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return DeptValidate
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:16
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->append('id', 'checkAbleDetele');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验部门
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:17
|
||||
*/
|
||||
public function checkDept($value)
|
||||
{
|
||||
$dept = Dept::findOrEmpty($value);
|
||||
if ($dept->isEmpty()) {
|
||||
return '部门不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同级(同一 pid)下部门名称不可重复;不同上级允许同名
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $rule
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public function checkDeptNameUnderParent($value, $rule, array $data = [])
|
||||
{
|
||||
$name = trim((string) $value);
|
||||
if ($name === '') {
|
||||
return true;
|
||||
}
|
||||
$pid = (int) ($data['pid'] ?? 0);
|
||||
$query = Dept::where(['name' => $name, 'pid' => $pid]);
|
||||
if (!empty($data['id'])) {
|
||||
$query->where('id', '<>', (int) $data['id']);
|
||||
}
|
||||
|
||||
return $query->count() === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验能否删除
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 14:22
|
||||
*/
|
||||
public function checkAbleDetele($value)
|
||||
{
|
||||
$hasLower = Dept::where(['pid' => $value])->findOrEmpty();
|
||||
if (!$hasLower->isEmpty()) {
|
||||
return '已关联下级部门,暂不可删除';
|
||||
}
|
||||
|
||||
$check = AdminDept::where(['dept_id' => $value])->findOrEmpty();
|
||||
if (!$check->isEmpty()) {
|
||||
return '已关联管理员,暂不可删除';
|
||||
}
|
||||
|
||||
$dept = Dept::findOrEmpty($value);
|
||||
if ($dept['pid'] == 0) {
|
||||
return '顶级部门不可删除';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 校验部门
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param array $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 18:41
|
||||
*/
|
||||
public function checkPid($value, $rule, $data = [])
|
||||
{
|
||||
// 当前编辑的部门id信息是否存在
|
||||
$dept = Dept::findOrEmpty($data['id']);
|
||||
if ($dept->isEmpty()) {
|
||||
return '当前部门信息缺失';
|
||||
}
|
||||
|
||||
// 顶级部门不校验上级部门id
|
||||
if ($dept['pid'] == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($data['id'] == $value) {
|
||||
return '上级部门不可是当前部门';
|
||||
}
|
||||
|
||||
$leaderDept = Dept::findOrEmpty($value);
|
||||
if ($leaderDept->isEmpty()) {
|
||||
return '部门不存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\dept;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminJobs;
|
||||
use app\common\model\dept\Jobs;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 岗位验证
|
||||
* Class JobsValidate
|
||||
* @package app\adminapi\validate\dept
|
||||
*/
|
||||
class JobsValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkJobs',
|
||||
'name' => 'require|unique:'.Jobs::class.'|length:1,50',
|
||||
'code' => 'require|unique:'.Jobs::class,
|
||||
'status' => 'require|in:0,1',
|
||||
'sort' => 'egt:0',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'name.require' => '请填写岗位名称',
|
||||
'name.length' => '岗位名称长度须在1-50位字符',
|
||||
'name.unique' => '岗位名称已存在',
|
||||
'code.require' => '请填写岗位编码',
|
||||
'code.unique' => '岗位编码已存在',
|
||||
'sort.egt' => '排序值不正确',
|
||||
'status.require' => '请选择岗位状态',
|
||||
'status.in' => '岗位状态值错误',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return JobsValidate
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 9:53
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return JobsValidate
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 9:53
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return JobsValidate
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 9:54
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->append('id', 'checkAbleDetele');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验岗位
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 9:55
|
||||
*/
|
||||
public function checkJobs($value)
|
||||
{
|
||||
$jobs = Jobs::findOrEmpty($value);
|
||||
if ($jobs->isEmpty()) {
|
||||
return '岗位不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验能否删除
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 14:22
|
||||
*/
|
||||
public function checkAbleDetele($value)
|
||||
{
|
||||
$check = AdminJobs::where(['jobs_id' => $value])->findOrEmpty();
|
||||
if (!$check->isEmpty()) {
|
||||
return '已关联管理员,暂不可删除';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\dict;
|
||||
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 字典数据验证
|
||||
* Class DictDataValidate
|
||||
* @package app\adminapi\validate\dict
|
||||
*/
|
||||
class DictDataValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|checkDictData',
|
||||
'name' => 'require|length:1,255',
|
||||
'value' => 'require',
|
||||
'type_id' => 'require|checkDictType',
|
||||
'status' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'name.require' => '请填写字典数据名称',
|
||||
'name.length' => '字典数据名称长度须在1-255位字符',
|
||||
'value.require' => '请填写字典数据值',
|
||||
'type_id.require' => '字典类型缺失',
|
||||
'status.require' => '请选择字典数据状态',
|
||||
'status.in' => '字典数据状态参数错误',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return DictDataValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:54
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes ID场景
|
||||
* @return DictDataValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:54
|
||||
*/
|
||||
public function sceneId()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return DictDataValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 18:36
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->remove('type_id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验字典数据
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:55
|
||||
*/
|
||||
protected function checkDictData($value)
|
||||
{
|
||||
$article = DictData::findOrEmpty($value);
|
||||
if ($article->isEmpty()) {
|
||||
return '字典数据不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验字典类型
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 17:03
|
||||
*/
|
||||
protected function checkDictType($value)
|
||||
{
|
||||
$type = DictType::findOrEmpty($value);
|
||||
if ($type->isEmpty()) {
|
||||
return '字典类型不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\dict;
|
||||
|
||||
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 字典类型验证
|
||||
* Class DictTypeValidate
|
||||
* @package app\adminapi\validate\dict
|
||||
*/
|
||||
class DictTypeValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|checkDictType',
|
||||
'name' => 'require|length:1,255',
|
||||
'type' => 'require|unique:' . DictType::class,
|
||||
'status' => 'require|in:0,1',
|
||||
'remark' => 'max:200',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'name.require' => '请填写字典名称',
|
||||
'name.length' => '字典名称长度须在1~255位字符',
|
||||
'type.require' => '请填写字典类型',
|
||||
'type.unique' => '字典类型已存在',
|
||||
'status.require' => '请选择状态',
|
||||
'remark.max' => '备注长度不能超过200',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return DictTypeValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:00
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return DictTypeValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:00
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return DictTypeValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:03
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id', 'checkAbleDelete');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检查字典类型是否存在
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:04
|
||||
*/
|
||||
protected function checkDictType($value)
|
||||
{
|
||||
$dictType = DictType::findOrEmpty($value);
|
||||
if ($dictType->isEmpty()) {
|
||||
return '字典类型不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 验证是否可删除
|
||||
* @param $value
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 16:04
|
||||
*/
|
||||
protected function checkAbleDelete($value)
|
||||
{
|
||||
$dictData = DictData::whereIn('type_id', $value)->select();
|
||||
|
||||
foreach ($dictData as $item) {
|
||||
if (!empty($item)) {
|
||||
return '字典类型已被使用,请先删除绑定该字典类型的数据';
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\validate\doctor;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 医生预约验证器
|
||||
* Class AppointmentValidate
|
||||
* @package app\adminapi\validate\doctor
|
||||
*/
|
||||
class AppointmentValidate extends BaseValidate
|
||||
{
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'patient_id' => 'require|integer',
|
||||
'doctor_id' => 'require|integer',
|
||||
'diagnosis_id' => 'require|integer',
|
||||
'appointment_date' => 'require|date',
|
||||
'appointment_time' => 'require',
|
||||
'period' => 'in:morning,afternoon,all',
|
||||
'appointment_type' => 'require|in:video,text,phone',
|
||||
'status' => 'require|integer|between:1,4',
|
||||
'remark' => 'max:500',
|
||||
'channel_source' => 'require',
|
||||
'channel_source_detail' => 'max:128',
|
||||
'ids' => 'require|array',
|
||||
'note_id' => 'require|integer',
|
||||
'image_type' => 'require|in:tongue_images,report_files',
|
||||
'image_path' => 'require',
|
||||
];
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => '预约ID',
|
||||
'patient_id' => '患者ID',
|
||||
'doctor_id' => '医生ID',
|
||||
'diagnosis_id' => '诊单ID',
|
||||
'appointment_date' => '预约日期',
|
||||
'appointment_time' => '预约时间',
|
||||
'period' => '时段',
|
||||
'appointment_type' => '预约类型',
|
||||
'status' => '状态',
|
||||
'remark' => '备注',
|
||||
'assistant_id' => '医助',
|
||||
'channel_source' => '渠道来源',
|
||||
'channel_source_detail' => '渠道补充说明',
|
||||
'ids' => '预约ID列表',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 创建预约场景
|
||||
* @return AppointmentValidate
|
||||
*/
|
||||
public function sceneCreate()
|
||||
{
|
||||
return $this->only(['patient_id', 'doctor_id', 'appointment_date', 'period', 'appointment_time', 'appointment_type', 'channel_source', 'channel_source_detail']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 取消预约场景
|
||||
* @return AppointmentValidate
|
||||
*/
|
||||
public function sceneCancel()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 预约详情场景
|
||||
* @return AppointmentValidate
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 可用时间段场景
|
||||
* @return AppointmentValidate
|
||||
*/
|
||||
public function sceneAvailableSlots()
|
||||
{
|
||||
return $this->only(['doctor_id', 'appointment_date', 'period']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 完成预约场景
|
||||
* @return AppointmentValidate
|
||||
*/
|
||||
public function sceneComplete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 接诊台聚合详情场景
|
||||
* @return AppointmentValidate
|
||||
*/
|
||||
public function sceneReception()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 通知接诊医助场景
|
||||
* @return AppointmentValidate
|
||||
*/
|
||||
public function sceneNotifyAssistant()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneAddDoctorNote()
|
||||
{
|
||||
return $this->only(['diagnosis_id']);
|
||||
}
|
||||
|
||||
public function sceneDoctorNotes()
|
||||
{
|
||||
return $this->only(['diagnosis_id']);
|
||||
}
|
||||
|
||||
public function sceneDeleteDoctorNoteImage()
|
||||
{
|
||||
return $this->only(['note_id', 'image_type', 'image_path']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台挂号编辑(消费者处方-挂号列表等)
|
||||
*/
|
||||
public function sceneAdminEdit()
|
||||
{
|
||||
return $this->only([
|
||||
'id',
|
||||
'appointment_date',
|
||||
'appointment_time',
|
||||
'period',
|
||||
'appointment_type',
|
||||
'status',
|
||||
'remark',
|
||||
'channel_source',
|
||||
'channel_source_detail',
|
||||
]);
|
||||
}
|
||||
|
||||
/** 批量修改挂号渠道(权限同 doctor.appointment/edit) */
|
||||
public function sceneBatchEditChannel()
|
||||
{
|
||||
return $this->only(['ids', 'channel_source', 'channel_source_detail']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\validate\doctor;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 药品库验证器
|
||||
*/
|
||||
class MedicineValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|integer',
|
||||
'name' => 'require|max:100',
|
||||
'supplier' => 'require|max:100',
|
||||
'unit' => 'require|max:20',
|
||||
'settlement_price' => 'require|float|>=:0',
|
||||
'retail_price' => 'require|float|>=:0',
|
||||
'stock' => 'integer|>=:0',
|
||||
'image' => 'max:255',
|
||||
'status' => 'in:0,1',
|
||||
'remark' => 'max:500',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '药品ID不能为空',
|
||||
'name.require' => '药材名称不能为空',
|
||||
'name.max' => '药材名称不能超过100个字符',
|
||||
'supplier.require' => '供应商名称不能为空',
|
||||
'supplier.max' => '供应商名称不能超过100个字符',
|
||||
'unit.require' => '单位不能为空',
|
||||
'settlement_price.require' => '结算价不能为空',
|
||||
'settlement_price.float' => '结算价必须是数字',
|
||||
'retail_price.require' => '零售价不能为空',
|
||||
'retail_price.float' => '零售价必须是数字',
|
||||
'stock.integer' => '库存必须是整数',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['name', 'supplier', 'unit', 'settlement_price', 'retail_price', 'stock', 'image', 'status', 'remark']);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'name', 'supplier', 'unit', 'settlement_price', 'retail_price', 'stock', 'image', 'status', 'remark']);
|
||||
}
|
||||
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\validate\doctor;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 医生排班验证器
|
||||
* Class RosterValidate
|
||||
* @package app\adminapi\validate\doctor
|
||||
*/
|
||||
class RosterValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'number',
|
||||
'doctor_id' => 'require',
|
||||
'date' => 'require|date',
|
||||
'period' => 'in:morning,afternoon,night,segment',
|
||||
// 须用数组写法:字符串规则里的 | 会与「多规则分隔符」冲突,导致 preg_match 报错
|
||||
'start_time' => ['require', 'regex' => '/^([01]\d|2[0-3]):[0-5]\d$/'],
|
||||
'end_time' => ['require', 'regex' => '/^([01]\d|2[0-3]):[0-5]\d$/'],
|
||||
'slot_minutes' => 'number|between:5,120',
|
||||
'status' => 'require|in:1,2,3,4',
|
||||
'quota' => 'number',
|
||||
'max_patients' => 'number',
|
||||
'remark' => 'max:500',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择排班',
|
||||
'id.number' => '排班ID格式错误',
|
||||
'doctor_id.require' => '请选择医生',
|
||||
'date.require' => '请选择日期',
|
||||
'date.date' => '日期格式不正确',
|
||||
'period.in' => '时段类型参数错误',
|
||||
'start_time.require' => '请填写接诊开始时间',
|
||||
'start_time.regex' => '开始时间格式须为 HH:mm',
|
||||
'end_time.require' => '请填写接诊结束时间',
|
||||
'end_time.regex' => '结束时间格式须为 HH:mm',
|
||||
'slot_minutes.number' => '号源间隔须为数字',
|
||||
'slot_minutes.between' => '号源间隔须在 5~120 分钟',
|
||||
'status.require' => '请选择状态',
|
||||
'status.in' => '状态参数错误',
|
||||
'quota.number' => '号源数必须是数字',
|
||||
'max_patients.number' => '最大接诊数必须是数字',
|
||||
'remark.max' => '备注过长',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 保存场景
|
||||
*/
|
||||
public function sceneSave()
|
||||
{
|
||||
return $this->only([
|
||||
'id', 'doctor_id', 'date', 'period', 'start_time', 'end_time', 'shift_type', 'slot_minutes',
|
||||
'status', 'quota', 'max_patients', 'remark',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->append('id', 'require');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id'])->append('id', 'require');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 批量保存场景
|
||||
*/
|
||||
public function sceneBatchSave()
|
||||
{
|
||||
return $this->only(['rosters'])
|
||||
->append('rosters', 'require|array');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 复制场景
|
||||
*/
|
||||
public function sceneCopy()
|
||||
{
|
||||
return $this->only(['source_start_date', 'source_end_date', 'target_start_date'])
|
||||
->append('source_start_date', 'require|date')
|
||||
->append('source_end_date', 'require|date')
|
||||
->append('target_start_date', 'require|date');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\finance;
|
||||
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\finance\AccountCost;
|
||||
use app\common\service\qywx\MediaChannelService;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class AccountCostValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkExists',
|
||||
'cost_date' => 'require|dateFormat:Y-m-d',
|
||||
'media_channel_code' => 'require|checkMediaChannelCode',
|
||||
'dept_id' => 'require|checkDeptId',
|
||||
'amount' => 'require|float|egt:0',
|
||||
'remark' => 'max:255',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'cost_date.require' => '请选择日期',
|
||||
'cost_date.dateFormat' => '日期格式错误',
|
||||
'media_channel_code.require' => '请选择自媒体渠道',
|
||||
'dept_id.require' => '请选择绑定部门',
|
||||
'amount.require' => '请输入账户消耗金额',
|
||||
'amount.float' => '账户消耗金额格式错误',
|
||||
'amount.egt' => '账户消耗金额不能小于0',
|
||||
'remark.max' => '备注不能超过255个字符',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
if (!AccountCost::supportsDeptBinding()) {
|
||||
return $this->remove('id', true)->remove('dept_id', true);
|
||||
}
|
||||
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
if (!AccountCost::supportsDeptBinding()) {
|
||||
return $this->remove('cost_date', true)->remove('dept_id', true);
|
||||
}
|
||||
|
||||
return $this->remove('cost_date', true);
|
||||
}
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkExists($value)
|
||||
{
|
||||
$model = AccountCost::find($value);
|
||||
if (!$model) {
|
||||
return '记录不存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkMediaChannelCode($value)
|
||||
{
|
||||
if (!MediaChannelService::isValidCode((string) $value)) {
|
||||
return '自媒体渠道不合法';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkDeptId($value)
|
||||
{
|
||||
if (!AccountCost::supportsDeptBinding()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$deptId = (int) $value;
|
||||
if ($deptId <= 0) {
|
||||
return '请选择绑定部门';
|
||||
}
|
||||
|
||||
if (!Dept::find($deptId)) {
|
||||
return '绑定部门不存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\finance;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class DeptPerformanceTargetValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'year_month' => 'require|regex:/^\d{4}-\d{2}$/',
|
||||
'items' => 'require|array',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'year_month.require' => '请选择月份',
|
||||
'year_month.regex' => '月份格式须为 YYYY-MM',
|
||||
'items.require' => '请提交目标数据',
|
||||
'items.array' => '目标数据格式错误',
|
||||
];
|
||||
|
||||
public function sceneMonthMatrix(): DeptPerformanceTargetValidate
|
||||
{
|
||||
return $this->only(['year_month']);
|
||||
}
|
||||
|
||||
public function sceneBatchSave(): DeptPerformanceTargetValidate
|
||||
{
|
||||
return $this->only(['year_month', 'items']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\notice;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 通知验证
|
||||
* Class NoticeValidate
|
||||
* @package app\adminapi\validate\notice
|
||||
*/
|
||||
class NoticeValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
];
|
||||
|
||||
protected function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\notice;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 短信配置验证
|
||||
* Class SmsConfigValidate
|
||||
* @package app\adminapi\validate\notice
|
||||
*/
|
||||
class SmsConfigValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'type' => 'require',
|
||||
'sign' => 'require',
|
||||
'app_id' => 'requireIf:type,tencent',
|
||||
'app_key' => 'requireIf:type,ali',
|
||||
'secret_id' => 'requireIf:type,tencent',
|
||||
'secret_key' => 'require',
|
||||
'status' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'type.require' => '请选择类型',
|
||||
'sign.require' => '请输入签名',
|
||||
'app_id.requireIf' => '请输入app_id',
|
||||
'app_key.requireIf' => '请输入app_key',
|
||||
'secret_id.requireIf' => '请输入secret_id',
|
||||
'secret_key.require' => '请输入secret_key',
|
||||
'status.require' => '请选择状态',
|
||||
];
|
||||
|
||||
|
||||
protected function sceneDetail()
|
||||
{
|
||||
return $this->only(['type']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\order;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 订单验证
|
||||
* Class OrderValidate
|
||||
* @package app\adminapi\validate\order
|
||||
*/
|
||||
class OrderValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|integer',
|
||||
'patient_id' => 'require|integer',
|
||||
'patient_id_optional' => 'integer',
|
||||
'order_type' => 'require|in:1,2,3,4,5,6,7,8',
|
||||
'amount' => 'require|float',
|
||||
'status' => 'require|in:1,2,3,4',
|
||||
'payment_method' => 'in:alipay,wechat,wechat_work,fubei,manual',
|
||||
'remark' => 'string|max:500',
|
||||
'order_no' => 'string|max:50',
|
||||
'is_supplement' => 'in:0,1',
|
||||
'order_ids' => 'require|array',
|
||||
'assistant_id' => 'require|integer|gt:0',
|
||||
'amounts' => 'require|array',
|
||||
'order_types' => 'require|array',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'patient_id.require' => '患者ID必填',
|
||||
'order_type.require' => '订单类型必填',
|
||||
'order_type.in' => '订单类型不正确',
|
||||
'amount.require' => '订单金额必填',
|
||||
'status.require' => '订单状态必填',
|
||||
'status.in' => '订单状态不正确',
|
||||
'payment_method.in' => '支付方式不正确',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'create' => ['patient_id', 'order_type', 'amount'],
|
||||
'edit' => ['id'],
|
||||
'detail' => ['id'],
|
||||
'pay' => ['payment_method'],
|
||||
'cancel' => ['id'],
|
||||
'refund' => ['id'],
|
||||
'delete' => ['id'],
|
||||
'assign_assistant' => ['order_ids', 'assistant_id'],
|
||||
'split' => ['id', 'amounts', 'order_types'],
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\pharmacy;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class MedicineMappingValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'local_medicine_id' => 'require|integer|gt:0',
|
||||
'medicine_code' => 'require|max:32',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'local_medicine_id.require' => '本地药材ID不能为空',
|
||||
'local_medicine_id.integer' => '本地药材ID格式错误',
|
||||
'local_medicine_id.gt' => '本地药材ID格式错误',
|
||||
'medicine_code.require' => '请选择洛阳药房药材',
|
||||
'medicine_code.max' => '洛阳药房药材编码不能超过32个字符',
|
||||
];
|
||||
|
||||
public function sceneSave(): self
|
||||
{
|
||||
return $this->only(['local_medicine_id', 'medicine_code']);
|
||||
}
|
||||
|
||||
public function sceneUnlink(): self
|
||||
{
|
||||
return $this->only(['local_medicine_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\qywx;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 企业微信客户验证器
|
||||
*/
|
||||
class CustomerValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'auto_sync' => 'require|boolean',
|
||||
'interval' => 'require|integer|between:3600,86400',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'auto_sync.require' => '请选择是否自动同步',
|
||||
'auto_sync.boolean' => '自动同步参数格式错误',
|
||||
'interval.require' => '请选择同步间隔',
|
||||
'interval.integer' => '同步间隔必须为整数',
|
||||
'interval.between' => '同步间隔必须在1小时到24小时之间',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 同步设置场景
|
||||
*/
|
||||
public function sceneSyncSettings()
|
||||
{
|
||||
return $this->only(['auto_sync', 'interval']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\qywx;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class MessageValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'sender_userid' => 'require',
|
||||
'external_userids' => 'require|array|min:1',
|
||||
'msg_payload' => 'require|array',
|
||||
'chat_type' => 'in:single,group',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'sender_userid.require' => '请选择代发员工',
|
||||
'external_userids.require' => '请选择至少一位客户',
|
||||
'external_userids.array' => '客户列表格式错误',
|
||||
'external_userids.min' => '至少选择 1 位客户',
|
||||
'msg_payload.require' => '请填写消息内容',
|
||||
'msg_payload.array' => '消息内容格式错误',
|
||||
'chat_type.in' => '会话类型不合法',
|
||||
];
|
||||
|
||||
public function sceneSend()
|
||||
{
|
||||
return $this->only(['sender_userid', 'external_userids', 'msg_payload', 'chat_type']);
|
||||
}
|
||||
|
||||
public function sceneMarkRead()
|
||||
{
|
||||
return $this->only(['session_id'])->append('session_id', 'require|integer|>:0');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\recharge;
|
||||
|
||||
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\RefundEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\recharge\RechargeOrder;
|
||||
use app\common\model\refund\RefundRecord;
|
||||
use app\common\model\user\User;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 充值退款校验
|
||||
* Class RechargeRefundValidate
|
||||
* @package app\adminapi\validate\recharge
|
||||
*/
|
||||
class RechargeRefundValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'recharge_id' => 'require|checkRecharge',
|
||||
'record_id' => 'require|checkRecord',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'recharge_id.require' => '参数缺失',
|
||||
'record_id.require' => '参数缺失',
|
||||
];
|
||||
|
||||
|
||||
public function sceneRefund()
|
||||
{
|
||||
return $this->only(['recharge_id']);
|
||||
}
|
||||
|
||||
|
||||
public function sceneAgain()
|
||||
{
|
||||
return $this->only(['record_id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验充值订单能否发起退款
|
||||
* @param $rechargeId
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2023/2/28 17:00
|
||||
*/
|
||||
protected function checkRecharge($rechargeId, $rule, $data)
|
||||
{
|
||||
$order = RechargeOrder::findOrEmpty($rechargeId);
|
||||
|
||||
if ($order->isEmpty()) {
|
||||
return '充值订单不存在';
|
||||
}
|
||||
|
||||
if ($order['pay_status'] != PayEnum::ISPAID) {
|
||||
return '当前订单不可退款';
|
||||
}
|
||||
|
||||
// 校验订单是否已退款
|
||||
if ($order['refund_status'] == YesNoEnum::YES) {
|
||||
return '订单已发起退款,退款失败请到退款记录重新退款';
|
||||
}
|
||||
|
||||
// 校验余额
|
||||
$user = User::findOrEmpty($order['user_id']);
|
||||
if ($user['user_money'] < $order['order_amount']) {
|
||||
return '退款失败:用户余额已不足退款金额';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验退款记录
|
||||
* @param $recordId
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2023/3/1 9:40
|
||||
*/
|
||||
protected function checkRecord($recordId, $rule, $data)
|
||||
{
|
||||
$record = RefundRecord::findOrEmpty($recordId);
|
||||
if ($record->isEmpty()) {
|
||||
return '退款记录不存在';
|
||||
}
|
||||
|
||||
if($record['refund_status'] == RefundEnum::REFUND_SUCCESS) {
|
||||
return '该退款记录已退款成功';
|
||||
}
|
||||
|
||||
$order = RechargeOrder::findOrEmpty($record['order_id']);
|
||||
$user = User::findOrEmpty($record['user_id']);
|
||||
|
||||
if ($user['user_money'] < $order['order_amount']) {
|
||||
return '退款失败:用户余额已不足退款金额';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\setting;
|
||||
|
||||
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\model\pay\PayConfig;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
class PayConfigValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'name' => 'require|checkName',
|
||||
'icon' => 'require',
|
||||
'sort' => 'require|number|max:5',
|
||||
'config' => 'checkConfig',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => 'id不能为空',
|
||||
'name.require' => '支付名称不能为空',
|
||||
'icon.require' => '支付图标不能为空',
|
||||
'sort.require' => '排序不能为空',
|
||||
'sort,number' => '排序必须是纯数字',
|
||||
'sort.max' => '排序最大不能超过五位数',
|
||||
'config.require' => '支付参数缺失',
|
||||
];
|
||||
|
||||
public function sceneGet()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验支付配置记录
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2023/2/23 16:19
|
||||
*/
|
||||
public function checkConfig($config, $rule, $data)
|
||||
{
|
||||
$result = PayConfig::where('id', $data['id'])->find();
|
||||
if (empty($result)) {
|
||||
return '支付方式不存在';
|
||||
}
|
||||
if ($result['pay_way'] != PayEnum::BALANCE_PAY && !isset($config)) {
|
||||
return '支付配置不能为空';
|
||||
}
|
||||
|
||||
if ($result['pay_way'] == PayEnum::WECHAT_PAY) {
|
||||
if (empty($config['interface_version'])) {
|
||||
return '微信支付接口版本不能为空';
|
||||
}
|
||||
if (empty($config['merchant_type'])) {
|
||||
return '商户类型不能为空';
|
||||
}
|
||||
if (empty($config['mch_id'])) {
|
||||
return '微信支付商户号不能为空';
|
||||
}
|
||||
if (empty($config['pay_sign_key'])) {
|
||||
return '商户API密钥不能为空';
|
||||
}
|
||||
if (empty($config['apiclient_cert'])) {
|
||||
return '微信支付证书不能为空';
|
||||
}
|
||||
if (empty($config['apiclient_key'])) {
|
||||
return '微信支付证书密钥不能为空';
|
||||
}
|
||||
}
|
||||
if ($result['pay_way'] == PayEnum::ALI_PAY) {
|
||||
if (empty($config['mode'])) {
|
||||
return '模式不能为空';
|
||||
}
|
||||
if (empty($config['merchant_type'])) {
|
||||
return '商户类型不能为空';
|
||||
}
|
||||
if (empty($config['app_id'])) {
|
||||
return '应用ID不能为空';
|
||||
}
|
||||
if (empty($config['private_key'])) {
|
||||
return '应用私钥不能为空';
|
||||
}
|
||||
if (empty($config['ali_public_key'])) {
|
||||
return '支付宝公钥不能为空';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验支付名
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2023/2/23 16:19
|
||||
*/
|
||||
public function checkName($value, $rule, $data)
|
||||
{
|
||||
$result = PayConfig::where('name', $value)
|
||||
->where('id', '<>', $data['id'])
|
||||
->findOrEmpty();
|
||||
if (!$result->isEmpty()) {
|
||||
return '支付名称已存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\setting;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 存储引擎验证
|
||||
* Class StorageValidate
|
||||
* @package app\adminapi\validate\setting
|
||||
*/
|
||||
class StorageValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'engine' => 'require',
|
||||
'status' => 'require',
|
||||
];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置存储引擎参数场景
|
||||
* @return StorageValidate
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 16:18
|
||||
*/
|
||||
public function sceneSetup()
|
||||
{
|
||||
return $this->only(['engine', 'status']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取配置参数信息场景
|
||||
* @return StorageValidate
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 16:18
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['engine']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 切换存储引擎场景
|
||||
* @return StorageValidate
|
||||
* @author 段誉
|
||||
* @date 2022/4/20 16:18
|
||||
*/
|
||||
public function sceneChange()
|
||||
{
|
||||
return $this->only(['engine']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\setting;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 交易设置验证
|
||||
* Class TransactionSettingsValidate
|
||||
* @package app\adminapi\validate\setting
|
||||
*/
|
||||
class TransactionSettingsValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'cancel_unpaid_orders' => 'require|in:0,1',
|
||||
'cancel_unpaid_orders_times' => 'requireIf:cancel_unpaid_orders,1|integer|gt:0',
|
||||
'verification_orders' => 'require|in:0,1',
|
||||
'verification_orders_times' => 'requireIf:verification_orders,1|integer|gt:0',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'cancel_unpaid_orders.require' => '请选择系统取消待付款订单方式',
|
||||
'cancel_unpaid_orders.in' => '系统取消待付款订单状态值有误',
|
||||
'cancel_unpaid_orders_times.requireIf' => '系统取消待付款订单时间未填写',
|
||||
'cancel_unpaid_orders_times.integer' => '系统取消待付款订单时间须为整型',
|
||||
'cancel_unpaid_orders_times.gt' => '系统取消待付款订单时间须大于0',
|
||||
|
||||
'verification_orders.require' => '请选择系统自动核销订单方式',
|
||||
'verification_orders.in' => '系统自动核销订单状态值有误',
|
||||
'verification_orders_times.requireIf' => '系统自动核销订单时间未填写',
|
||||
'verification_orders_times.integer' => '系统自动核销订单时间须为整型',
|
||||
'verification_orders_times.gt' => '系统自动核销订单时间须大于0',
|
||||
];
|
||||
|
||||
public function sceneSetConfig()
|
||||
{
|
||||
return $this->only(['cancel_unpaid_orders','cancel_unpaid_orders_times','verification_orders','verification_orders_times']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\validate\setting;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 用户设置验证
|
||||
* Class UserConfigValidate
|
||||
* @package app\adminapi\validate\setting
|
||||
*/
|
||||
class UserConfigValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'login_way' => 'requireIf:scene,register|array',
|
||||
'coerce_mobile' => 'requireIf:scene,register|in:0,1',
|
||||
'login_agreement' => 'in:0,1',
|
||||
'third_auth' => 'in:0,1',
|
||||
'wechat_auth' => 'in:0,1',
|
||||
'default_avatar' => 'require',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'default_avatar.require' => '请上传用户默认头像',
|
||||
'login_way.requireIf' => '请选择登录方式',
|
||||
'login_way.array' => '登录方式值错误',
|
||||
'coerce_mobile.requireIf' => '请选择注册强制绑定手机',
|
||||
'coerce_mobile.in' => '注册强制绑定手机值错误',
|
||||
'wechat_auth.in' => '公众号微信授权登录值错误',
|
||||
'third_auth.in' => '第三方登录值错误',
|
||||
'login_agreement.in' => '政策协议值错误',
|
||||
];
|
||||
|
||||
//用户设置验证
|
||||
public function sceneUser()
|
||||
{
|
||||
return $this->only(['default_avatar']);
|
||||
}
|
||||
|
||||
//注册验证
|
||||
public function sceneRegister()
|
||||
{
|
||||
return $this->only(['login_way', 'coerce_mobile', 'login_agreement', 'third_auth', 'wechat_auth']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\setting;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 网站设置验证器
|
||||
* Class WebSettingValidate
|
||||
* @package app\adminapi\validate\setting
|
||||
*/
|
||||
class WebSettingValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'name' => 'require|max:30',
|
||||
'web_favicon' => 'require',
|
||||
'web_logo' => 'require',
|
||||
'login_image' => 'require',
|
||||
'shop_name' => 'require',
|
||||
'shop_logo' => 'require',
|
||||
'pc_logo' => 'require'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.require' => '请填写网站名称',
|
||||
'name.max' => '网站名称最长为12个字符',
|
||||
'web_favicon.require' => '请上传网站图标',
|
||||
'web_logo.require' => '请上传网站logo',
|
||||
'login_image.require' => '请上传登录页广告图',
|
||||
'shop_name.require' => '请填写前台名称',
|
||||
'shop_logo.require' => '请上传前台logo',
|
||||
'pc_logo.require' => '请上传PC端logo'
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'website' => ['name', 'web_favicon', 'web_logo', 'login_image', 'shop_name', 'shop_logo', 'pc_logo'],
|
||||
'siteStatistics' => [''],
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\stats;
|
||||
|
||||
use app\common\model\stats\PersonalAccountCost;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class PersonalAccountCostValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkExists',
|
||||
'cost_date' => 'require|dateFormat:Y-m-d',
|
||||
'media_source' => 'require|max:120',
|
||||
'amount' => 'require|float|egt:0',
|
||||
'remark' => 'max:255',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'cost_date.require' => '请选择日期',
|
||||
'cost_date.dateFormat' => '日期格式错误',
|
||||
'media_source.require' => '请填写自媒体来源',
|
||||
'media_source.max' => '自媒体来源不能超过120个字符',
|
||||
'amount.require' => '请输入账户消耗金额',
|
||||
'amount.float' => '账户消耗金额格式错误',
|
||||
'amount.egt' => '账户消耗金额不能小于0',
|
||||
'remark.max' => '备注不能超过255个字符',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->remove('cost_date', true)->remove('media_source', true);
|
||||
}
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkExists($value)
|
||||
{
|
||||
$model = PersonalAccountCost::find($value);
|
||||
if (!$model) {
|
||||
return '记录不存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\stats;
|
||||
|
||||
use app\common\model\stats\PersonalYeji;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class PersonalYejiValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkExists',
|
||||
'yeji_date' => 'require|dateFormat:Y-m-d',
|
||||
'media_source' => 'require|max:120',
|
||||
'add_fans_count' => 'require|integer|egt:0',
|
||||
'total_open_count' => 'integer|egt:0',
|
||||
'unreplied_count' => 'integer|egt:0',
|
||||
'paid_appointment_count' => 'integer|egt:0',
|
||||
'free_appointment_count' => 'integer|egt:0',
|
||||
'interview_count' => 'integer|egt:0',
|
||||
'order_amount' => 'float|egt:0',
|
||||
'completed_order_count' => 'integer|egt:0',
|
||||
'remark' => 'max:255',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'yeji_date.require' => '请选择业绩日期',
|
||||
'yeji_date.dateFormat' => '业绩日期格式错误',
|
||||
'media_source.require' => '请填写自媒体来源',
|
||||
'media_source.max' => '自媒体来源不能超过120个字符',
|
||||
'add_fans_count.require' => '请填写加粉数',
|
||||
'add_fans_count.integer' => '加粉数格式错误',
|
||||
'add_fans_count.egt' => '加粉数不能小于0',
|
||||
'remark.max' => '备注不能超过255个字符',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->remove('yeji_date', true)->remove('media_source', true);
|
||||
}
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkExists($value)
|
||||
{
|
||||
$model = PersonalYeji::find($value);
|
||||
if (!$model) {
|
||||
return '记录不存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?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\tcm;
|
||||
|
||||
use app\common\model\tcm\Diagnosis;
|
||||
use app\common\model\tcm\DiagnosisTodo;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 诊单待办事项验证
|
||||
* Class DiagnosisTodoValidate
|
||||
* @package app\adminapi\validate\tcm
|
||||
*/
|
||||
class DiagnosisTodoValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|number',
|
||||
'diagnosis_id' => 'require|number|gt:0|checkDiagnosis',
|
||||
'content' => 'require|length:1,500',
|
||||
'remind_time' => 'require|number|checkRemindFuture',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'diagnosis_id.require' => '诊单 id 不能为空',
|
||||
'diagnosis_id.gt' => '诊单 id 非法',
|
||||
'content.require' => '请输入提醒内容',
|
||||
'content.length' => '提醒内容长度需在 1-500 字',
|
||||
'remind_time.require' => '请选择提醒时间',
|
||||
'remind_time.number' => '提醒时间格式错误',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['diagnosis_id', 'content', 'remind_time']);
|
||||
}
|
||||
|
||||
public function sceneCancel()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneList()
|
||||
{
|
||||
return $this->only(['diagnosis_id'])
|
||||
->append('diagnosis_id', 'require|number|gt:0');
|
||||
}
|
||||
|
||||
/**
|
||||
* 诊单存在校验
|
||||
*/
|
||||
protected function checkDiagnosis($value): bool|string
|
||||
{
|
||||
$diagnosis = Diagnosis::findOrEmpty((int) $value);
|
||||
if ($diagnosis->isEmpty()) {
|
||||
return '诊单不存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提醒时间必须在当前时间之后(至少 30 秒),避免立刻就过期
|
||||
*/
|
||||
protected function checkRemindFuture($value): bool|string
|
||||
{
|
||||
$ts = (int) $value;
|
||||
if ($ts <= time() + 30) {
|
||||
return '提醒时间必须晚于当前时间';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\tcm;
|
||||
|
||||
use app\common\model\tcm\Diagnosis;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 中医辨房病因诊单验证
|
||||
* Class DiagnosisValidate
|
||||
* @package app\adminapi\validate\tcm
|
||||
*/
|
||||
class DiagnosisValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkDiagnosis',
|
||||
'patient_name' => 'require|length:1,50',
|
||||
'id_card' => 'length:15,18',
|
||||
'phone' => 'require|mobile',
|
||||
'gender' => 'require|in:0,1',
|
||||
'age' => 'require|number|between:0,150',
|
||||
'diagnosis_type' => 'require',
|
||||
'local_hospital_name' => 'require|max:255',
|
||||
'status' => 'in:0,1',
|
||||
'show_card' => 'in:0,1',
|
||||
'create_source' => 'max:32',
|
||||
'current_medications' => 'max:2000',
|
||||
'tongue_images' => 'array',
|
||||
'report_files' => 'array',
|
||||
'diabetes_discovery_year' => 'max:50',
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date|checkDateRange',
|
||||
'diagnosis_id' => 'require|integer|checkDiagnosisId',
|
||||
'tracking_content' => 'require|length:1,1000',
|
||||
'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',
|
||||
'prompt' => 'max:500',
|
||||
'model' => 'in:qwen,openai',
|
||||
'patient_id' => 'integer|gt:0',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'patient_name.require' => '请输入患者姓名',
|
||||
'patient_name.length' => '患者姓名长度须在1-50位字符',
|
||||
'id_card.length' => '身份证号长度不正确',
|
||||
'id_card.require' => '请输入身份证号',
|
||||
'phone.require' => '请输入手机号',
|
||||
'phone.mobile' => '手机号格式不正确',
|
||||
'gender.require' => '请选择性别',
|
||||
'gender.in' => '性别参数错误',
|
||||
'age.require' => '请输入年龄',
|
||||
'age.number' => '年龄必须为数字',
|
||||
'age.between' => '年龄范围0-150',
|
||||
'diagnosis_type.require' => '请选择诊断类型',
|
||||
'local_hospital_name.require' => '请输入当地就诊医院名称',
|
||||
'local_hospital_name.max' => '当地就诊医院名称最多255个字符',
|
||||
'status.in' => '状态参数错误',
|
||||
'create_source.max' => '渠道来源长度不能超过32个字符',
|
||||
'current_medications.max' => '在用药物最多2000个字符',
|
||||
'diabetes_discovery_year.max' => '发现糖尿病患病史最多50个字符',
|
||||
'start_date.date' => '开始日期格式不正确',
|
||||
'end_date.date' => '结束日期格式不正确',
|
||||
'diagnosis_id.require' => '诊单ID不能为空',
|
||||
'tracking_content.require' => '跟踪备注内容不能为空',
|
||||
'tracking_content.length' => '跟踪备注最多1000个字符',
|
||||
'report_id.require' => '报告ID不能为空',
|
||||
'report_id.number' => '报告ID必须为数字',
|
||||
'report_id.gt' => '报告ID必须大于0',
|
||||
'content.require' => '报告内容不能为空',
|
||||
'content.max' => '报告内容最多12000个字符',
|
||||
'task.require' => '请选择 AI 助手任务',
|
||||
'task.in' => 'AI 助手任务不受支持',
|
||||
'prompt.max' => '问题最多500个字符',
|
||||
'model.in' => 'AI模型仅支持qwen或openai',
|
||||
'patient_id.require' => '患者ID不能为空',
|
||||
'patient_id.integer' => '患者ID必须为整数',
|
||||
'patient_id.gt' => '患者ID必须大于0',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
// 全局规则里混有跟踪备注、AI 助手字段;新增诊单只去掉这些无关校验。
|
||||
// 不要改成 only([...]):add 还会写入现病史等多选字段,only 会把它们从请求里丢掉。
|
||||
return $this->remove('id', true)
|
||||
->remove('diagnosis_id', true)
|
||||
->remove('tracking_content', true)
|
||||
->remove('task', true)
|
||||
->remove('prompt', true)
|
||||
->remove('model', true)
|
||||
->remove('report_id', true)
|
||||
->remove('content', true);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'patient_name', 'id_card', 'phone', 'gender', 'age', 'diagnosis_date', 'diagnosis_type', 'syndrome_type', 'marital_status', 'height', 'weight', 'region', 'systolic_pressure', 'diastolic_pressure', 'fasting_blood_sugar', 'diabetes_discovery_year', 'local_hospital_diagnosis', 'local_hospital_name', 'past_history', 'symptoms', 'tongue_coating', 'pulse', 'treatment_principle', 'prescription', 'doctor_advice', 'remark', 'current_medications', 'status', 'show_card', 'create_source']);
|
||||
}
|
||||
|
||||
public function sceneId()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneReadonlyDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneTrackingWindow()
|
||||
{
|
||||
return $this->only(['id', 'start_date', 'end_date']);
|
||||
}
|
||||
|
||||
/** 新增跟踪备注:诊单ID + 备注内容 */
|
||||
public function sceneAddTrackingNote()
|
||||
{
|
||||
return $this->only(['diagnosis_id', 'tracking_content']);
|
||||
}
|
||||
|
||||
/** 拉取跟踪备注列表:诊单ID */
|
||||
public function sceneTrackingNotes()
|
||||
{
|
||||
return $this->only(['diagnosis_id']);
|
||||
}
|
||||
|
||||
public function sceneGenerateQrcode()
|
||||
{
|
||||
return $this->only(['diagnosis_id', 'doctor_id', 'patient_id', 'share_user_id', 'mini_program_path'])
|
||||
// The global diagnosis_id rule is required for diagnosis APIs, but
|
||||
// video QR codes identify the doctor instead. Keep diagnosis_id
|
||||
// optional here while still validating it when it is supplied.
|
||||
->remove('diagnosis_id', 'require')
|
||||
->append('patient_id', 'require|integer|checkQrcodeIds')
|
||||
->append('share_user_id', 'require|integer')
|
||||
->append('doctor_id', 'integer');
|
||||
}
|
||||
|
||||
public function sceneGenerateOrderQrcode()
|
||||
{
|
||||
return $this->only([]);
|
||||
}
|
||||
|
||||
public function sceneFillIdCard()
|
||||
{
|
||||
return $this->only(['id', 'id_card'])
|
||||
->append('id', 'require')
|
||||
->append('id_card', 'require|length:15,18');
|
||||
}
|
||||
|
||||
public function sceneGuahaoLogList()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
/** 业务订单 tab:设置复诊接诊率统计起始偏移 */
|
||||
public function sceneSetRevisitSlotStartOffset()
|
||||
{
|
||||
return $this->only(['id', 'revisit_slot_start_offset'])
|
||||
->append('revisit_slot_start_offset', 'require|integer|between:0,20');
|
||||
}
|
||||
|
||||
public function sceneAiReports()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneAiAssistant()
|
||||
{
|
||||
return $this->only(['id', 'task', 'prompt']);
|
||||
}
|
||||
|
||||
public function sceneAiAnalysis()
|
||||
{
|
||||
return $this->only(['id', 'model'])
|
||||
->remove('id', 'checkDiagnosis')
|
||||
->append('id', 'integer|gt:0|checkAiAnalysisPayload');
|
||||
}
|
||||
|
||||
public function scenePatientAiReports()
|
||||
{
|
||||
return $this->only(['patient_id'])
|
||||
->append('patient_id', 'require|integer|gt:0|checkPatientAiReportsPayload');
|
||||
}
|
||||
|
||||
public function sceneGeneratePatientAiReport()
|
||||
{
|
||||
return $this->only(['patient_id', 'model'])
|
||||
->append('patient_id', 'require|integer|gt:0|checkGeneratePatientAiReportPayload')
|
||||
->append('model', 'require|in:qwen,openai');
|
||||
}
|
||||
|
||||
public function sceneGenerateAiReports()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneEditAiReport()
|
||||
{
|
||||
return $this->only(['id', 'report_id', 'content'])
|
||||
->append('report_id', 'require|number|gt:0')
|
||||
->append('content', 'require|max:12000');
|
||||
}
|
||||
|
||||
protected function checkDiagnosis($value)
|
||||
{
|
||||
$diagnosis = Diagnosis::findOrEmpty($value);
|
||||
if ($diagnosis->isEmpty()) {
|
||||
return '诊单不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 校验 diagnosis_id 字段(addTrackingNote 等场景使用,避开 id 字段) */
|
||||
protected function checkDiagnosisId($value)
|
||||
{
|
||||
$diagnosis = Diagnosis::findOrEmpty($value);
|
||||
if ($diagnosis->isEmpty()) {
|
||||
return '诊单不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** end_date 不能早于 start_date */
|
||||
protected function checkDateRange($value, $rule, $data = [])
|
||||
{
|
||||
$start = $data['start_date'] ?? '';
|
||||
if ($start && $value && strtotime($value) < strtotime($start)) {
|
||||
return '结束日期不能早于开始日期';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 视频场景需 doctor_id,确认诊单需 diagnosis_id */
|
||||
protected function checkQrcodeIds($value, $rule, $data = [])
|
||||
{
|
||||
$page = $data['mini_program_path'] ?? '';
|
||||
$hasDoctor = !empty($data['doctor_id']);
|
||||
$hasDiagnosis = !empty($data['diagnosis_id']);
|
||||
if ($page === 'pages/login/login') {
|
||||
return $hasDoctor ? true : '视频二维码需传挂号医生ID';
|
||||
}
|
||||
return $hasDiagnosis ? true : '诊单ID不能为空';
|
||||
}
|
||||
|
||||
/**
|
||||
* AI 智能分析仅接受诊单 ID 和可选的固定模型键。客户端不得提供
|
||||
* provider、凭据、上游地址、提示词等服务端配置或控制字段。
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $rule
|
||||
* @param array<string,mixed> $data
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function checkAiAnalysisPayload($value, $rule, array $data = [])
|
||||
{
|
||||
if (!array_key_exists('id', $data)) {
|
||||
return 'AI智能分析请求缺少id参数';
|
||||
}
|
||||
|
||||
$extraFields = array_diff(array_keys($data), ['id', 'model']);
|
||||
if ($extraFields !== []) {
|
||||
return 'AI智能分析请求仅允许id及可选model参数';
|
||||
}
|
||||
|
||||
if (array_key_exists('model', $data)) {
|
||||
$model = $data['model'];
|
||||
if (!is_string($model) || !in_array($model, ['qwen', 'openai'], true)) {
|
||||
return 'AI模型仅支持qwen或openai';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $data */
|
||||
protected function checkPatientAiReportsPayload($value, $rule, array $data = [])
|
||||
{
|
||||
if (!array_key_exists('patient_id', $data)) {
|
||||
return '请求缺少patient_id参数';
|
||||
}
|
||||
$extraFields = array_diff(array_keys($data), ['patient_id']);
|
||||
return $extraFields === [] ? true : '请求仅允许patient_id参数';
|
||||
}
|
||||
|
||||
/**
|
||||
* 患者报告生成端点只接受稳定患者ID与服务端模型白名单键。
|
||||
* provider、凭据、BASE_URL、提示词和任意来源正文均不得由客户端注入。
|
||||
*
|
||||
* @param array<string,mixed> $data
|
||||
*/
|
||||
protected function checkGeneratePatientAiReportPayload($value, $rule, array $data = [])
|
||||
{
|
||||
if (!array_key_exists('patient_id', $data) || !array_key_exists('model', $data)) {
|
||||
return '请求缺少patient_id或model参数';
|
||||
}
|
||||
$extraFields = array_diff(array_keys($data), ['patient_id', 'model']);
|
||||
if ($extraFields !== []) {
|
||||
return '请求仅允许patient_id和model参数';
|
||||
}
|
||||
if (!is_string($data['model']) || !in_array($data['model'], ['qwen', 'openai'], true)) {
|
||||
return 'AI模型仅支持qwen或openai';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?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']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\tcm;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class PrescriptionOrderValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|integer',
|
||||
'diagnosis_id' => 'require|integer|gt:0',
|
||||
'prescription_id' => 'require|integer',
|
||||
'pay_order_ids' => 'array',
|
||||
'recipient_name' => 'require|max:50',
|
||||
'recipient_phone' => 'require|max:20',
|
||||
'shipping_address' => 'require|max:500',
|
||||
'is_follow_up' => 'in:0,1',
|
||||
'prev_staff' => 'max:100',
|
||||
'service_channel' => 'max:100',
|
||||
'service_package' => 'max:100',
|
||||
'tracking_number' => 'max:80',
|
||||
'express_company' => 'max:20',
|
||||
'ship_mode' => 'in:gancao,direct',
|
||||
'resolution' => 'require|in:CONFIRM_SUCCESS,CONFIRM_NOT_CREATED',
|
||||
'remote_order_no' => 'max:64',
|
||||
'note' => 'require|max:1000',
|
||||
'fee_type' => 'require|in:1,2,3,4,5,6,7,8',
|
||||
'amount' => 'require|float',
|
||||
'order_type' => 'require|in:1,2,3,4,5,6,7,8',
|
||||
'pay_amount' => 'require|float|egt:0',
|
||||
'pay_remark' => 'max:200',
|
||||
'remark_extra' => 'max:500',
|
||||
'remark_assistant' => 'max:500',
|
||||
'action' => 'require|in:approve,reject',
|
||||
'remark' => 'max:500',
|
||||
'summary' => 'require|max:500',
|
||||
'prescription_audit_status' => 'in:0,1,2',
|
||||
'payment_slip_audit_status' => 'in:0,1,2',
|
||||
'prescription_audit_remark' => 'max:500',
|
||||
'payment_slip_audit_remark' => 'max:500',
|
||||
'fulfillment_status' => 'require|integer|in:3,7,8,9,11,12',
|
||||
'reason' => 'require|max:500',
|
||||
'refund_amount' => 'float|egt:0',
|
||||
'patient_name' => 'require|max:50',
|
||||
'phone' => 'require|max:20',
|
||||
'phone_tail' => 'max:20|regex:/^\\d*$/',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'prescription_id.require' => '请选择处方',
|
||||
'diagnosis_id.require' => '请选择诊单',
|
||||
'recipient_name.require' => '请输入收货人',
|
||||
'recipient_phone.require' => '请输入收货手机',
|
||||
'shipping_address.require' => '请输入收货地址',
|
||||
'fee_type.require' => '请选择费用类别',
|
||||
'amount.require' => '请输入订单金额',
|
||||
'action.require' => '请选择审核操作',
|
||||
'patient_name.require' => '请输入患者姓名',
|
||||
'phone.require' => '请输入手机号',
|
||||
'tracking_number.require' => '请输入快递单号',
|
||||
'phone_tail.regex' => '手机后四位仅支持数字',
|
||||
'reason.require' => '请填写退款原因',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'create' => [
|
||||
'prescription_id', 'diagnosis_id', 'recipient_name', 'recipient_phone', 'shipping_address',
|
||||
'is_follow_up', 'prev_staff', 'service_channel', 'service_package',
|
||||
'tracking_number', 'express_company', 'ship_mode', 'fee_type', 'amount', 'remark_extra', 'remark_assistant', 'pay_order_ids',
|
||||
],
|
||||
'detail' => ['id'],
|
||||
'edit' => [
|
||||
'id', 'recipient_name', 'recipient_phone', 'shipping_address',
|
||||
'is_follow_up', 'prev_staff', 'service_channel', 'service_package',
|
||||
'tracking_number', 'express_company', 'fee_type', 'amount', 'remark_extra', 'remark_assistant', 'pay_order_ids',
|
||||
],
|
||||
'ddcode' => ['id', 'tracking_number', 'express_company'],
|
||||
'logisticsTrace' => ['id', 'phone_tail'],
|
||||
'logisticsJdUpdate' => ['id'],
|
||||
'auditPrescription' => ['id', 'action', 'remark'],
|
||||
'auditPayment' => ['id', 'action', 'remark'],
|
||||
'withdraw' => ['id'],
|
||||
'ship' => ['id', 'tracking_number', 'express_company', 'ship_mode'],
|
||||
'logs' => ['id'],
|
||||
'addLog' => ['id', 'summary'],
|
||||
'paidPayOrders' => ['diagnosis_id'],
|
||||
'addPayOrder' => ['id', 'order_type', 'pay_amount', 'pay_remark'],
|
||||
'linkPayOrder' => ['id', 'pay_order_id'],
|
||||
'requestCompletion' => ['id'],
|
||||
'complete' => ['id', 'fulfillment_status'],
|
||||
'refund' => ['id', 'reason', 'refund_amount'],
|
||||
'submitGancaoRecipel' => ['id'],
|
||||
'uploadToPharmacy' => ['id'],
|
||||
'previewGancaoRecipel' => ['id'],
|
||||
'patchPrescriptionPatient' => ['id', 'patient_name', 'phone'],
|
||||
'patchPrescriptionUsage' => ['id', 'times_per_day', 'usage_days', 'medication_days', 'aux_times_per_day', 'aux_usage_days'],
|
||||
'updateAmount' => ['id', 'amount'],
|
||||
'setShipMode' => ['id', 'ship_mode'],
|
||||
'confirmGancaoSubmission' => ['id', 'resolution', 'remote_order_no', 'note'],
|
||||
];
|
||||
|
||||
public function updateAmount(): PrescriptionOrderValidate
|
||||
{
|
||||
return $this->only(['id', 'amount'])
|
||||
->append('id', 'require|integer|gt:0')
|
||||
->append('amount', 'require|float|egt:0');
|
||||
}
|
||||
|
||||
public function ddcode(): PrescriptionOrderValidate
|
||||
{
|
||||
return $this->only(['id', 'tracking_number', 'express_company'])
|
||||
->append('id', 'require|integer|gt:0')
|
||||
->append('tracking_number', 'require|max:80')
|
||||
->append('express_company', 'max:20');
|
||||
}
|
||||
|
||||
public function patchPrescriptionUsage(): PrescriptionOrderValidate
|
||||
{
|
||||
return $this->only(['id', 'times_per_day', 'usage_days', 'medication_days', 'aux_times_per_day', 'aux_usage_days'])
|
||||
->append('id', 'require|integer|gt:0')
|
||||
->append('times_per_day', 'require|integer|between:1,6')
|
||||
->append('usage_days', 'require|integer|between:1,999')
|
||||
->append('medication_days', 'require|integer|between:1,999')
|
||||
->append('aux_times_per_day', 'integer|between:1,6')
|
||||
->append('aux_usage_days', 'integer|between:1,999');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\tcm;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class PrescriptionValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'diagnosis_id' => 'number',
|
||||
'appointment_id' => 'number',
|
||||
'dosage_bag_count' => 'integer|between:1,5',
|
||||
'patient_name' => 'require',
|
||||
'phone' => 'require|max:20',
|
||||
'gender' => 'require|in:0,1',
|
||||
'clinical_diagnosis' => 'require',
|
||||
'herbs' => 'require|array',
|
||||
'action' => 'require|in:approve,reject',
|
||||
'remark' => 'max:500',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'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' => '请添加中药',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only([
|
||||
'prescription_type', 'dosage_amount', 'dosage_unit', 'dosage_bag_count', 'need_decoction', 'bags_per_dose',
|
||||
'patient_name', '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',
|
||||
]);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only([
|
||||
'id', 'prescription_type', 'dosage_amount', 'dosage_unit', 'dosage_bag_count', 'need_decoction', 'bags_per_dose',
|
||||
'patient_name', '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',
|
||||
]);
|
||||
}
|
||||
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function scenePatchPatient()
|
||||
{
|
||||
return $this->only(['id', 'patient_name', 'phone', 'gender']);
|
||||
}
|
||||
|
||||
public function sceneAudit()
|
||||
{
|
||||
return $this->only(['id', 'action', 'remark']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\tools;
|
||||
|
||||
|
||||
use app\common\model\tools\GenerateTable;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 编辑表验证
|
||||
* Class EditTableValidate
|
||||
* @package app\adminapi\validate\tools
|
||||
*/
|
||||
class EditTableValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|checkTableData',
|
||||
'table_name' => 'require',
|
||||
'table_comment' => 'require',
|
||||
'template_type' => 'require|in:0,1',
|
||||
'generate_type' => 'require|in:0,1',
|
||||
'module_name' => 'require',
|
||||
'table_column' => 'require|array|checkColumn',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '表id缺失',
|
||||
'table_name.require' => '请填写表名称',
|
||||
'table_comment.require' => '请填写表描述',
|
||||
'template_type.require' => '请选择模板类型',
|
||||
'template_type.in' => '模板类型参数错误',
|
||||
'generate_type.require' => '请选择生成方式',
|
||||
'generate_type.in' => '生成方式类型错误',
|
||||
'module_name.require' => '请填写模块名称',
|
||||
'table_column.require' => '表字段信息缺失',
|
||||
'table_column.array' => '表字段信息类型错误',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验当前数据表是否存在
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/6/15 18:58
|
||||
*/
|
||||
protected function checkTableData($value, $rule, $data)
|
||||
{
|
||||
$table = GenerateTable::findOrEmpty($value);
|
||||
if ($table->isEmpty()) {
|
||||
return '信息不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验表字段参数
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/6/20 10:42
|
||||
*/
|
||||
protected function checkColumn($value, $rule, $data)
|
||||
{
|
||||
foreach ($value as $item) {
|
||||
if (!isset($item['id'])) {
|
||||
return '表字段id参数缺失';
|
||||
}
|
||||
if (!isset($item['query_type'])) {
|
||||
return '请选择查询方式';
|
||||
}
|
||||
if (!isset($item['view_type'])) {
|
||||
return '请选择显示类型';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\tools;
|
||||
|
||||
|
||||
use app\common\model\tools\GenerateTable;
|
||||
use app\common\validate\BaseValidate;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 代码生成选择表验证
|
||||
* Class SelectTableValidate
|
||||
* @package app\adminapi\validate\tools
|
||||
*/
|
||||
class GenerateTableValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|checkTableData',
|
||||
'table' => 'require|array|checkTable',
|
||||
'file' => 'require'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数缺失',
|
||||
'table.require' => '参数缺失',
|
||||
'table.array' => '参数类型错误',
|
||||
'file.require' => '下载失败',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 选择数据表场景
|
||||
* @return GenerateTableValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/15 18:58
|
||||
*/
|
||||
public function sceneSelect()
|
||||
{
|
||||
return $this->only(['table']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 需要校验id的场景
|
||||
* @return GenerateTableValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/15 18:58
|
||||
*/
|
||||
public function sceneId()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 下载场景
|
||||
* @return GenerateTableValidate
|
||||
* @author 段誉
|
||||
* @date 2022/6/24 10:02
|
||||
*/
|
||||
public function sceneDownload()
|
||||
{
|
||||
return $this->only(['file']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验选择的数据表信息
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/6/15 18:58
|
||||
*/
|
||||
protected function checkTable($value, $rule, $data)
|
||||
{
|
||||
foreach ($value as $item) {
|
||||
if (!isset($item['name']) || !isset($item['comment'])) {
|
||||
return '参数缺失';
|
||||
}
|
||||
$exist = Db::query("SHOW TABLES LIKE'" . $item['name'] . "'");
|
||||
if (empty($exist)) {
|
||||
return '当前数据库不存在' . $item['name'] . '表';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验当前数据表是否存在
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/6/15 18:58
|
||||
*/
|
||||
protected function checkTableData($value, $rule, $data)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
$value = [$value];
|
||||
}
|
||||
|
||||
foreach ($value as $item) {
|
||||
$table = GenerateTable::findOrEmpty($item);
|
||||
if ($table->isEmpty()) {
|
||||
return '信息不存在';
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\user;
|
||||
|
||||
use app\common\enum\user\AccountLogEnum;
|
||||
use app\common\model\user\User;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 调整用户钱包验证器
|
||||
* Class AdjustUserMoney
|
||||
* @package app\adminapi\validate\user
|
||||
*/
|
||||
class AdjustUserMoney extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'user_id' => 'require',
|
||||
'action' => 'require|in:' . AccountLogEnum::INC . ',' .AccountLogEnum::DEC,
|
||||
'num' => 'require|gt:0|checkMoney',
|
||||
'remark' => 'max:128',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择用户',
|
||||
'action.require' => '请选择调整类型',
|
||||
'action.in' => '调整类型错误',
|
||||
'num.require' => '请输入调整数量',
|
||||
'num.gt' => '调整余额必须大于零',
|
||||
'remark' => '备注不可超过128个符号',
|
||||
];
|
||||
|
||||
|
||||
protected function checkMoney($vaule, $rule, $data)
|
||||
{
|
||||
$user = User::find($data['user_id']);
|
||||
if (empty($user)) {
|
||||
return '用户不存在';
|
||||
}
|
||||
|
||||
if (1 == $data['action']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$surplusMoeny = $user->user_money - $vaule;
|
||||
if ($surplusMoeny < 0) {
|
||||
return '用户可用余额仅剩' . $user->user_money;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\adminapi\validate\user;
|
||||
|
||||
|
||||
use app\common\model\user\User;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 用户验证
|
||||
* Class UserValidate
|
||||
* @package app\adminapi\validate\user
|
||||
*/
|
||||
class UserValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|checkUser',
|
||||
'field' => 'require|checkField',
|
||||
'value' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择用户',
|
||||
'field.require' => '请选择操作',
|
||||
'value.require' => '请输入内容',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return UserValidate
|
||||
* @author 段誉
|
||||
* @date 2022/9/22 16:35
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 用户信息校验
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/9/22 17:03
|
||||
*/
|
||||
public function checkUser($value, $rule, $data)
|
||||
{
|
||||
$userIds = is_array($value) ? $value : [$value];
|
||||
|
||||
foreach ($userIds as $item) {
|
||||
if (!User::find($item)) {
|
||||
return '用户不存在!';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验是否可更新信息
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/9/22 16:37
|
||||
*/
|
||||
public function checkField($value, $rule, $data)
|
||||
{
|
||||
$allowField = ['account', 'sex', 'mobile', 'real_name'];
|
||||
|
||||
if (!in_array($value, $allowField)) {
|
||||
return '用户信息不允许更新';
|
||||
}
|
||||
|
||||
switch ($value) {
|
||||
case 'account':
|
||||
//验证手机号码是否存在
|
||||
$account = User::where([
|
||||
['id', '<>', $data['id']],
|
||||
['account', '=', $data['value']]
|
||||
])->findOrEmpty();
|
||||
|
||||
if (!$account->isEmpty()) {
|
||||
return '账号已被使用';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'mobile':
|
||||
if (false == $this->validate($data['value'], 'mobile', $data)) {
|
||||
return '手机号码格式错误';
|
||||
}
|
||||
|
||||
//验证手机号码是否存在
|
||||
$mobile = User::where([
|
||||
['id', '<>', $data['id']],
|
||||
['mobile', '=', $data['value']]
|
||||
])->findOrEmpty();
|
||||
|
||||
if (!$mobile->isEmpty()) {
|
||||
return '手机号码已存在';
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user