2023-11-22 18:11:03 +08:00
|
|
|
|
<?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;
|
2023-11-28 13:51:06 +08:00
|
|
|
|
use think\facade\Db;
|
2023-11-22 18:11:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Land验证器
|
|
|
|
|
* Class LandValidate
|
|
|
|
|
* @package app\adminapi\validate\land
|
|
|
|
|
*/
|
|
|
|
|
class LandValidate extends BaseValidate
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置校验规则
|
|
|
|
|
* @var string[]
|
|
|
|
|
*/
|
|
|
|
|
protected $rule = [
|
2023-11-23 11:13:45 +08:00
|
|
|
|
'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',
|
2023-11-22 18:11:03 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 参数描述
|
|
|
|
|
* @var string[]
|
|
|
|
|
*/
|
|
|
|
|
protected $field = [
|
2023-11-23 11:13:45 +08:00
|
|
|
|
'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-全部种植',
|
2023-11-28 11:18:56 +08:00
|
|
|
|
'pic' => '土地图片',
|
2023-11-22 18:11:03 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 添加场景
|
|
|
|
|
* @return LandValidate
|
|
|
|
|
* @author likeadmin
|
|
|
|
|
* @date 2023/11/22 16:35
|
|
|
|
|
*/
|
|
|
|
|
public function sceneAdd()
|
|
|
|
|
{
|
2023-11-23 11:13:45 +08:00
|
|
|
|
return $this->only(['user_id','title','master_name','master_phone']);
|
2023-11-22 18:11:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 编辑场景
|
|
|
|
|
* @return LandValidate
|
|
|
|
|
* @author likeadmin
|
|
|
|
|
* @date 2023/11/22 16:35
|
|
|
|
|
*/
|
|
|
|
|
public function sceneEdit()
|
|
|
|
|
{
|
2023-11-23 11:13:45 +08:00
|
|
|
|
return $this->only(['id','user_id','title','master_name','master_phone']);
|
2023-11-22 18:11:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 删除场景
|
|
|
|
|
* @return LandValidate
|
|
|
|
|
* @author likeadmin
|
|
|
|
|
* @date 2023/11/22 16:35
|
|
|
|
|
*/
|
|
|
|
|
public function sceneDelete()
|
|
|
|
|
{
|
2023-11-28 13:51:58 +08:00
|
|
|
|
return $this->only(['id'])->append('id', 'require|checkLand');
|
2023-11-22 18:11:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 详情场景
|
|
|
|
|
* @return LandValidate
|
|
|
|
|
* @author likeadmin
|
|
|
|
|
* @date 2023/11/22 16:35
|
|
|
|
|
*/
|
|
|
|
|
public function sceneDetail()
|
|
|
|
|
{
|
|
|
|
|
return $this->only(['id']);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-28 13:51:06 +08:00
|
|
|
|
public function checkLand($value, $rule, $data)
|
|
|
|
|
{
|
|
|
|
|
$landProduct = Db::name('land_product')->where('land_id', $value)->findOrEmpty();
|
|
|
|
|
if (!empty($landProduct)) {
|
|
|
|
|
return '存在关联产品,无法删除';
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-22 18:11:03 +08:00
|
|
|
|
}
|