diff --git a/admin/src/api/land.ts b/admin/src/api/land.ts index b251e26c..91a62335 100644 --- a/admin/src/api/land.ts +++ b/admin/src/api/land.ts @@ -5,9 +5,13 @@ export function getUserList(params: any) { return request.get({ url: '/user.user/lists', params }, { ignoreCancelToken: true }) } +// 产品列表列表 +export function apiProductLists(params: any) { + return request.get({ url: '/land.product/lists', params }) +} + // 土地表列表 export function apiLandLists(params: any) { - console.log(params) return request.get({ url: '/land.land/lists', params }) } @@ -29,4 +33,9 @@ export function apiLandDelete(params: any) { // 土地表详情 export function apiLandDetail(params: any) { return request.get({ url: '/land.land/detail', params }) +} + +// 绑定产品 +export function apiLandBind(params: any) { + return request.post({ url: '/land.land/bind', params }) } \ No newline at end of file diff --git a/admin/src/api/land_plant.ts b/admin/src/api/land_plant.ts index 20f361c1..38c4455d 100644 --- a/admin/src/api/land_plant.ts +++ b/admin/src/api/land_plant.ts @@ -7,7 +7,6 @@ export function getUserList(params: any) { // 土地表列表 export function apiLandLists(params: any) { - console.log(params) return request.get({ url: '/land.land/lists', params }) } diff --git a/admin/src/api/product.ts b/admin/src/api/product.ts index 8bee7081..b197a598 100644 --- a/admin/src/api/product.ts +++ b/admin/src/api/product.ts @@ -7,7 +7,6 @@ export function getUserList(params: any) { // 土地表列表 export function apiLandLists(params: any) { - console.log(params) return request.get({ url: '/land.land/lists', params }) } @@ -16,6 +15,12 @@ export function apiProductLists(params: any) { return request.get({ url: '/land.product/lists', params }) } +// 监测设备列表 +export function apiDeviceLists(params: any) { + return request.get({ url: '/device.device/lists', params }) +} + + // 添加产品列表 export function apiProductAdd(params: any) { return request.post({ url: '/land.product/add', params }) @@ -34,4 +39,9 @@ export function apiProductDelete(params: any) { // 产品列表详情 export function apiProductDetail(params: any) { return request.get({ url: '/land.product/detail', params }) +} + +// 绑定设备 +export function apiProductBind(params: any) { + return request.post({ url: '/land.product/bind', params }) } \ No newline at end of file diff --git a/admin/src/views/device/detail.vue b/admin/src/views/device/detail.vue index 0d0159d5..88c83570 100644 --- a/admin/src/views/device/detail.vue +++ b/admin/src/views/device/detail.vue @@ -46,12 +46,6 @@ -
-
是否绑定产品:
-
- -
-
diff --git a/admin/src/views/device/edit.vue b/admin/src/views/device/edit.vue index add3e7c6..98d0329d 100644 --- a/admin/src/views/device/edit.vue +++ b/admin/src/views/device/edit.vue @@ -9,25 +9,20 @@ @close="handleClose" > - - - - + + - + + + + + + - + - - - - - - - - @@ -93,16 +75,6 @@ :value="parseInt(item.value)" /> - - - - - @@ -135,7 +107,6 @@ const popupTitle = computed(() => { // 表单数据 const formData = reactive({ id: '', - user_id: '', product_id: '', code: '', name: '', @@ -144,22 +115,10 @@ const formData = reactive({ monitor_item: '', status: '', is_online: '', - is_bind: '', }) - // 表单验证 const formRules = reactive({ - user_id: [{ - required: true, - message: '请输入用户ID', - trigger: ['blur'] - }], - product_id: [{ - required: true, - message: '请输入产品id', - trigger: ['blur'] - }], code: [{ required: true, message: '请输入设备编码', @@ -185,11 +144,6 @@ const formRules = reactive({ message: '请选择是否在线', trigger: ['blur'] }], - is_bind: [{ - required: true, - message: '请选择是否绑定土地', - trigger: ['blur'] - }], }) @@ -208,29 +162,8 @@ interface ListItem { label: string } const productOptions = ref([]) -const userOptions = ref([]) const loading = ref(false) -const queryUser = async (query: string) => { - if (query) { - loading.value = true - const userList = await getUserList({ - keyword: query - }) - loading.value = false - if (userList.count > 0) { - userOptions.value = userList.lists.map((user: any) => { - return { value: `${user.id}`, label: `ID: ${user.id} / 账户: ${user.account}` } - }) - } else { - userOptions.value = [] - } - loading.value = false - } else { - userOptions.value = [] - } -} - const queryProduct = async (query: string) => { if (query) { loading.value = true diff --git a/admin/src/views/device/index.vue b/admin/src/views/device/index.vue index e8819089..cae54d3b 100644 --- a/admin/src/views/device/index.vue +++ b/admin/src/views/device/index.vue @@ -58,17 +58,6 @@ :value="item.value" /> - - - - - - 查询 @@ -128,11 +117,6 @@ - - - + + diff --git a/admin/src/views/land/edit.vue b/admin/src/views/land/edit.vue index 5246023c..9e54d2f0 100644 --- a/admin/src/views/land/edit.vue +++ b/admin/src/views/land/edit.vue @@ -9,7 +9,7 @@ @close="handleClose" > - + + + + @@ -71,12 +74,6 @@ - - - - - - @@ -118,6 +115,7 @@ const popupTitle = computed(() => { const formData = reactive({ id: '', user_id: '', + root: 0, title: '', total_area: '', residual_area: '', @@ -133,25 +131,24 @@ const formData = reactive({ village_name: '', group_code: '', group_name: '', - longitude: '', - latitude: '', master_name: '', master_phone: '', + address: '', pic: '' }) // 表单验证 const formRules = reactive({ - user_id: [{ - required: true, - message: '请输入用户ID', - trigger: ['blur'] - }], title: [{ required: true, message: '请输入土地名称', trigger: ['blur'] }], + address: [{ + required: true, + message: '请输入详细地址', + trigger: ['blur'] + }], master_name: [{ required: true, message: '请输入土地负责人', diff --git a/admin/src/views/land/index.vue b/admin/src/views/land/index.vue index 2682404b..5118aede 100644 --- a/admin/src/views/land/index.vue +++ b/admin/src/views/land/index.vue @@ -49,16 +49,12 @@ 账户: {{ row.user.account }} --> - - - + - + - + @@ -134,11 +143,15 @@ import { apiProductLists, apiProductDelete } from '@/api/product' import { timeFormat } from '@/utils/util' import feedback from '@/utils/feedback' import EditPopup from './edit.vue' +import BindPopup from './bind.vue' const { query } = useRoute() const editRef = shallowRef>() + + const bindRef = shallowRef>() // 是否显示编辑框 const showEdit = ref(false) +const bindEdit = ref(false) let land_id = query.land_id if (typeof land_id == 'undefined') { @@ -188,6 +201,14 @@ const handleEdit = async (data: any) => { editRef.value?.setFormData(data) } +// 绑定 +const handleBind = async (data: any) => { + bindEdit.value = true + await nextTick() + bindRef.value?.open('bind') + bindRef.value?.setFormData(data) +} + // 删除 const handleDelete = async (id: number | any[]) => { await feedback.confirm('确定要删除?') diff --git a/app/adminapi/controller/land/LandController.php b/app/adminapi/controller/land/LandController.php index 034d11d3..f8b52c8f 100644 --- a/app/adminapi/controller/land/LandController.php +++ b/app/adminapi/controller/land/LandController.php @@ -104,5 +104,18 @@ class LandController extends BaseAdminController return $this->data($result); } + /** + * @notes 绑定产品 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/22 16:35 + */ + public function bind() + { + $params = (new LandValidate())->post()->goCheck('bind'); + LandLogic::bind($params); + return $this->success('绑定成功', [], 1, 1); + } + } \ No newline at end of file diff --git a/app/adminapi/controller/land/ProductController.php b/app/adminapi/controller/land/ProductController.php index 5707030d..2330cf72 100644 --- a/app/adminapi/controller/land/ProductController.php +++ b/app/adminapi/controller/land/ProductController.php @@ -16,9 +16,9 @@ namespace app\adminapi\controller\land; -use app\adminapi\controller\BaseAdminController; -use app\adminapi\lists\land\ProductLists; -use app\adminapi\logic\land\ProductLogic; +use app\adminapi\controller\BaseAdminController; +use app\adminapi\lists\land\ProductLists; +use app\adminapi\logic\land\ProductLogic; use app\adminapi\validate\land\ProductValidate; @@ -104,5 +104,17 @@ class ProductController extends BaseAdminController return $this->data($result); } + /** + * @notes 绑定产品 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/22 16:35 + */ + public function bind() + { + $params = (new ProductValidate())->post()->goCheck('bind'); + ProductLogic::bind($params); + return $this->success('绑定成功', [], 1, 1); + } } \ No newline at end of file diff --git a/app/adminapi/lists/land/LandLists.php b/app/adminapi/lists/land/LandLists.php index 147f3718..53d35ab8 100644 --- a/app/adminapi/lists/land/LandLists.php +++ b/app/adminapi/lists/land/LandLists.php @@ -68,11 +68,15 @@ class LandLists extends BaseAdminDataLists implements ListsSearchInterface */ public function lists(): array { + return Land::where($this->searchWhere)->where($this->userSearch())->with('user') - ->field(['id', 'user_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', 'pic']) + ->field(['id', 'user_id', 'title', 'address', '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', 'master_name', 'master_phone', 'pic']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select() + ->select()->each(function($item, $key){ + $item['root'] = $this->adminInfo['root'] ?? 0; + return $item; + }) ->toArray(); } diff --git a/app/adminapi/logic/device/DeviceLogic.php b/app/adminapi/logic/device/DeviceLogic.php index 09a4bdd8..4d7d39c4 100644 --- a/app/adminapi/logic/device/DeviceLogic.php +++ b/app/adminapi/logic/device/DeviceLogic.php @@ -43,26 +43,31 @@ class DeviceLogic extends BaseLogic } else { $params['monitor_item'] = trim($params['monitor_item']); } + $userId = (request()->adminInfo)['user_id']; + if (!empty($params['product_id'])) { + $userId = Db::name('product')->where('id', $params['product_id'])->value('user_id'); + } Db::startTrans(); try { $device = Device::create([ - 'user_id' => $params['user_id'], + 'user_id' => $userId, 'code' => $params['code'], 'name' => $params['name'], 'type' => $params['type'], 'monitor_item' => $params['monitor_item'], 'video_url' => $params['video_url'], 'status' => $params['status'], - 'is_online' => $params['is_online'], - 'is_bind' => $params['is_bind'], - ]); - Db::name('product_device')->insert([ - 'product_id' => $params['product_id'], - 'device_id' => $device['id'], - 'device_type' => $params['type'], - 'create_time' => time(), - 'update_time' => time() + 'is_online' => $params['is_online'] ]); + if (!empty($params['product_id'])) { + Db::name('product_device')->insert([ + 'product_id' => $params['product_id'], + 'device_id' => $device['id'], + 'device_type' => $params['type'], + 'create_time' => time(), + 'update_time' => time() + ]); + } Db::commit(); return true; } catch (\Exception $e) { @@ -87,27 +92,32 @@ class DeviceLogic extends BaseLogic } else { $params['monitor_item'] = trim($params['monitor_item']); } + $userId = (request()->adminInfo)['user_id']; + if (!empty($params['product_id'])) { + $userId = Db::name('product')->where('id', $params['product_id'])->value('user_id'); + } Db::startTrans(); try { $device = Device::where('id', $params['id'])->update([ - 'user_id' => $params['user_id'], + 'user_id' => $userId, 'code' => $params['code'], 'name' => $params['name'], 'type' => $params['type'], 'monitor_item' => $params['monitor_item'], 'video_url' => $params['video_url'], 'status' => $params['status'], - 'is_online' => $params['is_online'], - 'is_bind' => $params['is_bind'], + 'is_online' => $params['is_online'] ]); Db::name('product_device')->where('device_id', $params['id'])->delete(); - Db::name('product_device')->insert([ - 'product_id' => $params['product_id'], - 'device_id' => $params['id'], - 'device_type' => $params['type'], - 'create_time' => time(), - 'update_time' => time() - ]); + if (!empty($params['product_id'])) { + Db::name('product_device')->insert([ + 'product_id' => $params['product_id'], + 'device_id' => $params['id'], + 'device_type' => $params['type'], + 'create_time' => time(), + 'update_time' => time() + ]); + } Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/adminapi/logic/land/LandLogic.php b/app/adminapi/logic/land/LandLogic.php index e9a60b4d..7fc3f37f 100644 --- a/app/adminapi/logic/land/LandLogic.php +++ b/app/adminapi/logic/land/LandLogic.php @@ -38,11 +38,16 @@ class LandLogic extends BaseLogic */ public static function add(array $params): bool { + $userId = (request()->adminInfo)['user_id']; + if (!empty($params['user_id'])) { + $userId = $params['user_id']; + } Db::startTrans(); try { Land::create([ - 'user_id' => $params['user_id'], + 'user_id' => $userId, 'title' => $params['title'], + 'address' => $params['address'], 'total_area' => $params['total_area'], 'residual_area' => $params['residual_area'], 'province_code' => $params['province_code'], @@ -57,8 +62,6 @@ class LandLogic extends BaseLogic 'village_name' => $params['village_name'], 'group_code' => $params['group_code'], 'group_name' => $params['group_name'], - 'longitude' => $params['longitude'], - 'latitude' => $params['latitude'], 'master_name' => $params['master_name'], 'master_phone' => $params['master_phone'], 'pic' => json_encode($params['pic']), @@ -83,11 +86,16 @@ class LandLogic extends BaseLogic */ public static function edit(array $params): bool { + $userId = (request()->adminInfo)['user_id']; + if (!empty($params['user_id'])) { + $userId = $params['user_id']; + } Db::startTrans(); try { Land::where('id', $params['id'])->update([ - 'user_id' => $params['user_id'], + 'user_id' => $userId, 'title' => $params['title'], + 'address' => $params['address'], 'total_area' => $params['total_area'], 'residual_area' => $params['residual_area'], 'province_code' => $params['province_code'], @@ -101,9 +109,7 @@ class LandLogic extends BaseLogic 'village_code' => $params['village_code'], 'village_name' => $params['village_name'], 'group_code' => $params['group_code'], - 'group_name' => $params['group_name'], - 'longitude' => $params['longitude'], - 'latitude' => $params['latitude'], + 'group_name' => $params['group_name'], 'master_name' => $params['master_name'], 'master_phone' => $params['master_phone'], 'pic' => json_encode($params['pic']), @@ -143,4 +149,33 @@ class LandLogic extends BaseLogic { return Land::findOrEmpty($params['id'])->toArray(); } + + public static function bind($params): bool + { + $userId = (request()->adminInfo)['user_id']; + if (!empty($params['id'])) { + $userId = Db::name('land')->where('id', $params['id'])->value('user_id'); + } + Db::startTrans(); + try { + Db::name('product')->where('id', $params['product_id'])->update([ + 'user_id' => $userId, + 'status' => 2 + ]); + Db::name('land_product')->where('land_id', $params['id'])->delete(); + Db::name('land_product')->where('product_id', $params['product_id'])->delete(); + Db::name('land_product')->insert([ + 'land_id' => $params['id'], + 'product_id' => $params['product_id'], + 'create_time' => time(), + 'update_time' => time() + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } } \ No newline at end of file diff --git a/app/adminapi/logic/land/LandPlantActionLogic.php b/app/adminapi/logic/land/LandPlantActionLogic.php index 298136da..588ea419 100644 --- a/app/adminapi/logic/land/LandPlantActionLogic.php +++ b/app/adminapi/logic/land/LandPlantActionLogic.php @@ -38,10 +38,11 @@ class LandPlantActionLogic extends BaseLogic */ public static function add(array $params): bool { + $userId = Db::name('land_plant')->where('id', $params['plant_id'])->value('user_id'); Db::startTrans(); try { LandPlantAction::create([ - 'user_id' => $params['user_id'], + 'user_id' => $userId, 'plant_id' => $params['plant_id'], 'type' => $params['type'], 'type_text' => $params['type_text'], @@ -67,10 +68,11 @@ class LandPlantActionLogic extends BaseLogic */ public static function edit(array $params): bool { + $userId = Db::name('land_plant')->where('id', $params['plant_id'])->value('user_id'); Db::startTrans(); try { LandPlantAction::where('id', $params['id'])->update([ - 'user_id' => $params['user_id'], + 'user_id' => $userId, 'plant_id' => $params['plant_id'], 'type' => $params['type'], 'type_text' => $params['type_text'], diff --git a/app/adminapi/logic/land/LandPlantLogic.php b/app/adminapi/logic/land/LandPlantLogic.php index 9a7debcd..65d6f706 100644 --- a/app/adminapi/logic/land/LandPlantLogic.php +++ b/app/adminapi/logic/land/LandPlantLogic.php @@ -28,7 +28,6 @@ use think\facade\Db; class LandPlantLogic extends BaseLogic { - /** * @notes 添加 * @param array $params @@ -38,10 +37,11 @@ class LandPlantLogic extends BaseLogic */ public static function add(array $params): bool { + $userId = Db::name('land')->where('id', $params['land_id'])->value('user_id'); Db::startTrans(); try { LandPlant::create([ - 'user_id' => $params['user_id'], + 'user_id' => $userId, 'land_id' => $params['land_id'], 'kind' => $params['kind'], 'breed' => $params['breed'], @@ -73,10 +73,11 @@ class LandPlantLogic extends BaseLogic */ public static function edit(array $params): bool { + $userId = Db::name('land')->where('id', $params['land_id'])->value('user_id'); Db::startTrans(); try { LandPlant::where('id', $params['id'])->update([ - 'user_id' => $params['user_id'], + 'user_id' => $userId, 'land_id' => $params['land_id'], 'kind' => $params['kind'], 'breed' => $params['breed'], diff --git a/app/adminapi/logic/land/ProductLogic.php b/app/adminapi/logic/land/ProductLogic.php index c2de4658..bec1ea07 100644 --- a/app/adminapi/logic/land/ProductLogic.php +++ b/app/adminapi/logic/land/ProductLogic.php @@ -38,20 +38,28 @@ class ProductLogic extends BaseLogic */ public static function add(array $params): bool { + $userId = (request()->adminInfo)['user_id']; + $status = 1; + if (!empty($params['land_id'])) { + $userId = Db::name('land')->where('id', $params['land_id'])->value('user_id'); + $status = 2; + } Db::startTrans(); try { $product = Product::create([ - 'user_id' => $params['user_id'], + 'user_id' => $userId, 'code' => $params['code'], 'name' => $params['name'], - 'status' => $params['status'], - ]); - Db::name('land_product')->insert([ - 'land_id' => $params['land_id'], - 'product_id' => $product['id'], - 'create_time' => time(), - 'update_time' => time() + 'status' => $status, ]); + if (!empty($params['land_id'])) { + Db::name('land_product')->insert([ + 'land_id' => $params['land_id'], + 'product_id' => $product['id'], + 'create_time' => time(), + 'update_time' => time() + ]); + } Db::commit(); return true; } catch (\Exception $e) { @@ -71,21 +79,29 @@ class ProductLogic extends BaseLogic */ public static function edit(array $params): bool { + $userId = (request()->adminInfo)['user_id']; + $status = 1; + if (!empty($params['land_id'])) { + $userId = Db::name('land')->where('id', $params['land_id'])->value('user_id'); + $status = 2; + } Db::startTrans(); try { Product::where('id', $params['id'])->update([ - 'user_id' => $params['user_id'], + 'user_id' => $userId, 'code' => $params['code'], 'name' => $params['name'], - 'status' => $params['status'], + 'status' => $status, ]); Db::name('land_product')->where('product_id', $params['id'])->delete(); - Db::name('land_product')->insert([ - 'land_id' => $params['land_id'], - 'product_id' => $params['id'], - 'create_time' => time(), - 'update_time' => time() - ]); + if (!empty($params['land_id'])) { + Db::name('land_product')->insert([ + 'land_id' => $params['land_id'], + 'product_id' => $params['id'], + 'create_time' => time(), + 'update_time' => time() + ]); + } Db::commit(); return true; } catch (\Exception $e) { @@ -122,4 +138,38 @@ class ProductLogic extends BaseLogic { return Product::findOrEmpty($params['id'])->toArray(); } + + public static function bind($params): bool + { + $userId = (request()->adminInfo)['user_id']; + if (!empty($params['id'])) { + $userId = Db::name('product')->where('id', $params['id'])->value('user_id'); + } + Db::startTrans(); + try { + Db::name('product_device')->whereIn('device_id', $params['device_id'])->delete(); + Db::name('product_device')->where('product_id', $params['id'])->delete(); + Db::name('device')->whereIn('id', $params['device_id'])->update([ + 'user_id' => $userId + ]); + $deviceList = Db::name('device')->whereIn('id', $params['device_id'])->select()->toArray(); + $insertData = []; + foreach($deviceList as $d) { + $insertData[] = [ + 'product_id' => $params['id'], + 'device_id' => $d['id'], + 'device_type' => $d['type'], + 'create_time' => time(), + 'update_time' => time() + ]; + } + Db::name('product_device')->insertAll($insertData); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } } \ No newline at end of file diff --git a/app/adminapi/validate/land/LandValidate.php b/app/adminapi/validate/land/LandValidate.php index 40ae07f5..850afe45 100644 --- a/app/adminapi/validate/land/LandValidate.php +++ b/app/adminapi/validate/land/LandValidate.php @@ -33,10 +33,10 @@ class LandValidate extends BaseValidate */ protected $rule = [ 'id' => 'require', - 'user_id' => 'require', + 'product_id' => 'require', 'title' => 'require', - 'total_area' => 'require', - 'residual_area' => 'require', + 'address' => 'require', + 'residual_area' => 'checkArea', 'province_code' => 'require', 'province_name' => 'require', 'city_code' => 'require', @@ -62,8 +62,8 @@ class LandValidate extends BaseValidate */ protected $field = [ 'id' => 'id', - 'user_id' => '用户id', 'title' => '土地名称', + 'address' => '详细地址', 'total_area' => '土地面积', 'residual_area' => '剩余面积', 'province_code' => '省编码', @@ -82,7 +82,7 @@ class LandValidate extends BaseValidate 'latitude' => '纬度', 'master_name' => '土地负责人', 'master_phone' => '负责人电话', - 'status' => '土地状态1-未种植 2-部分种植 3-全部种植', + 'status' => '土地状态', 'pic' => '土地图片', ]; @@ -95,7 +95,7 @@ class LandValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['user_id','title','master_name','master_phone']); + return $this->only(['title','address','residual_area','master_name','master_phone']); } @@ -107,7 +107,7 @@ class LandValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id','user_id','title','master_name','master_phone']); + return $this->only(['id','title','address','residual_area','master_name','master_phone']); } @@ -143,4 +143,25 @@ class LandValidate extends BaseValidate return true; } + /** + * @notes 绑定产品 + * @return LandValidate + * @author likeadmin + * @date 2023/11/22 16:35 + */ + public function sceneBind() + { + return $this->only(['id', 'product_id']); + } + + public function checkArea($value, $rule, $data) + { + if (!empty($data['total_area']) && !empty($data['residual_area'])) { + if ($data['residual_area'] > $data['total_area']) { + return '剩余面积不能大于总面积'; + } + } + return true; + } + } \ No newline at end of file diff --git a/app/adminapi/validate/land/ProductValidate.php b/app/adminapi/validate/land/ProductValidate.php index 9a98f7ea..be4d1f22 100644 --- a/app/adminapi/validate/land/ProductValidate.php +++ b/app/adminapi/validate/land/ProductValidate.php @@ -32,23 +32,19 @@ class ProductValidate extends BaseValidate */ protected $rule = [ 'id' => 'require', - 'user_id' => 'require', + 'device_id' => 'require', 'code' => 'require', 'name' => 'require', - 'status' => 'require', ]; - /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', - 'user_id' => '用户id', 'code' => '产品编号', 'name' => '产品名称', - 'status' => '产品状态', ]; @@ -60,7 +56,7 @@ class ProductValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['user_id','code','name','status']); + return $this->only(['code','name']); } @@ -72,7 +68,7 @@ class ProductValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id','user_id','code','name','status']); + return $this->only(['id','code','name']); } @@ -108,4 +104,15 @@ class ProductValidate extends BaseValidate return true; } + /** + * @notes 绑定设备 + * @return LandValidate + * @author likeadmin + * @date 2023/11/22 16:35 + */ + public function sceneBind() + { + return $this->only(['id', 'device_id']); + } + } \ No newline at end of file