-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFireController.php
152 lines (137 loc) · 4.28 KB
/
FireController.php
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/**
* Created by PhpStorm.
* User: XieLe
* Date: 2018/5/16
* Time: 11:16
*/
namespace app\fire\controller;
use app\fire\logic\FireLogic;
use app\fire\validate\BaseValidate;
use think\Controller;
use Workerman\Worker;
class FireController extends controller
{
/**
* 新增火情上报
* @return string|\think\response\Json
*/
function addFireUpload(){
/*$auth = Common::auth();
if (!$auth[0]) return Common::reJson($auth);*/
$data = $_POST;
$dbRes = FireLogic::saveFireUpload($data);
return Common::reJson($dbRes);
}
/**
* 火情查询列表3
* @return string|\think\response\Json
* @throws \think\exception\DbException
*/
function getFireUploadList(){
$auth = Common::auth();
if (!$auth[0]) return Common::reJson($auth);
$data = input('post.');
$validate = new BaseValidate([
'per_page' => 'require|number|max:50|min:1',
'current_page' => 'require|number|min:1',
'region'=>'require|region',
'status' => 'require|in:1,2,3',
'fire_level'=>'in:1,2,3,4',
'fire_type'=>'in:1,2,3',
'begin_time'=>'dateFormat:Y-m-d',
'end_time'=>'dateFormat:Y-m-d'
]);
if (!$validate->check($data)) return Common::reJson(Errors::Error($validate->getError()));
$result = FireLogic::queryFireUploadList($data);
return Common::reJson($result);
}
/**
* 获得火情上报信息
* @return string|\think\response\Json
*/
function getFireUploadInfo(){
$auth = Common::auth();
if (!$auth[0]) return Common::reJson($auth);
$data = input('post.');
$validate = new BaseValidate([
'id' => 'require|number'
]);
if (!$validate->check($data)) return Common::reJson(Errors::Error($validate->getError()));
$result = FireLogic::queryFireUploadInfo($data['id']);
return Common::reJson($result);
}
/**
* 软删除火情
* @return string|\think\response\Json
*/
function delFire(){
$auth = Common::auth(1);
if (!$auth[0]) return Common::reJson($auth);
$data = input('post.');
$validate = new BaseValidate([
'id' => 'require|number'
]);
if (!$validate->check($data)) return Common::reJson(Errors::Error($validate->getError()));
$result = FireLogic::deleteFire($data['id']);
return Common::reJson($result);
}
/**
* 修改火情上报
* @return string|\think\response\Json
*/
function editFireUpload(){
$auth = Common::auth();
if (!$auth[0]) return Common::reJson($auth);
$data = $_POST;
$result = FireLogic::updateFireUpload($data);
return Common::reJson($result);
}
/**
* 获得火情热力图
* @return string|\think\response\Json
*/
function getFireHeatMap(){
$auth = Common::auth();
if (!$auth[0]) return Helper::reJson($auth);
$result = FireLogic::queryFireHeatMap($auth['region']);
return Common::reJson($result);
}
/**
* 新增火情跟踪
* @return string|\think\response\Json
*/
function addFireTrace(){
$auth = Common::auth();
if (!$auth[0]) return Common::reJson($auth);
$data = $_POST;
$dbRes = FireLogic::saveFireUpload($data);
return Common::reJson($dbRes);
}
/**
* 获得火情上报信息
* @return string|\think\response\Json
*/
function getFireTraceInfo(){
$auth = Common::auth();
if (!$auth[0]) return Common::reJson($auth);
$data = input('post.');
$validate = new BaseValidate([
'id' => 'require|number'
]);
if (!$validate->check($data)) return Common::reJson(Errors::Error($validate->getError()));
$result = FireLogic::queryFireUploadInfo($data['id']);
return Common::reJson($result);
}
/**
* 修改火情跟踪信息
* @return string|\think\response\Json
*/
function editFireTrace(){
$auth = Common::auth();
if (!$auth[0]) return Common::reJson($auth);
$data = $_POST;
$result = FireLogic::updateFireUpload($data);
return Common::reJson($result);
}
}