AdminTeamController.php
3.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
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
<?php
/**
* 专业团队
* Author : xiaojie
* DateTime: 2018/12/03 11:31
*/
namespace app\portal\controller;
use app\portal\model\TeamModel;
use cmf\controller\AdminBaseController;
/**
* Class AdminTeamController
* @package app\portal\controller
* @adminMenuRoot(
* 'name' =>'专业团队',
* 'action' =>'default',
* 'parent' =>'',
* 'display'=> true,
* 'order' => 30,
* 'icon' =>'th',
* 'remark' =>'专业团队'
* )
*/
class AdminTeamController extends AdminBaseController
{
/**
* 专业团队
* @adminMenu(
* 'name' => '专业团队',
* 'parent' => 'portal/AdminTeam/default',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '专业团队',
* 'param' => ''
* )
*/
public function index()
{
$teamModel = new TeamModel();
$param = $this->request->param();
$map = $this->search($param,'update_time','name|mobile');
$list = $teamModel
->where($map)
->order('sort desc')
->paginate(30);
$this->assign('list',$list);
$this->assign('page',$list->render());
return $this->fetch();
}
//添加
public function add()
{
return $this->fetch();
}
//添加提交
public function addPost()
{
$teamModel = new TeamModel();
$param = $this->request->param();
$param['create_time'] = time();
$param['update_time'] = time();
$param['user_id'] = 1;
$res = $teamModel->create($param);
if($res){
$this->success('保存成功','AdminTeam/index');
}
$this->error('请稍后重试');
}
/**
* 编辑专业团队
* @adminMenu(
* 'name' => '编辑专业团队',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '编辑专业团队',
* 'param' => ''
* )
*/
public function edit()
{
$teamModel = new TeamModel();
$id = $this->request->param('id','','intval');
$info = $teamModel->where('id',$id)->find();
$this->assign('info',$info);
return $this->fetch();
}
/**
* 编辑专业团队提交
* @adminMenu(
* 'name' => '编辑专业团队提交',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '编辑专业团队提交',
* 'param' => ''
* )
*/
public function editPost()
{
$teamModel = new TeamModel();
$param = $this->request->param();
$res = $teamModel->isUpdate(true)->save($param);
if($res){
$this->success('保存成功','AdminTeam/index');
}
$this->error('请稍后重试');
}
}