delete no-use file #17

Merged
weiz merged 1 commits from zhangwei into dev 2023-11-25 17:36:08 +08:00
2 changed files with 0 additions and 86 deletions

View File

@ -1,52 +0,0 @@
<?php
namespace app\api\controller;
use app\common\model\device\Device;
use app\common\model\land\Land;
use app\common\model\land\LandDevice;
use think\facade\Db;
use think\response\Json;
class DeviceController extends BaseApiController
{
//绑定设备
public function bind(): Json
{
$params = $this->request->post(['land_id','device_code']);
if(empty($params['land_id']) || empty($params['device_code'])) {
return $this->fail('缺少必要参数');
}
$land = Land::where('id',$params['land_id'])->findOrEmpty();
if($land->isEmpty()){
return $this->fail('土地信息错误');
}
$device = Device::where('code',$params['device_code'])->findOrEmpty();
if($device->isEmpty()){
return $this->fail('设备不存在');
}
if($device['is_bind'] == 2){
return $this->fail('当前设备已被绑定');
}
$landDevice = LandDevice::where('land_id',$land['id'])->where('device_type',$device['type'])->findOrEmpty();
if(!$landDevice->isEmpty()){
$msg = $device['type'] == 1 ? '土壤监测设备' : ($device['type'] == 2 ? '环境监测设备' : '视频监控设备');
return $this->fail('该土地已绑定'.$msg);
}
Db::transaction(function()use($land,$device) {
Device::where('id',$device['id'])->update([
'is_bind' => 2,
'user_id' => $land['user_id'],
'update_time' => time()
]);
LandDevice::create([
'land_id' => $land['id'],
'device_id' => $device['id'],
'device_type' => $device['type'],
'create_time' => time(),
'update_time' => time()
]);
});
return $this->success('设备绑定成功');
}
}

View File

@ -1,34 +0,0 @@
<?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\common\model\land;
use app\common\model\BaseModel;
/**
* LandPlant模型
* Class LandPlant
* @package app\common\model\land
*/
class LandDevice extends BaseModel
{
protected $name = 'land_device';
}