Video.php
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
namespace app\equipment\controller;
use app\common\controller\Frontend;
use think\Db;
class Video extends Frontend
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $layout = '';
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\reservoir\hkws\Hardware;
}
public function list()
{
$list = $this->model
->alias('h')
->join('reservoir_list r','r.id=h.reservoir_id','LEFT')
->field('h.*,r.name as reservoir')
->order('id desc')
->paginate(10,'',['query'=>$this->request->param()]);
$this->view->assign([
'list'=>$list,
'reservoir_list' => Db::name('reservoir_list')->field('id,name')->where('county_id',1)->select()
]);
return $this->view->fetch();
}
public function add()
{
if($this->request->isPost()){
$params = $this->request->post('row/a');
if($params){
if (!$params['name']){
$this->error('设备名称不能为空');
}
if (!$params['rcode']) {
$this->error('注册码不能为空');
}
if (!$params['vcode']) {
$this->error('验证码不能为空');
}
if (!$params['scode']) {
$this->error('序列号不能为空');
}
$params['province_id'] = $params['state_id'] = $params['county_id'] = 1;
$params['createtime'] = time();
$result = $this->model->allowField(true)->save($params);
if(!$result){
$this->error('网络繁忙');
}
$this->success('添加成功');
}
}
}
public function edit($ids=null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error('数据不存在');
}
if ($this->request->isPost()) {
$params = $this->request->post('row/a');
if (!$params['name']){
$this->error('设备名称不能为空');
}
if (!$params['rcode']) {
$this->error('注册码不能为空');
}
if (!$params['vcode']) {
$this->error('验证码不能为空');
}
if (!$params['scode']) {
$this->error('序列号不能为空');
}
$result = $row->allowField(true)->save($params);
if (!$result) {
$this->error('网络繁忙,更新失败');
}
$this->success('更新成功');
}
return json(['code'=>1,'data'=>$row]);
}
public function del($ids=null)
{
$m = $this->model->get($ids);
$res = $m->delete(true);
if(!$res){
$this->error('网络繁忙');
}
$this->success('删除成功');
}
public function getinfo()
{
$id = input('?post.id');
$list = $this->model
->alias('h')
->join('reservoir_list r','r.id=h.reservoir_id')
->field('h.*,r.name as reservoir')
// ->where('h.id',$id)
->select();
var_dump($list);
}
}