146 lines
4.0 KiB
PHP
146 lines
4.0 KiB
PHP
<?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\land;
|
||
|
||
|
||
use app\common\validate\BaseValidate;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* Land验证器
|
||
* Class LandValidate
|
||
* @package app\adminapi\validate\land
|
||
*/
|
||
class LandValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require',
|
||
'user_id' => 'require',
|
||
'title' => 'require',
|
||
'total_area' => 'require',
|
||
'residual_area' => 'require',
|
||
'province_code' => 'require',
|
||
'province_name' => 'require',
|
||
'city_code' => 'require',
|
||
'city_name' => 'require',
|
||
'county_code' => 'require',
|
||
'county_name' => 'require',
|
||
'town_code' => 'require',
|
||
'town_name' => 'require',
|
||
'village_code' => 'require',
|
||
'village_name' => 'require',
|
||
'group_code' => 'require',
|
||
'group_name' => 'require',
|
||
'longitude' => 'require',
|
||
'latitude' => 'require',
|
||
'master_name' => 'require',
|
||
'master_phone' => 'require',
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'user_id' => '用户id',
|
||
'title' => '土地名称',
|
||
'total_area' => '土地面积',
|
||
'residual_area' => '剩余面积',
|
||
'province_code' => '省编码',
|
||
'province_name' => '省名称',
|
||
'city_code' => '市编码',
|
||
'city_name' => '市名称',
|
||
'county_code' => '县编码',
|
||
'county_name' => '县名称',
|
||
'town_code' => '镇编码',
|
||
'town_name' => '镇名称',
|
||
'village_code' => '村编码',
|
||
'village_name' => '村名称',
|
||
'group_code' => '组编码',
|
||
'group_name' => '组名称',
|
||
'longitude' => '经度',
|
||
'latitude' => '纬度',
|
||
'master_name' => '土地负责人',
|
||
'master_phone' => '负责人电话',
|
||
'status' => '土地状态1-未种植 2-部分种植 3-全部种植',
|
||
'pic' => '土地图片',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return LandValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/22 16:35
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->only(['user_id','title','master_name','master_phone']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return LandValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/22 16:35
|
||
*/
|
||
public function sceneEdit()
|
||
{
|
||
return $this->only(['id','user_id','title','master_name','master_phone']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return LandValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/22 16:35
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id'])->append('id', 'require|checkLand');
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return LandValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/22 16:35
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkLand($value, $rule, $data)
|
||
{
|
||
$landProduct = Db::name('land_product')->where('land_id', $value)->findOrEmpty();
|
||
if (!empty($landProduct)) {
|
||
return '存在关联产品,无法删除';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
} |