2023-11-13 16:10:19 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\common\validate\user;
|
|
|
|
|
|
|
|
|
|
|
|
use app\common\enum\notice\NoticeEnum;
|
|
|
|
use app\common\model\systems\System;
|
|
|
|
use app\common\validate\BaseValidate;
|
|
|
|
|
|
|
|
class SystemUserValidate extends BaseValidate
|
|
|
|
{
|
|
|
|
protected $rule = [
|
|
|
|
'app_id' => 'require|checkApp',
|
|
|
|
'system_user_id' => 'require',
|
|
|
|
];
|
|
|
|
|
|
|
|
protected $message = [
|
|
|
|
'app_id.require' => '应用id不能为空',
|
|
|
|
'system_user_id.require' => '应用用户id不能为空'
|
|
|
|
];
|
|
|
|
|
|
|
|
public function sceneBind(): SystemUserValidate
|
|
|
|
{
|
|
|
|
return $this->only(['app_id', 'system_user_id']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkApp($appid): bool|string
|
|
|
|
{
|
2023-11-13 16:56:29 +08:00
|
|
|
$app = System::field('id, status, register_status')->where('app_id',$appid)->findOrEmpty();
|
2023-11-13 16:19:48 +08:00
|
|
|
if ($app->isEmpty()) {
|
2023-11-13 16:10:19 +08:00
|
|
|
return '应用错误';
|
|
|
|
}
|
|
|
|
if ($app['status'] != 0) {
|
|
|
|
return '应用已禁止或删除';
|
|
|
|
}
|
2023-11-13 16:56:29 +08:00
|
|
|
if ($app['register_status'] != 1) {
|
|
|
|
return '应用未开启注册';
|
|
|
|
}
|
2023-11-13 16:10:19 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|