<?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\bank; use app\common\model\dept\Dept; use app\common\model\dept\Orgs; use app\common\validate\BaseValidate; /** * BankAccount验证器 * Class BankAccountValidate * @package app\adminapi\validate\bank */ class BankAccountValidate extends BaseValidate { /** * 设置校验规则 * @var string[] */ protected $rule = [ 'id' => 'require', 'org_id' => 'require|checkOrg', 'dept_id' => 'require|checkDept', 'deposit_bank' => 'require', 'account_name' => 'require', 'account' => 'require', 'account_opening_date' => 'dateFormat:Y-m-d', 'opening_amount' => 'require|float|egt:0', ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', 'org_id' => '组织', 'dept_id' => '部门', 'deposit_bank' => '开户银行', 'account_name' => '开户名称', 'account' => '账号', 'account_opening_date' => '开户日期', 'opening_amount' => '期初金额', ]; /** * @notes 添加场景 * @return BankAccountValidate * @author likeadmin * @date 2023/12/20 15:04 */ public function sceneAdd() { return $this->remove('id',true); } /** * @notes 编辑场景 * @return BankAccountValidate * @author likeadmin * @date 2023/12/20 15:04 */ public function sceneEdit() {} /** * @notes 删除场景 * @return BankAccountValidate * @author likeadmin * @date 2023/12/20 15:04 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return BankAccountValidate * @author likeadmin * @date 2023/12/20 15:04 */ public function sceneDetail() { return $this->only(['id']); } public function checkOrg($value): bool|string { $org = Orgs::where('id',$value)->findOrEmpty(); if($org->isEmpty()){ return '组织不存在'; } return true; } public function checkDept($value,$rule,$data): bool|string { $dept = Dept::where('id',$value)->findOrEmpty(); if($dept->isEmpty()){ return '部门不存在'; } if($dept['org_id'] != $data['org_id']){ return '部门无效'; } return true; } }