MatchCert.php
2.0 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
<?php
namespace app\school\controller\match;
use think\Db;
use app\common\controller\ManystoreBase;
use app\school\model\match\MatchCert as MatchCertModel;
/**
* 证书管理
*/
class MatchCert extends ManystoreBase
{
protected $model = null;
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
$this->model = new MatchCertModel();
}
/**
* 证书管理首页
* @return \think\response\Json|void
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$count = $this->model->where($where)->count();
$list = $this->model
->where($where)
->order('createtime', 'desc')
->limit($offset, $limit)
->select();
$list = collection($list)->toArray();
$result = array("total" => $count, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
/**
* 添加证书
*/
public function add()
{
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
if($this->shopIdAutoCondition && SCHOOL_ID){
$params['school_id'] = SCHOOL_ID;
}
Db::startTrans();
try {
$result = $this->model->save($params);
Db::commit();
} catch (Exception $e) {
Db::rollback();
$this->error('添加失败');
}
$this->success();
}
$this->error(__('Parameter %s can not be empty', ''));
}
return $this->view->fetch();
}
}