| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- // +----------------------------------------------------------------------
- // | whitef快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/whitef
- // | github下载:https://github.com/likeshop-github/whitef
- // | 访问官网:https://www.whitef.cn
- // | whitef团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: whitefTeam
- // +----------------------------------------------------------------------
- namespace app\workerapi\validate;
- use app\common\model\user\User;
- use app\common\validate\BaseValidate;
- /**
- * 设置工程师信息
- */
- class SetMasterWorkerInfoValidate extends BaseValidate
- {
- protected $rule = [
- 'field' => 'require|checkField',
- 'value' => 'require',
- ];
- protected $message = [
- 'field.require' => '参数缺失',
- 'value.require' => '值不存在',
- ];
- /**
- * @notes 校验字段内容
- * @param $value
- * @param $rule
- * @param $data
- * @return bool|string
- * @author 段誉
- * @date 2022/9/21 17:01
- */
- protected function checkField($value, $rule, $data)
- {
- $allowField = [
- 'nickname', 'account', 'sex', 'avatar', 'real_name',
- ];
- if (!in_array($value, $allowField)) {
- return '参数错误';
- }
- if ($value == 'account') {
- $user = User::where([
- ['account', '=', $data['value']],
- ['id', '<>', $data['id']]
- ])->findOrEmpty();
- if (!$user->isEmpty()) {
- return '账号已被使用!';
- }
- }
- return true;
- }
- }
|