Order.php
2.1 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
<?php
namespace app\api\controller\reservoir\run;
use app\common\controller\Api;
use think\Db;
use think\exception\PDOException;
/**
* 工单
*/
class Order extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\reservoir\run\Order;
}
/**
* 首页
*
*/
public function index()
{
$this->success('请求成功');
}
public function add()
{
if ($this->request->isPost()) {
$params = $this->reqeust->post();
if ($params) {
$params['createtime'] = time();
$res = $this->model->allowField(true)->save($params);
if (!$res) {
$this->error('网络繁忙');
}
$this->success('添加成功');
}
}
}
public function list()
{
$page = $this->request->param('page',1);
$limit = $this->request->param('limit',1);
$total = $this->model::count();
$list = $model
->page($page,$limit)
->select();
$data = [
'page' => $page,
'total'=> $total,
'data' => $list
];
$this->success('',$data);
}
public function del($ids=null)
{
$res = $this->model::destroy(1);
if (!$res) {
$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();
if ($params) {
$result = $row->allowField(true)->save($params);
if (!$result) {
$this->error('网络繁忙');
}
$this->success('修改成功');
}
}
$this->suceess('',$row);
}
}